MCPcopy Index your code
hub / github.com/coder/coder / draftFromState

Function draftFromState

site/src/theme/themeMode.ts:165–188  ·  view source on GitHub ↗
(
	state: ThemeModeState,
	persistedSlots?: { light?: string; dark?: string },
)

Source from the content-addressed store, hash-verified

163};
164
165export const draftFromState = (
166 state: ThemeModeState,
167 persistedSlots?: { light?: string; dark?: string },
168): ThemeModeDraft => {
169 if (state.mode === "sync") {
170 // Seed the "single" slot from the dark slot since historical
171 // default behavior preferred dark. If the user later switches
172 // modes via the dropdown, `switchToSingle` overrides this with
173 // the OS-matching slot anyway.
174 return {
175 mode: "sync",
176 single: state.dark,
177 light: state.light,
178 dark: state.dark,
179 };
180 }
181 const pair = FAMILY_PAIR[state.theme];
182 return {
183 mode: "single",
184 single: state.theme,
185 light: coerceConcrete(persistedSlots?.light, pair.light),
186 dark: coerceConcrete(persistedSlots?.dark, pair.dark),
187 };
188};

Callers 2

themeMode.test.tsFile · 0.90
toFormValuesFunction · 0.90

Calls 1

coerceConcreteFunction · 0.85

Tested by

no test coverage detected