1- import {
2- useMantineColorScheme ,
3- SegmentedControl ,
4- rem ,
5- MantineColorScheme ,
6- Tooltip ,
7- } from "@mantine/core" ;
1+ import { useMantineColorScheme , rem , ActionIcon } from "@mantine/core" ;
82import {
93 IconMoonFilled ,
104 IconSunFilled ,
11- IconUserFilled ,
5+ IconBrightnessFilled ,
126} from "@tabler/icons-react" ;
137import { FC } from "react" ;
148
@@ -20,45 +14,28 @@ export const ThemeSelector: FC = () => {
2014 } ;
2115
2216 return (
23- < SegmentedControl
24- color = "gray.7"
25- size = "xs"
26- // styles={{ root: { backgroundColor: "var(--mantine-color-gray-7)" } }}
27- styles = { {
28- root : {
29- padding : 3 ,
30- backgroundColor : "var(--mantine-color-gray-6)" ,
31- } ,
32- } }
33- withItemsBorders = { false }
34- value = { colorScheme }
35- onChange = { ( v ) => setColorScheme ( v as MantineColorScheme ) }
36- data = { [
37- {
38- value : "light" ,
39- label : (
40- < Tooltip label = "Use light theme" offset = { 15 } >
41- < IconSunFilled { ...iconProps } />
42- </ Tooltip >
43- ) ,
44- } ,
45- {
46- value : "dark" ,
47- label : (
48- < Tooltip label = "Use dark theme" offset = { 15 } >
49- < IconMoonFilled { ...iconProps } />
50- </ Tooltip >
51- ) ,
52- } ,
53- {
54- value : "auto" ,
55- label : (
56- < Tooltip label = "Use browser-preferred theme" offset = { 15 } >
57- < IconUserFilled { ...iconProps } />
58- </ Tooltip >
59- ) ,
60- } ,
61- ] }
62- />
17+ < ActionIcon
18+ color = "gray"
19+ title = { `Switch to ${ colorScheme === "light" ? "dark" : colorScheme === "dark" ? "browser-preferred" : "light" } theme` }
20+ aria-label = { `Switch to ${ colorScheme === "light" ? "dark" : colorScheme === "dark" ? "browser-preferred" : "light" } theme` }
21+ size = { 32 }
22+ onClick = { ( ) =>
23+ setColorScheme (
24+ colorScheme === "light"
25+ ? "dark"
26+ : colorScheme === "dark"
27+ ? "auto"
28+ : "light"
29+ )
30+ }
31+ >
32+ { colorScheme === "light" ? (
33+ < IconSunFilled { ...iconProps } />
34+ ) : colorScheme === "dark" ? (
35+ < IconMoonFilled { ...iconProps } />
36+ ) : (
37+ < IconBrightnessFilled { ...iconProps } />
38+ ) }
39+ </ ActionIcon >
6340 ) ;
6441} ;
0 commit comments