mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-07-04 15:21:29 +00:00

* refactor: replace comlink with kkrpc * fix: import path in api pkg and btn styling in ui iframe page * fix: fixed fetch API from kkRPC migrate * refactor: replace comlink-stdio with kkrpc * update deno lock * bump @kksh/api * update API version * publish api pkg again to fix kkrpc version * update pnpm lock * dep: fix dependency problems * dep: update deno.lock * chore: remove 2 submodules they were added only for integration development * update pnpm lock * fix: test template path * format: with prettier * downgrade next version * ci: try to fix next build on windows * try to fix CI * Revert "try to fix CI" This reverts commit b9c63c392f50f1d2d3ceec406e49b1af2348c740. * upgrade tauri-api-adapter * try to fix next * remove templates from pnpm workspace * update CI test * publish @kksh/api with upgraded tauri-api-adapter to fix nextjs template
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { type ClassValue, clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
import { cubicOut } from 'svelte/easing';
|
|
import type { TransitionConfig } from 'svelte/transition';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
type FlyAndScaleParams = {
|
|
y?: number;
|
|
x?: number;
|
|
start?: number;
|
|
duration?: number;
|
|
};
|
|
|
|
export const flyAndScale = (
|
|
node: Element,
|
|
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
|
): TransitionConfig => {
|
|
const style = getComputedStyle(node);
|
|
const transform = style.transform === 'none' ? '' : style.transform;
|
|
|
|
const scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {
|
|
const [minA, maxA] = scaleA;
|
|
const [minB, maxB] = scaleB;
|
|
|
|
const percentage = (valueA - minA) / (maxA - minA);
|
|
const valueB = percentage * (maxB - minB) + minB;
|
|
|
|
return valueB;
|
|
};
|
|
|
|
const styleToString = (style: Record<string, number | string | undefined>): string => {
|
|
return Object.keys(style).reduce((str, key) => {
|
|
if (style[key] === undefined) return str;
|
|
return str + `${key}:${style[key]};`;
|
|
}, '');
|
|
};
|
|
|
|
return {
|
|
duration: params.duration ?? 200,
|
|
delay: 0,
|
|
css: (t) => {
|
|
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);
|
|
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);
|
|
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);
|
|
|
|
return styleToString({
|
|
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
|
|
opacity: t
|
|
});
|
|
},
|
|
easing: cubicOut
|
|
};
|
|
};
|