@@ -13,24 +13,34 @@ import {
13
13
TagIcon ,
14
14
XCircleIcon ,
15
15
} from '@primer/octicons-react' ;
16
- import { Button , ButtonGroup , IconButton , useTheme } from '@primer/react' ;
16
+ import {
17
+ Button ,
18
+ ButtonGroup ,
19
+ IconButton ,
20
+ Select ,
21
+ useTheme ,
22
+ } from '@primer/react' ;
17
23
18
24
import { namespacedEvent } from '../../../shared/events' ;
19
25
import { AppContext } from '../../context/App' ;
20
26
import { Size , Theme } from '../../types' ;
21
27
import { hasMultipleAccounts } from '../../utils/auth/utils' ;
22
- import { getColorModeFromTheme , setTheme } from '../../utils/theme' ;
28
+ import {
29
+ DEFAULT_DAY_COLOR_SCHEME ,
30
+ DEFAULT_NIGHT_COLOR_SCHEME ,
31
+ isDayScheme ,
32
+ setScrollbarTheme ,
33
+ } from '../../utils/theme' ;
23
34
import { zoomLevelToPercentage , zoomPercentageToLevel } from '../../utils/zoom' ;
24
35
import { Checkbox } from '../fields/Checkbox' ;
25
36
import { FieldLabel } from '../fields/FieldLabel' ;
26
- import { RadioGroup } from '../fields/RadioGroup' ;
27
37
import { Title } from '../primitives/Title' ;
28
38
29
39
let timeout : NodeJS . Timeout ;
30
40
const DELAY = 200 ;
31
41
32
42
export const AppearanceSettings : FC = ( ) => {
33
- const { setColorMode } = useTheme ( ) ;
43
+ const { setColorMode, setDayScheme , setNightScheme } = useTheme ( ) ;
34
44
const { auth, settings, updateSetting } = useContext ( AppContext ) ;
35
45
const [ zoomPercentage , setZoomPercentage ] = useState (
36
46
zoomLevelToPercentage ( webFrame . getZoomLevel ( ) ) ,
@@ -41,14 +51,15 @@ export const AppearanceSettings: FC = () => {
41
51
namespacedEvent ( 'update-theme' ) ,
42
52
( _ , updatedTheme : Theme ) => {
43
53
if ( settings . theme === Theme . SYSTEM ) {
44
- const mode = getColorModeFromTheme ( updatedTheme ) ;
45
-
46
- setTheme ( updatedTheme ) ;
47
- setColorMode ( mode ) ;
54
+ const mode = isDayScheme ( updatedTheme ) ? 'day' : 'night' ;
55
+ setColorMode ( 'auto' ) ;
56
+ setDayScheme ( DEFAULT_DAY_COLOR_SCHEME ) ;
57
+ setNightScheme ( DEFAULT_NIGHT_COLOR_SCHEME ) ;
58
+ setScrollbarTheme ( mode ) ;
48
59
}
49
60
} ,
50
61
) ;
51
- } , [ settings . theme , setColorMode ] ) ;
62
+ } , [ settings . theme , setColorMode , setDayScheme , setNightScheme ] ) ;
52
63
53
64
window . addEventListener ( 'resize' , ( ) => {
54
65
// clear the timeout
@@ -65,20 +76,48 @@ export const AppearanceSettings: FC = () => {
65
76
< fieldset >
66
77
< Title icon = { PaintbrushIcon } > Appearance</ Title >
67
78
68
- < RadioGroup
69
- name = "theme"
70
- label = "Theme:"
71
- value = { settings . theme }
72
- options = { [
73
- { label : 'System' , value : Theme . SYSTEM } ,
74
- { label : 'Light' , value : Theme . LIGHT } ,
75
- { label : 'Dark' , value : Theme . DARK } ,
76
- ] }
77
- onChange = { ( evt ) => updateSetting ( 'theme' , evt . target . value as Theme ) }
78
- />
79
+ < div className = "flex items-center mt-3 mb-2 text-sm" >
80
+ < FieldLabel name = "theme" label = "Theme:" />
81
+
82
+ < Select
83
+ id = "theme"
84
+ value = { settings . theme }
85
+ onChange = { ( evt ) => updateSetting ( 'theme' , evt . target . value as Theme ) }
86
+ data-testid = "settings-theme"
87
+ >
88
+ < Select . OptGroup label = "System" >
89
+ < Select . Option value = { Theme . SYSTEM } > System</ Select . Option >
90
+ </ Select . OptGroup >
91
+ < Select . OptGroup label = "Light" >
92
+ < Select . Option value = { Theme . LIGHT } > Light default</ Select . Option >
93
+ < Select . Option value = { Theme . LIGHT_HIGH_CONTRAST } >
94
+ Light high contrast
95
+ </ Select . Option >
96
+ < Select . Option value = { Theme . LIGHT_COLORBLIND } >
97
+ Light Protanopia & Deuteranopia
98
+ </ Select . Option >
99
+ < Select . Option value = { Theme . LIGHT_TRITANOPIA } >
100
+ Light Tritanopia
101
+ </ Select . Option >
102
+ </ Select . OptGroup >
103
+ < Select . OptGroup label = "Dark" >
104
+ < Select . Option value = { Theme . DARK } > Dark default</ Select . Option >
105
+ < Select . Option value = { Theme . DARK_HIGH_CONTRAST } >
106
+ Dark high contrast
107
+ </ Select . Option >
108
+ < Select . Option value = { Theme . DARK_COLORBLIND } >
109
+ Dark Protanopia & Deuteranopia
110
+ </ Select . Option >
111
+ < Select . Option value = { Theme . DARK_TRITANOPIA } >
112
+ Dark Tritanopia
113
+ </ Select . Option >
114
+ < Select . Option value = { Theme . DARK_DIMMED } > Dark dimmed</ Select . Option >
115
+ </ Select . OptGroup >
116
+ </ Select >
117
+ </ div >
79
118
80
119
< div className = "flex items-center mt-3 mb-2 text-sm" >
81
- < FieldLabel name = "zoom" label = "Zoom" />
120
+ < FieldLabel name = "zoom" label = "Zoom: " />
82
121
83
122
< ButtonGroup >
84
123
< IconButton
0 commit comments