Skip to content

Commit 04e79d1

Browse files
author
Ruizhe Pang
committed
Update the UI
1 parent 933538b commit 04e79d1

File tree

2 files changed

+78
-29
lines changed

2 files changed

+78
-29
lines changed

src/renderer/components/settings/NotificationSettings.tsx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -246,33 +246,6 @@ export const NotificationSettings: FC = () => {
246246
</Text>
247247
}
248248
/>
249-
250-
<Stack direction="horizontal" gap="condensed" alignItems="center">
251-
<Text as="label" htmlFor="notificationVolume">
252-
Notification Volume:
253-
</Text>
254-
<input
255-
id="notificationVolume"
256-
type="number"
257-
min={0}
258-
max={100}
259-
step={1}
260-
value={settings.notificationVolume}
261-
onChange={(evt) => {
262-
let val = Number(evt.target.value);
263-
if (Number.isNaN(val)) val = 0;
264-
if (val > 100) val = 100;
265-
if (val < 0) val = 0;
266-
updateSetting('notificationVolume', val);
267-
}}
268-
style={{
269-
width: '3rem',
270-
textAlign: 'center',
271-
border: '1px solid #ccc',
272-
borderRadius: '4px',
273-
}}
274-
/>
275-
</Stack>
276249
</Stack>
277250
</fieldset>
278251
);

src/renderer/components/settings/SystemSettings.tsx

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { type FC, useContext } from 'react';
22

3-
import { DeviceDesktopIcon } from '@primer/octicons-react';
4-
import { Box, Stack, Text } from '@primer/react';
3+
import {
4+
DashIcon,
5+
DeviceDesktopIcon,
6+
PlusIcon,
7+
XCircleIcon,
8+
} from '@primer/octicons-react';
9+
10+
import {
11+
Box,
12+
Button,
13+
ButtonGroup,
14+
IconButton,
15+
Stack,
16+
Text,
17+
} from '@primer/react';
518

619
import { APPLICATION } from '../../../shared/constants';
720
import { isLinux, isMacOS } from '../../../shared/platform';
821
import { AppContext } from '../../context/App';
922
import { OpenPreference } from '../../types';
1023
import { Constants } from '../../utils/constants';
1124
import { Checkbox } from '../fields/Checkbox';
25+
import { FieldLabel } from '../fields/FieldLabel';
1226
import { RadioGroup } from '../fields/RadioGroup';
1327
import { Title } from '../primitives/Title';
1428

@@ -77,6 +91,68 @@ export const SystemSettings: FC = () => {
7791
onChange={(evt) => updateSetting('playSound', evt.target.checked)}
7892
/>
7993

94+
{settings.playSound && (
95+
<Stack
96+
direction="horizontal"
97+
gap="condensed"
98+
align="center"
99+
className="text-sm"
100+
>
101+
<FieldLabel
102+
name="notificationVolume"
103+
label="Notification volume:"
104+
/>
105+
106+
<ButtonGroup className="ml-2">
107+
<IconButton
108+
aria-label="Volume down"
109+
size="small"
110+
icon={DashIcon}
111+
unsafeDisableTooltip={true}
112+
onClick={() => {
113+
const newVolume = Math.max(
114+
settings.notificationVolume - 10,
115+
0,
116+
);
117+
updateSetting('notificationVolume', newVolume);
118+
}}
119+
data-testid="settings-volume-down"
120+
/>
121+
122+
<Button aria-label="Volume percentage" size="small" disabled>
123+
{settings.notificationVolume.toFixed(0)}%
124+
</Button>
125+
126+
<IconButton
127+
aria-label="Volume up"
128+
size="small"
129+
icon={PlusIcon}
130+
unsafeDisableTooltip={true}
131+
onClick={() => {
132+
const newVolume = Math.min(
133+
settings.notificationVolume + 10,
134+
100,
135+
);
136+
updateSetting('notificationVolume', newVolume);
137+
}}
138+
data-testid="settings-volume-up"
139+
/>
140+
141+
<IconButton
142+
aria-label="Reset volume"
143+
size="small"
144+
variant="danger"
145+
icon={XCircleIcon}
146+
unsafeDisableTooltip={true}
147+
onClick={() => {
148+
updateSetting('notificationVolume', 20);
149+
}}
150+
data-testid="settings-volume-reset"
151+
/>
152+
</ButtonGroup>
153+
</Stack>
154+
)}
155+
80156
<Checkbox
81157
name="useAlternateIdleIcon"
82158
label="Use alternate idle icon"

0 commit comments

Comments
 (0)