Skip to content

Commit 89e9d68

Browse files
committed
chore: prep for nested nav menu
1 parent ff15701 commit 89e9d68

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/next-ts/pages/navigation-menu-nested.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export default function Page() {
1111
const rootService = useMachine(navigationMenu.machine, { id: useId() })
1212
const rootMenu = navigationMenu.connect(rootService, normalizeProps)
1313

14-
const productService = useMachine(navigationMenu.machine, { id: useId(), value: "extensibility" })
14+
const productService = useMachine(navigationMenu.machine, { id: useId(), defaultValue: "extensibility" })
1515
const productSubmenu = navigationMenu.connect(productService, normalizeProps)
1616

17-
const companyService = useMachine(navigationMenu.machine, { id: useId(), value: "customers" })
17+
const companyService = useMachine(navigationMenu.machine, { id: useId(), defaultValue: "customers" })
1818
const companySubmenu = navigationMenu.connect(companyService, normalizeProps)
1919

2020
const renderLinks = (menu: typeof rootMenu, opts: { value: string; items: string[] }) => {

packages/machines/navigation-menu/src/navigation-menu.machine.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ export const machine = createMachine({
6060
triggerNode: bindable<HTMLElement | null>(() => ({
6161
defaultValue: null,
6262
})),
63-
64-
// nesting
6563
}
6664
},
6765

@@ -93,9 +91,8 @@ export const machine = createMachine({
9391

9492
exit: ["cleanupObservers", "cleanupAutoResetRef"],
9593

96-
initialState({ prop }) {
97-
const value = prop("value") || prop("defaultValue")
98-
return value ? "open" : "closed"
94+
initialState() {
95+
return "closed"
9996
},
10097

10198
on: {

shared/src/css/navigation-menu-nested.css

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,23 @@
3333
}
3434

3535
[data-scope="navigation-menu"][data-part="trigger"] {
36+
display: flex;
37+
align-items: center;
38+
justify-content: center;
3639
border: 0;
3740
background: transparent;
3841
font-size: inherit;
3942
gap: 4px;
4043
padding: 10px 16px;
4144
font-weight: bold;
4245

43-
& > svg {
46+
& svg {
4447
transition: rotate 200ms ease;
4548
width: 14px;
4649
height: 14px;
4750
}
4851

49-
&[data-state="open"] > svg {
52+
&[data-state="open"] svg {
5053
rotate: -180deg;
5154
}
5255

0 commit comments

Comments
 (0)