Skip to content
Source
Sign inSign up

useEnvironmentTheme.ts

19 lines719 Bytes

1import { useAtomValue } from "@effect/atom-react";
2​
3import { subscribeAtomChanges } from "../rpc/atomRegistry";
4import { environmentThemeDefinitionsAtom, type ThemeDefinition } from "../themePalette";
5import { refreshTheme } from "./useTheme";
6​
7export function useEnvironmentThemeDefinitions(): ReadonlyArray<ThemeDefinition> {
8 return useAtomValue(environmentThemeDefinitionsAtom);
9}
10​
11/**
12 * The palette is painted from a snapshot taken when the theme last changed, so new colors
13 * only land if the active theme is re-applied.
14 */
15export function startEnvironmentThemeRepaint(): () => void {
16 return subscribeAtomChanges(environmentThemeDefinitionsAtom, () => {
17 refreshTheme({ preservePreview: true });
18 });