/**
* The var layer as one `
);
}
/**
* Read a live Tamagui theme into the two forms `graphCssVars` needs.
*
* The CSS form comes from the Variable itself (`var(--…)` on web) rather than
* from a reconstructed prefix, so nothing here has to know how Tamagui names
* its custom properties. The raw form is the literal value, and is used only by
* the two blended entries.
*/
export function useGraphThemeAccess(): GraphThemeAccess {
const theme = useTamaguiTheme();
return useMemo(() => {
const read = (key: string): unknown => (theme as unknown as Record)[key];
return {
css: (key: string) => {
const value = read(key);
if (value == null) return undefined;
const variable = (value as { variable?: string }).variable;
if (typeof variable === "string" && variable) return variable;
const resolved = getVariable(value as never);
return typeof resolved === "string" ? resolved : undefined;
},
raw: (key: string) => {
const value = read(key);
if (value == null) return undefined;
if (typeof value === "string") return value;
const val = (value as { val?: unknown }).val;
return typeof val === "string" ? val : undefined;
},
};
}, [theme]);
}
/** `graphCssVars` against the live theme. */
export function useGraphCssVars(
resolved: ResolvedKnobs,
options?: GraphCssVarsOptions,
): Record {
const theme = useGraphThemeAccess();
const pointer = options?.pointer;
return useMemo(() => graphCssVars(resolved, theme, { pointer }), [resolved, theme, pointer]);
}