mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
28 lines
642 B
TypeScript
28 lines
642 B
TypeScript
import { getContext, setContext, type Component } from "svelte";
|
|
|
|
export const THEMES = { light: "", dark: ".dark" } as const;
|
|
|
|
export type ChartConfig = {
|
|
[k in string]: {
|
|
label?: string;
|
|
icon?: Component;
|
|
} & (
|
|
| { color?: string; theme?: never }
|
|
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
);
|
|
};
|
|
|
|
type ChartContextValue = {
|
|
config: ChartConfig;
|
|
};
|
|
|
|
const chartContextKey = Symbol("chart-context");
|
|
|
|
export function setChartContext(value: ChartContextValue) {
|
|
return setContext(chartContextKey, value);
|
|
}
|
|
|
|
export function useChart() {
|
|
return getContext<ChartContextValue>(chartContextKey);
|
|
}
|