(
state: ThemeModeState,
persistedSlots?: { light?: string; dark?: string },
)
| 163 | }; |
| 164 | |
| 165 | export 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 | }; |
no test coverage detected