feat(waybar): implement all dummy widgets
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { type Child, type Icon } from "./tree";
|
||||
|
||||
export const lerpIcon = (icons: Array<string>, value: number, max: number) =>
|
||||
icons[Math.floor((value / max) * icons.length)] ?? icons[icons.length - 1];
|
||||
|
||||
export const getIcon = (file: Child | string | undefined): Icon => {
|
||||
if (!file) return DEFAULT_ICON;
|
||||
|
||||
|
||||
5
src/utils/math.ts
Normal file
5
src/utils/math.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const clamp = (v: number, min: number, max: number) =>
|
||||
Math.min(Math.max(v, min), max);
|
||||
|
||||
export const randomMinMax = (min: number, max: number) =>
|
||||
Math.floor(Math.random() * (max - min) + min);
|
||||
4
src/utils/react.ts
Normal file
4
src/utils/react.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { type ClassNameValue, twMerge } from "tailwind-merge";
|
||||
import { clsx } from "clsx";
|
||||
|
||||
export const cn = (...classes: Array<ClassNameValue>) => twMerge(clsx(classes));
|
||||
@@ -6,3 +6,12 @@ export type Prettify<T> = NonNullable<{ [K in keyof T]: T[K] }>;
|
||||
export type InnerKittyProps<T extends (...args: any[]) => any> = Prettify<
|
||||
Parameters<T>[0] & KittyContextProps
|
||||
>;
|
||||
|
||||
export type State<
|
||||
Name extends string,
|
||||
T,
|
||||
> = Name extends `${infer First}${infer Rest}`
|
||||
? {
|
||||
[K in Name]: T;
|
||||
} & { [K in `set${Capitalize<First>}${Rest}`]: (value: T) => void }
|
||||
: never;
|
||||
|
||||
Reference in New Issue
Block a user