/
SettingsGroup.js
79 lines (71 loc) 路 1.57 KB
/
SettingsGroup.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react'
import styled, { up, css, Box } from '@xstyled/styled-components'
import { useHiddenState, Hidden, HiddenDisclosure } from 'reakit/Hidden'
import { ChevronLeft } from 'components/playground/icons/ChevronLeft'
const Container = styled.div`
border-right: 1px solid;
border-color: light400;
`
const Marker = styled(ChevronLeft)`
width: 18;
height: 18;
transition: base;
transform: rotate(90deg);
${up(
'md',
css`
transform: rotate(0);
`,
)}
`
const Button = styled.buttonBox`
font-size: 15;
font-weight: bold;
padding: 8 16;
background-color: transparent;
border: none;
color: inherit;
cursor: pointer;
transition: base;
border: 0;
border-bottom: 1px solid;
border-color: light400;
appearance: none;
margin: 0;
width: 100%;
text-align: left;
&[aria-expanded='true'] {
${Marker} {
transform: rotate(-90deg);
}
}
&:focus,
&:hover {
background-color: light200;
outline: none;
}
`
const Content = styled.div`
border-bottom: 1px solid;
border-color: light400;
`
export function SettingsGroup({ title, children }) {
const hidden = useHiddenState({ visible: true })
return (
<Container>
<HiddenDisclosure {...hidden}>
{hiddenDisclosureProps => (
<Button row {...hiddenDisclosureProps}>
<Box col>{title}</Box>
<Box col="auto">
<Marker />
</Box>
</Button>
)}
</HiddenDisclosure>
<Hidden as={Content} {...hidden}>
{children}
</Hidden>
</Container>
)
}