@@ -65,27 +65,18 @@ const StyledList = styled(List, {
65
65
all : 'unset' ,
66
66
display : 'flex' ,
67
67
justifyContent : 'center' ,
68
- // backgroundColor: 'white',
69
68
padding : 4 ,
70
- // borderRadius: 6,
71
69
listStyle : 'none' ,
72
- // boxShadow: `0 2px 10px $colors$brandGrey12`
73
-
74
- $$main : '$colors$primary' ,
75
- $$mainHover : '$colors$primaryHighlight' ,
76
- $$contrast : '$colors$primaryContrast' ,
77
- $$default : '$colors$default' ,
78
- $$defaultHover : '$colors$defaultHighlight' ,
79
70
80
71
fontSize : '$0' ,
81
- borderRadius : '$default ' ,
72
+ borderRadius : '$3 ' ,
82
73
backgroundColor : '$paper' ,
83
74
border : 'none' ,
84
75
width : 'fit-content; width: -moz-fit-content'
85
76
} )
86
77
87
78
const itemStyles = {
88
- padding : '8px 12px ' ,
79
+ padding : '$2 $3 ' ,
89
80
outline : 'none' ,
90
81
userSelect : 'none' ,
91
82
borderRadius : 4 ,
@@ -146,7 +137,7 @@ const StyledLink = styled(Link, {
146
137
} )
147
138
148
139
const StyledContent = styled ( Content , paperStyles , {
149
- borderRadius : '$default ' ,
140
+ borderRadius : '$3 ' ,
150
141
padding : '$4' ,
151
142
152
143
display : 'flex' ,
@@ -162,7 +153,7 @@ const StyledContent = styled(Content, paperStyles, {
162
153
top : 0 ,
163
154
left : 0 ,
164
155
width : '100%' ,
165
- '@media only screen and (min-width: 600px) ' : { width : 'auto' } ,
156
+ '@default ' : { width : 'auto' } ,
166
157
'@media (prefers-reduced-motion: no-preference)' : {
167
158
animationDuration : '250ms' ,
168
159
animationTimingFunction : 'ease' ,
@@ -213,15 +204,11 @@ const StyledViewport = styled(Viewport, {
213
204
marginTop : '$2' ,
214
205
width : '100%' ,
215
206
backgroundColor : '$paper' ,
216
- borderRadius : '$3' ,
207
+ borderRadius : 6 ,
217
208
overflow : 'hidden' ,
218
- boxShadow :
219
- 'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px' ,
209
+ boxShadow : '$2' ,
220
210
height : 'var(--radix-navigation-menu-viewport-height)' ,
221
211
222
- '@media only screen and (min-width: 600px)' : {
223
- width : 'var(--radix-navigation-menu-viewport-width)'
224
- } ,
225
212
'@media (prefers-reduced-motion: no-preference)' : {
226
213
transition : 'width, height, 300ms ease' ,
227
214
'&[data-state="open"]' : { animation : `${ scaleIn } 200ms ease` } ,
@@ -231,23 +218,21 @@ const StyledViewport = styled(Viewport, {
231
218
232
219
const ContentList = styled ( 'ul' , {
233
220
display : 'grid' ,
234
- padding : '$2' ,
235
221
margin : '$0' ,
236
- columnGap : '$3 ' ,
222
+ columnGap : '$2 ' ,
237
223
rowGap : '$2' ,
238
224
listStyle : 'none' ,
239
225
240
226
variants : {
241
227
layout : {
242
- one : {
243
- '@media only screen and (min-width: 600px) ' : {
244
- width : '100% ' ,
245
- gridTemplateColumns : '.75fr 1fr'
228
+ row : {
229
+ '@default ' : {
230
+ gridAutoFlow : 'row ' ,
231
+ gridTemplateRows : 'repeat(3, 1fr) '
246
232
}
247
233
} ,
248
234
column : {
249
- '@media only screen and (min-width: 600px)' : {
250
- width : '100%' ,
235
+ '@default' : {
251
236
gridAutoFlow : 'column' ,
252
237
gridTemplateRows : 'repeat(3, 1fr)'
253
238
}
@@ -273,12 +258,20 @@ const LinkText = styled('p', {
273
258
fontWeight : '$regular'
274
259
} )
275
260
261
+ const ViewportPosition = styled ( 'div' , {
262
+ position : 'absolute' ,
263
+ display : 'flex' ,
264
+ justifyContent : 'center' ,
265
+ width : '100%' ,
266
+ top : '100%' ,
267
+ left : 0
268
+ } )
269
+
276
270
type ContentListItemProps = ComponentProps < typeof StyledLink > & {
277
271
title : string
278
272
}
279
273
280
274
const ContentListItem = forwardRef <
281
- // ElementRef<typeof ListItem>,
282
275
ElementRef < typeof StyledLink > ,
283
276
ContentListItemProps
284
277
> ( ( { children, title, ...props } , forwardedRef ) => (
@@ -287,8 +280,7 @@ const ContentListItem = forwardRef<
287
280
{ ...props }
288
281
ref = { forwardedRef }
289
282
css = { {
290
- padding : '$3' ,
291
- borderRadius : '$3' ,
283
+ borderRadius : 3 ,
292
284
'&:hover' : { backgroundColor : '$colors$primary7' }
293
285
} }
294
286
>
@@ -302,12 +294,22 @@ const ContentListItem = forwardRef<
302
294
303
295
const StyledItem = styled ( Item , { } )
304
296
305
- // Exports
297
+ /**
298
+ * NavigationMenu component
299
+ *
300
+ * Displays a collection of links for navigation websites or apps.
301
+ *
302
+ * Navigation Menu Items can either be in the form of simply links (by using a NavigationMenuLink) or
303
+ * take the form of a extended menu, similar to a Popover, controlled by a NavigationMenuTrigger.
304
+ *
305
+ * Based on [Radix Dropdown Menu](https://radix-ui.com/primitives/docs/components/navigation-menu).
306
+ */
306
307
export const NavigationMenu = StyledMenu
307
308
export const NavigationMenuList = StyledList
308
309
export const NavigationMenuItem = StyledItem
309
310
export const NavigationMenuLink = StyledLink
310
311
export const NavigationMenuContent = StyledContent
312
+ export const NavigationViewportPosition = ViewportPosition
311
313
export const NavigationMenuViewport = StyledViewport
312
314
export const NavigationMenuIndicator = StyledIndicatorWithArrow
313
315
export const NavigationMenuContentList = ContentList
0 commit comments