Skip to content

Commit 6a895f5

Browse files
feat: added triggers to nav-menu
1 parent f63c7df commit 6a895f5

File tree

2 files changed

+59
-51
lines changed

2 files changed

+59
-51
lines changed

src/components/NavigationMenu/NavigationMenu.stories.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,48 +37,48 @@ const ViewportPosition = styled('div', {
3737
justifyContent: 'center',
3838
width: '100%',
3939
top: '100%',
40-
left: 0,
41-
perspective: '2000px'
40+
left: 0
41+
// perspective: '2000px',
4242
})
4343

4444
const Template: Story = args => (
4545
<NavigationMenu>
4646
<NavigationMenuList>
47-
{/* <NavigationMenuItem>
48-
<>
49-
<NavigationMenuTrigger caret={true}>Learn</NavigationMenuTrigger>
50-
<NavigationMenuContent>
51-
<Text>Github</Text>
52-
<NavigationMenuContentList layout="one">
53-
<NavigationMenuContentListItem
54-
href="https://stitches.dev/"
55-
title="Stitches"
56-
>
57-
<Text>CSS-in-JS with best-in-class developer experience.</Text>
58-
</NavigationMenuContentListItem>
59-
<NavigationMenuContentListItem href="/colors" title="Colors">
60-
<Text>
61-
Beautiful, thought-out palettes with auto dark mode.
62-
</Text>
63-
</NavigationMenuContentListItem>
64-
<NavigationMenuContentListItem
65-
href="https://icons.modulz.app/"
66-
title="Icons"
67-
>
68-
<Text>
69-
A crisp set of 15x15 icons, balanced and consistent.
70-
</Text>
71-
</NavigationMenuContentListItem>
72-
</NavigationMenuContentList>
73-
</NavigationMenuContent>
74-
</>
75-
</NavigationMenuItem> */}
47+
<NavigationMenuItem>
48+
<NavigationMenuTrigger caret={true}>
49+
<Text>Learn</Text>
50+
</NavigationMenuTrigger>
51+
<NavigationMenuContent>
52+
<NavigationMenuContentList layout="one">
53+
<NavigationMenuContentListItem
54+
href="https://stitches.dev/"
55+
title="Stitches"
56+
>
57+
<Text>CSS-in-JS with best-in-class developer experience.</Text>
58+
</NavigationMenuContentListItem>
59+
<NavigationMenuContentListItem href="/colors" title="Colors">
60+
<Text>Beautiful, thought-out palettes with auto dark mode.</Text>
61+
</NavigationMenuContentListItem>
62+
<NavigationMenuContentListItem
63+
href="https://icons.modulz.app/"
64+
title="Icons"
65+
>
66+
<Text>A crisp set of 15x15 icons, balanced and consistent.</Text>
67+
</NavigationMenuContentListItem>
68+
</NavigationMenuContentList>
69+
</NavigationMenuContent>
70+
</NavigationMenuItem>
7671

7772
<NavigationMenuItem>
7873
<NavigationMenuLink href="https://github.com/commitd/components">
7974
<Text>Github</Text>
8075
</NavigationMenuLink>
8176
</NavigationMenuItem>
77+
<NavigationMenuItem>
78+
<NavigationMenuLink href="https://components.committed.software">
79+
<Text>Storybook</Text>
80+
</NavigationMenuLink>
81+
</NavigationMenuItem>
8282

8383
<NavigationMenuIndicator />
8484
</NavigationMenuList>

src/components/NavigationMenu/NavigationMenu.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Item,
1111
List
1212
} from '@radix-ui/react-navigation-menu'
13-
import { mauve, violet } from '@radix-ui/colors'
13+
// import { mauve, violet } from '@radix-ui/colors'
1414
import { ChevronDown } from '../Icons'
1515
import { paperStyles } from '../Paper'
1616

@@ -118,9 +118,15 @@ const StyledCaret = styled(ChevronDown, {
118118
})
119119

120120
const NAV_MENU_TRIGGER_CLASS_NAME = 'c-popover-trigger'
121-
export type NavigationMenuTriggerProps = Omit<
122-
ComponentProps<typeof StyledTrigger>,
123-
'asChild'
121+
// export type NavigationMenuTriggerProps = Omit<
122+
// ComponentProps<typeof StyledTrigger>,
123+
// 'asChild'
124+
// > & {
125+
// caret?: boolean
126+
// }
127+
128+
export type NavigationMenuTriggerProps = ComponentProps<
129+
typeof StyledTrigger
124130
> & {
125131
caret?: boolean
126132
}
@@ -130,12 +136,13 @@ export const NavigationMenuTrigger = forwardRef<
130136
>(({ children, caret = false, ...props }, forwardedRef) => (
131137
<StyledTrigger
132138
className={NAV_MENU_TRIGGER_CLASS_NAME}
133-
asChild
134139
{...props}
135140
ref={forwardedRef}
136141
>
137-
{children}
138-
{caret && <StyledCaret aria-hidden />}
142+
<>
143+
{children}
144+
{caret && <StyledCaret aria-hidden />}
145+
</>
139146
</StyledTrigger>
140147
))
141148
NavigationMenuTrigger.toString = () => `.${NAV_MENU_TRIGGER_CLASS_NAME}`
@@ -196,8 +203,8 @@ const StyledArrow = styled('div', {
196203
position: 'relative',
197204
top: '70%',
198205
backgroundColor: '$paper',
199-
width: 10,
200-
height: 10,
206+
width: '$3',
207+
height: '$3',
201208
transform: 'rotate(45deg)',
202209
borderTopLeftRadius: 2
203210
})
@@ -234,9 +241,9 @@ const StyledViewport = styled(Viewport, {
234241

235242
const ContentList = styled('ul', {
236243
display: 'grid',
237-
padding: 22,
238-
margin: 0,
239-
columnGap: 10,
244+
padding: '$5',
245+
margin: '$0',
246+
columnGap: '$3',
240247
listStyle: 'none',
241248

242249
variants: {
@@ -262,17 +269,18 @@ const ListItem = styled('li', {})
262269

263270
// TODO: Replace/Match up with CC Links
264271
const LinkTitle = styled('div', {
265-
fontWeight: 500,
266-
lineHeight: 1.2,
267-
marginBottom: 5,
268-
color: violet.violet12
272+
fontWeight: '$bold',
273+
fontSize: '$0',
274+
lineHeight: '$body',
275+
marginBottom: '$2',
276+
color: '$text'
269277
})
270278

271279
const LinkText = styled('p', {
272280
all: 'unset',
273-
color: mauve.mauve11,
274-
lineHeight: 1.4,
275-
fontWeight: 'initial'
281+
color: '$textSecondary',
282+
lineHeight: '$body',
283+
fontWeight: '$regular'
276284
})
277285

278286
type ContentListItemProps = ComponentProps<typeof StyledLink> & {
@@ -291,7 +299,7 @@ const ContentListItem = forwardRef<
291299
css={{
292300
padding: 12,
293301
borderRadius: 6,
294-
'&:hover': { backgroundColor: mauve.mauve3 }
302+
'&:hover': { backgroundColor: '$colors$primary7' }
295303
}}
296304
>
297305
<>

0 commit comments

Comments
 (0)