Files
progcode/docs/design-system/kit-completeness/reference-source/fsd/features/theme-selection/ui/ThemeInit.jsx
T
huncode 12562baeb5
Build and deploy / deploy (push) Successful in 2m39s
Implement ProgCode identity and real shared reading UI kit
2026-10-27 15:19:49 +03:00

4 lines
486 B
React

import {THEME_STORAGE_KEY} from '../../../shared/config';
// Constant script contains only the storage key and allowlisted preference values.
export function ThemeInit(){const code=`try{var t=localStorage.getItem(${JSON.stringify(THEME_STORAGE_KEY)});document.documentElement.dataset.theme=(t==='light'||t==='dark'||t==='system')?t:'system';}catch(e){document.documentElement.dataset.theme='system';}`;return <script id="progcode-theme-init" dangerouslySetInnerHTML={{__html:code}}/>;}