11// @mui
22import { styled } from '@mui/material/styles'
3- import { CardActionArea , Grid , RadioGroup } from '@mui/material'
3+ import { CardActionArea , Grid , RadioGroup , Tooltip } from '@mui/material'
44import useSettings from 'hooks/useSettings'
55//
66import Iconify from './Iconify'
@@ -9,7 +9,7 @@ import BoxMask from './BoxMask'
99// ----------------------------------------------------------------------
1010
1111const BoxStyle = styled ( CardActionArea ) ( ( { theme } ) => ( {
12- height : 72 ,
12+ aspectRatio : '1' ,
1313 display : 'flex' ,
1414 alignItems : 'center' ,
1515 justifyContent : 'center' ,
@@ -23,26 +23,43 @@ const BoxStyle = styled(CardActionArea)(({ theme }) => ({
2323export default function SettingMode ( ) {
2424 const { themeMode, onChangeMode } = useSettings ( )
2525
26+ const modes = [ 'light' , 'dark' , 'system' ]
27+ const icons = [ 'ph:sun-duotone' , 'ph:moon-duotone' , 'ph:monitor-duotone' ]
28+
29+ const getBackgroundColor = ( mode : string ) => {
30+ if ( mode === 'light' ) return 'common.white'
31+ if ( mode === 'dark' ) return 'grey.800'
32+ return 'grey.600'
33+ }
34+
35+ const getModeLabel = ( mode : string ) => {
36+ return mode . charAt ( 0 ) . toUpperCase ( ) + mode . slice ( 1 )
37+ }
38+
2639 return (
2740 < RadioGroup name = 'themeMode' value = { themeMode } onChange = { onChangeMode } >
2841 < Grid dir = 'ltr' container spacing = { 2.5 } >
29- { [ 'light' , 'dark' ] . map ( ( mode , index ) => {
42+ { modes . map ( ( mode , index ) => {
3043 const isSelected = themeMode === mode
3144
3245 return (
33- < Grid key = { mode } item xs = { 6 } >
34- < BoxStyle
35- sx = { {
36- bgcolor : mode === 'light' ? 'common.white' : 'grey.800' ,
37- ...( isSelected && {
38- color : 'primary.main' ,
39- boxShadow : ( theme ) => theme . customShadows . z20 ,
40- } ) ,
41- } }
42- >
43- < Iconify icon = { index === 0 ? 'ph:sun-duotone' : 'ph:moon-duotone' } width = { 28 } height = { 28 } />
44- < BoxMask value = { mode } />
45- </ BoxStyle >
46+ < Grid key = { mode } item xs = { 4 } >
47+ < Tooltip title = { getModeLabel ( mode ) } arrow placement = 'bottom' >
48+ < span >
49+ < BoxStyle
50+ sx = { {
51+ bgcolor : getBackgroundColor ( mode ) ,
52+ ...( isSelected && {
53+ color : 'primary.main' ,
54+ boxShadow : ( theme ) => theme . customShadows . z20 ,
55+ } ) ,
56+ } }
57+ >
58+ < Iconify icon = { icons [ index ] } width = { 28 } height = { 28 } />
59+ < BoxMask value = { mode } />
60+ </ BoxStyle >
61+ </ span >
62+ </ Tooltip >
4663 </ Grid >
4764 )
4865 } ) }
0 commit comments