blob: 4e9c5078c2ff62e32b47922f71e8c3e180a7dea7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { useId } from 'react'
import { ActionButton } from '@react-spectrum/s2/ActionButton'
import { DialogTrigger, Popover } from '@react-spectrum/s2/Popover'
import { Radio, RadioGroup } from '@react-spectrum/s2/RadioGroup'
import { Tooltip, TooltipTrigger } from '@react-spectrum/s2/Tooltip'
import SettingsIcon from '@react-spectrum/s2/icons/Settings'
import { useTheme } from '../theme'
import styles from './global-settings.module.css'
function GlobalSettings() {
const titleId = useId()
const { colorScheme, setColorScheme } = useTheme()
return (
<DialogTrigger>
<TooltipTrigger>
<ActionButton aria-label="全局设置" isQuiet>
<SettingsIcon />
</ActionButton>
<Tooltip>全局设置</Tooltip>
</TooltipTrigger>
<Popover placement="bottom end" aria-labelledby={titleId}>
<div className={styles.settings}>
<h2 id={titleId} className={styles.title}>全局设置</h2>
<RadioGroup
label="外观模式"
value={colorScheme}
onChange={(value) => {
if (value === 'light' || value === 'dark') setColorScheme(value)
}}
>
<Radio value="light">亮色</Radio>
<Radio value="dark">暗色</Radio>
</RadioGroup>
</div>
</Popover>
</DialogTrigger>
)
}
export default GlobalSettings
|