Repository navigation
Conversation
setTheme(null) removes the saved theme in every tab and applies the theme the page starts with when nothing was chosen, so ThemeScript and initTheme follow prefers-color-scheme again. getTheme and useTheme keep returning the theme in effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g example Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setTheme(theme: ThemeName | null):nullmeans "forget the user's explicit choice and follow the system again".__DF_THEME_SELECTED__) — other tabs follow through the nativestorageevent.data-theme, then lets the runningThemeScript/initThemere-apply the first-load theme with their ownautoand default theme (a same-tabstorageevent for the theme key, which both already listen to). Their existingprefers-color-schemelisteners keep following the system afterwards, since no saved choice blocks them anymore.ThemeScriptorinitThemeon the page, it applies the system preference once (darkfor a dark system, else the default theme); there is nothing to keep listening in that setup, the same as before.getTheme()/useTheme()keep their return types and return the theme in effect after a reset (nevernullon a page), so toggles likegetTheme() === 'dark'keep working.ThemeScriptinline script is unchanged: on first load with no saved choice it already picks the system theme before paint, so there is no flash after a reset either.@devup-ui/react, so the React Native runtime (feat(native): theme tokens, multiple themes and the React Native runtime #1042) gets the nullable argument too.Shared helpers moved to
utils/theme-system.ts(storage key, saved-theme read, system theme) soinitThemeandsetTheme(null)resolve the theme the same way.Tests
theme-behavior.browser.test.ts: reset withinitTheme(true)(back to system, then follows its changes), withinitTheme(false)(default theme), without any runtime (system once), nomatchMedia, blockedremoveItem,StorageEventunavailable, server no-op.ThemeScript.behavior.browser.test.tsx: the inline script follows the reset (auto and non-auto).use-theme.browser.test.ts:useTheme()returns the effective theme aftersetTheme(null).setTheme(null)type-checks.SKILL.md. Changepack (patch) for@devup-ui/react.요약
setTheme(theme: ThemeName | null):null은 "사용자가 명시적으로 고른 테마를 잊고 다시 시스템을 따른다"는 뜻입니다.__DF_THEME_SELECTED__)를 지웁니다. 다른 탭은 기본storage이벤트로 따라옵니다.data-theme을 지운 뒤, 실행 중인ThemeScript/initTheme이 자신의auto와 기본 테마로 첫 로드 테마를 다시 적용하게 합니다(둘 다 이미 듣고 있는 테마 키의 같은 탭storage이벤트). 저장된 선택이 없으므로 기존prefers-color-scheme리스너가 이후 시스템 변경을 계속 따릅니다.ThemeScript나initTheme이 없는 페이지에서는 시스템 설정을 한 번 적용합니다(다크면dark, 아니면 기본 테마). 그 구성에는 계속 들을 주체가 없으며 이전과 같습니다.getTheme()/useTheme()의 반환 타입은 그대로이며, 리셋 후에도 실제 적용된 테마를 반환합니다(페이지에서는null이 아님).getTheme() === 'dark'같은 토글이 그대로 동작합니다.ThemeScript인라인 스크립트는 변경이 없습니다. 저장된 선택이 없으면 첫 로드에서 이미 페인트 전에 시스템 테마를 고르므로 리셋 후에도 깜빡임이 없습니다.@devup-ui/react에 있으므로 React Native 런타임(feat(native): theme tokens, multiple themes and the React Native runtime #1042)도 nullable 인자를 받게 됩니다.공용 헬퍼(저장 키, 저장 테마 읽기, 시스템 테마)를
utils/theme-system.ts로 옮겨initTheme과setTheme(null)이 같은 방식으로 테마를 정합니다.테스트
theme-behavior.browser.test.ts:initTheme(true)에서 리셋(시스템으로 복귀 후 변경 추적),initTheme(false)(기본 테마), 런타임 없음(시스템 1회),matchMedia없음,removeItem차단,StorageEvent사용 불가, 서버 no-op.ThemeScript.behavior.browser.test.tsx: 인라인 스크립트가 리셋을 따름(auto / non-auto).use-theme.browser.test.ts:setTheme(null)후useTheme()이 실제 테마를 반환.setTheme(null)타입 체크.SKILL.md.@devup-ui/reactchangepack(patch).🤖 Generated with Claude Code