@@ -424,8 +424,22 @@ const getStoredTheme = (): ThemeMode => {
424424 return localStorage . getItem ( "textodon.christmas" ) === "on" ? "christmas" : "default" ;
425425} ;
426426
427+ type ColorScheme = "system" | "light" | "dark" ;
428+
429+ const isColorScheme = ( value : string ) : value is ColorScheme =>
430+ value === "system" || value === "light" || value === "dark" ;
431+
432+ const getStoredColorScheme = ( ) : ColorScheme => {
433+ const storedScheme = localStorage . getItem ( "textodon.colorScheme" ) ;
434+ if ( storedScheme && isColorScheme ( storedScheme ) ) {
435+ return storedScheme ;
436+ }
437+ return "system" ;
438+ } ;
439+
427440export const App = ( ) => {
428441 const [ themeMode , setThemeMode ] = useState < ThemeMode > ( ( ) => getStoredTheme ( ) ) ;
442+ const [ colorScheme , setColorScheme ] = useState < ColorScheme > ( ( ) => getStoredColorScheme ( ) ) ;
429443 const [ sectionSize , setSectionSize ] = useState < "small" | "medium" | "large" > ( ( ) => {
430444 const stored = localStorage . getItem ( "textodon.sectionSize" ) ;
431445 if ( stored === "medium" || stored === "large" || stored === "small" ) {
@@ -633,6 +647,17 @@ export const App = () => {
633647 localStorage . setItem ( "textodon.christmas" , themeMode === "christmas" ? "on" : "off" ) ;
634648 } , [ themeMode ] ) ;
635649
650+ useEffect ( ( ) => {
651+ if ( colorScheme === "system" ) {
652+ delete document . documentElement . dataset . colorScheme ;
653+ delete document . body . dataset . colorScheme ;
654+ } else {
655+ document . documentElement . dataset . colorScheme = colorScheme ;
656+ document . body . dataset . colorScheme = colorScheme ;
657+ }
658+ localStorage . setItem ( "textodon.colorScheme" , colorScheme ) ;
659+ } , [ colorScheme ] ) ;
660+
636661 useEffect ( ( ) => {
637662 document . documentElement . dataset . sectionSize = sectionSize ;
638663 localStorage . setItem ( "textodon.sectionSize" , sectionSize ) ;
@@ -1154,6 +1179,26 @@ export const App = () => {
11541179 < option value = "monochrome" > 모노톤</ option >
11551180 </ select >
11561181 </ div >
1182+ < div className = "settings-item" >
1183+ < div >
1184+ < strong > 색상 모드</ strong >
1185+ < p > 시스템 설정을 따르거나 라이트/다크 모드를 고정합니다.</ p >
1186+ </ div >
1187+ < select
1188+ value = { colorScheme }
1189+ onChange = { ( event ) => {
1190+ const nextScheme = event . target . value ;
1191+ if ( isColorScheme ( nextScheme ) ) {
1192+ setColorScheme ( nextScheme ) ;
1193+ }
1194+ } }
1195+ aria-label = "색상 모드 선택"
1196+ >
1197+ < option value = "system" > 시스템</ option >
1198+ < option value = "light" > 라이트</ option >
1199+ < option value = "dark" > 다크</ option >
1200+ </ select >
1201+ </ div >
11571202 < div className = "settings-item" >
11581203 < div >
11591204 < strong > 프로필 이미지 표시</ strong >
0 commit comments