|
1 | 1 | import { type FC, useContext } from 'react'; |
2 | 2 |
|
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'; |
5 | 18 |
|
6 | 19 | import { APPLICATION } from '../../../shared/constants'; |
7 | 20 | import { isLinux, isMacOS } from '../../../shared/platform'; |
8 | 21 | import { AppContext } from '../../context/App'; |
9 | 22 | import { OpenPreference } from '../../types'; |
10 | 23 | import { Constants } from '../../utils/constants'; |
11 | 24 | import { Checkbox } from '../fields/Checkbox'; |
| 25 | +import { FieldLabel } from '../fields/FieldLabel'; |
12 | 26 | import { RadioGroup } from '../fields/RadioGroup'; |
13 | 27 | import { Title } from '../primitives/Title'; |
14 | 28 |
|
@@ -77,6 +91,68 @@ export const SystemSettings: FC = () => { |
77 | 91 | onChange={(evt) => updateSetting('playSound', evt.target.checked)} |
78 | 92 | /> |
79 | 93 |
|
| 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 | + |
80 | 156 | <Checkbox |
81 | 157 | name="useAlternateIdleIcon" |
82 | 158 | label="Use alternate idle icon" |
|
0 commit comments