format
This commit is contained in:
@@ -1,28 +1,27 @@
|
|||||||
|
/* eslint-disable */
|
||||||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__TAURI_INVOKE__<T>(
|
__TAURI_INVOKE__<T>(cmd: string, args?: Record<string, unknown>): Promise<T>
|
||||||
cmd: string,
|
|
||||||
args?: Record<string, unknown>
|
|
||||||
): Promise<T>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const invoke = window.__TAURI_INVOKE__;
|
// Function avoids 'window not defined' in SSR
|
||||||
|
const invoke = () => window.__TAURI_INVOKE__
|
||||||
|
|
||||||
export function helloTauri() {
|
export function helloTauri() {
|
||||||
return invoke<string>('hello_tauri');
|
return invoke()<string>('hello_tauri')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hash256sum(hashInput: string) {
|
export function hash256sum(hashInput: string) {
|
||||||
return invoke<string>('hash256sum', { hashInput });
|
return invoke()<string>('hash256sum', { hashInput })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function storeSetKey(key: string, value: string) {
|
export function storeSetKey(key: string, value: string) {
|
||||||
return invoke<null>('store_set_key', { key, value });
|
return invoke()<null>('store_set_key', { key, value })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function storeReadKey(key: string) {
|
export function storeReadKey(key: string) {
|
||||||
return invoke<string | null>('store_read_key', { key });
|
return invoke()<string | null>('store_read_key', { key })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,62 @@
|
|||||||
import { type ClassValue, clsx } from 'clsx';
|
import { type ClassValue, clsx } from 'clsx'
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge'
|
||||||
import { cubicOut } from 'svelte/easing';
|
import { cubicOut } from 'svelte/easing'
|
||||||
import type { TransitionConfig } from 'svelte/transition';
|
import type { TransitionConfig } from 'svelte/transition'
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlyAndScaleParams = {
|
type FlyAndScaleParams = {
|
||||||
y?: number;
|
y?: number
|
||||||
x?: number;
|
x?: number
|
||||||
start?: number;
|
start?: number
|
||||||
duration?: number;
|
duration?: number
|
||||||
};
|
}
|
||||||
|
|
||||||
export const flyAndScale = (
|
export const flyAndScale = (
|
||||||
node: Element,
|
node: Element,
|
||||||
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
||||||
): TransitionConfig => {
|
): TransitionConfig => {
|
||||||
const style = getComputedStyle(node);
|
const style = getComputedStyle(node)
|
||||||
const transform = style.transform === 'none' ? '' : style.transform;
|
const transform = style.transform === 'none' ? '' : style.transform
|
||||||
|
|
||||||
const scaleConversion = (
|
const scaleConversion = (
|
||||||
valueA: number,
|
valueA: number,
|
||||||
scaleA: [number, number],
|
scaleA: [number, number],
|
||||||
scaleB: [number, number]
|
scaleB: [number, number]
|
||||||
) => {
|
) => {
|
||||||
const [minA, maxA] = scaleA;
|
const [minA, maxA] = scaleA
|
||||||
const [minB, maxB] = scaleB;
|
const [minB, maxB] = scaleB
|
||||||
|
|
||||||
const percentage = (valueA - minA) / (maxA - minA);
|
const percentage = (valueA - minA) / (maxA - minA)
|
||||||
const valueB = percentage * (maxB - minB) + minB;
|
const valueB = percentage * (maxB - minB) + minB
|
||||||
|
|
||||||
return valueB;
|
return valueB
|
||||||
};
|
}
|
||||||
|
|
||||||
const styleToString = (
|
const styleToString = (
|
||||||
style: Record<string, number | string | undefined>
|
style: Record<string, number | string | undefined>
|
||||||
): string => {
|
): string => {
|
||||||
return Object.keys(style).reduce((str, key) => {
|
return Object.keys(style).reduce((str, key) => {
|
||||||
if (style[key] === undefined) return str;
|
if (style[key] === undefined) return str
|
||||||
return str + `${key}:${style[key]};`;
|
return str + `${key}:${style[key]};`
|
||||||
}, '');
|
}, '')
|
||||||
};
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
duration: params.duration ?? 200,
|
duration: params.duration ?? 200,
|
||||||
delay: 0,
|
delay: 0,
|
||||||
css: t => {
|
css: t => {
|
||||||
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);
|
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0])
|
||||||
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);
|
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0])
|
||||||
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);
|
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1])
|
||||||
|
|
||||||
return styleToString({
|
return styleToString({
|
||||||
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
|
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
|
||||||
opacity: t
|
opacity: t
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
easing: cubicOut
|
easing: cubicOut
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user