-
Notifications
You must be signed in to change notification settings - Fork 402
/
Header.tsx
230 lines (220 loc) · 8.84 KB
/
Header.tsx
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import React from 'react';
import NextLink from 'next/link';
import { useRouter } from 'next/router';
import {
Box,
Container,
Text,
Badge,
Flex,
Button,
Popover,
PopoverTrigger,
PopoverContent,
Separator,
Link,
Heading,
styled,
} from '@modulz/design-system';
import { RadixLogo } from '@components/RadixLogo';
import { PlusIcon, MixIcon, StitchesLogoIcon } from '@radix-ui/react-icons';
import { ThemeToggle } from '@components/ThemeToggle';
import { BoxLink } from '@components/BoxLink';
import { RadixLogoIcon } from './RadixLogoIcon';
import { RemoveScroll } from 'react-remove-scroll';
export const Header = () => {
const router = useRouter();
const isColors = router.pathname.includes('/colors') || router.pathname.includes('/docs/colors');
return (
<Box as="header" className={RemoveScroll.classNames.fullWidth}>
<Container size="4">
<Flex align="center" justify="between" css={{ height: '$8' }}>
<NextLink href={isColors ? '/colors' : '/'} passHref>
<BoxLink>
<RadixLogo label={isColors ? 'Radix Colors homepage' : 'Radix homepage'} />
</BoxLink>
</NextLink>
<Flex
align="center"
gap={{ '@initial': 4, '@bp2': 5 }}
// Baseline align with the logo
css={{ mb: -2 }}
>
<Box css={{ display: 'none', '@bp1': { display: 'contents' } }}>
{isColors && (
<NextLink href="/docs/colors" passHref>
<Link variant={router.pathname.includes('/docs/colors') ? 'contrast' : 'subtle'}>
<Text>Documentation</Text>
</Link>
</NextLink>
)}
{isColors === false && (
<>
<NextLink href="/docs/primitives" passHref>
<Link
variant={router.pathname.includes('/docs/primitives') ? 'contrast' : 'subtle'}
>
<Text>Documentation</Text>
</Link>
</NextLink>
<NextLink href="/case-studies" passHref>
<Link
variant={router.pathname.includes('/case-studies') ? 'contrast' : 'subtle'}
>
<Text>Case studies</Text>
</Link>
</NextLink>
</>
)}
</Box>
<Popover>
<PopoverTrigger asChild>
<Link
variant="subtle"
as="button"
css={{
bc: 'transparent',
cursor: 'pointer',
appearance: 'none',
fontFamily: '$untitled',
border: 0,
p: 0,
m: 0,
mr: '-$1',
}}
>
<Text css={{ display: 'flex', gap: '$1', ai: 'center' }}>
Resources
<PlusIcon />
</Text>
</Link>
</PopoverTrigger>
<PopoverContent hideArrow sideOffset={15} align="end" alignOffset={-15}>
<Box css={{ p: '$1' }}>
{isColors && (
<NextLink href="/" passHref>
<HighlightLink>
<Flex gap="3">
<RadixLogoIcon
width="25"
height="25"
style={{ flex: 'none', marginTop: 2 }}
/>
<Box>
<Text
size="3"
as="h3"
css={{ fontWeight: 500, lineHeight: 1.5, letterSpacing: '-0.02em' }}
>
Primitives
</Text>
<Text size="2" as="p" variant="gray" css={{ lineHeight: 1.4 }}>
Acessible components for design systems and web apps.
</Text>
</Box>
</Flex>
</HighlightLink>
</NextLink>
)}
<HighlightLink href="https://stitches.dev">
<Flex gap="3">
<StitchesLogoIcon
width="25"
height="25"
style={{ flex: 'none', marginTop: 2 }}
/>
<Box>
<Text
size="3"
as="h3"
css={{ fontWeight: 500, lineHeight: 1.5, letterSpacing: '-0.02em' }}
>
Stitches
</Text>
<Text size="2" as="p" variant="gray" css={{ lineHeight: 1.4 }}>
CSS-in-JS with best-in-class developer experience.
</Text>
</Box>
</Flex>
</HighlightLink>
{isColors === false && (
<NextLink href="/colors" passHref>
<HighlightLink>
<Flex gap="3">
<svg
width="25"
height="25"
viewBox="0 0 30 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
style={{ flex: 'none', marginTop: 2 }}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M1.75391 14.9998C1.75391 7.68444 7.6842 1.75415 14.9996 1.75415C22.3149 1.75415 28.2452 7.68444 28.2452 14.9998C28.2452 22.3151 22.3149 28.2455 14.9996 28.2455C7.6842 28.2455 1.75391 22.3151 1.75391 14.9998ZM7.56191 6.4319C9.3655 4.86489 11.6687 3.85795 14.2008 3.68183V13.0708L7.56191 6.4319ZM6.43062 7.56335C4.8644 9.36653 3.85792 11.6689 3.68166 14.2H13.0673L6.43062 7.56335ZM13.0673 15.8H3.68169C3.85806 18.3311 4.8646 20.6334 6.43085 22.4365L13.0673 15.8ZM7.56217 23.5679C9.36572 25.1348 11.6688 26.1417 14.2008 26.3178V16.9293L7.56217 23.5679ZM15.8008 16.9335V26.3176C18.3313 26.1411 20.6332 25.1347 22.436 23.5687L15.8008 16.9335ZM23.5675 22.4375C25.1342 20.6342 26.1411 18.3315 26.3174 15.8H16.9301L23.5675 22.4375ZM16.9301 14.2H26.3175C26.1412 11.6685 25.1344 9.36574 23.5677 7.56242L16.9301 14.2ZM22.4363 6.43109C20.6334 4.86504 18.3314 3.85856 15.8008 3.682V13.0666L22.4363 6.43109Z"
fill="currentcolor"
/>
</svg>
<Box>
<Text
size="3"
as="h3"
css={{ fontWeight: 500, lineHeight: 1.5, letterSpacing: '-0.02em' }}
>
Colors
</Text>
<Text size="2" as="p" variant="gray" css={{ lineHeight: 1.4 }}>
Beautiful, thought-out palettes with auto dark mode.
</Text>
</Box>
</Flex>
</HighlightLink>
</NextLink>
)}
<HighlightLink href="https://icons.radix-ui.com">
<Flex gap="3">
<MixIcon width="25" height="25" style={{ flex: 'none', marginTop: 2 }} />
<Box>
<Text
size="3"
as="h3"
css={{ fontWeight: 500, lineHeight: 1.5, letterSpacing: '-0.02em' }}
>
Icons
</Text>
<Text size="2" as="p" variant="gray" css={{ lineHeight: 1.4 }}>
A crisp set of 15×15 icons, balanced and consistent.
</Text>
</Box>
</Flex>
</HighlightLink>
</Box>
</PopoverContent>
</Popover>
<ThemeToggle />
</Flex>
</Flex>
</Container>
</Box>
);
};
const HighlightLink = styled('a', {
display: 'block',
color: '$hiContrast',
textDecoration: 'none',
outline: 0,
p: '$2',
br: '$2',
'@hover': {
'&:hover': {
bc: '$slateA3',
},
},
'&:focus': {
boxShadow: '0 0 0 2px $colors$slateA8',
},
'&:focus:not(:focus-visible)': {
boxShadow: 'none',
},
});