diff --git a/docs/content/docs/2.components/navigation-menu.md b/docs/content/docs/2.components/navigation-menu.md index f01d77d1ec..76df9e6080 100644 --- a/docs/content/docs/2.components/navigation-menu.md +++ b/docs/content/docs/2.components/navigation-menu.md @@ -373,15 +373,16 @@ props: - label: Installation description: Learn how to install and configure Nuxt UI in your application. icon: i-lucide-cloud-download - - label: 'Icons' - icon: 'i-lucide-smile' - description: 'You have nothing to do, @nuxt/icon will handle it automatically.' - - label: 'Colors' - icon: 'i-lucide-swatch-book' - description: 'Choose a primary and a neutral color from your Tailwind CSS theme.' - label: 'Theme' icon: 'i-lucide-cog' description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.' + children: + - label: 'Icons' + icon: 'i-lucide-smile' + description: 'You have nothing to do, @nuxt/icon will handle it automatically.' + - label: 'Colors' + icon: 'i-lucide-swatch-book' + description: 'Choose a primary and a neutral color from your Tailwind CSS theme.' - label: Composables icon: i-lucide-database children: diff --git a/playgrounds/nuxt/app/pages/components/navigation-menu.vue b/playgrounds/nuxt/app/pages/components/navigation-menu.vue index 463f66c86d..b50e0d47ed 100644 --- a/playgrounds/nuxt/app/pages/components/navigation-menu.vue +++ b/playgrounds/nuxt/app/pages/components/navigation-menu.vue @@ -14,9 +14,9 @@ const attrs = reactive({ const highlight = ref(true) const highlightColor = ref() -const orientation = ref('horizontal' as keyof typeof theme.variants.orientation) +const orientation = ref('vertical' as keyof typeof theme.variants.orientation) const contentOrientation = ref('horizontal' as keyof typeof theme.variants.contentOrientation) -const collapsed = ref(false) +const collapsed = ref(true) const arrow = ref(false) const items = [ @@ -50,12 +50,57 @@ const items = [ to: '/components/navigation-menu', type: 'trigger', active: true, + popover: { + mode: 'click' + }, defaultOpen: true, children: [{ label: 'Link', icon: 'i-lucide-link', description: 'Use NuxtLink with superpowers.', - to: '/components/link' + to: '/components/link', + children: [{ + label: 'Button', + icon: 'i-lucide-square', + description: 'Display a modal dialog overlay for important content.', + to: '/components/modal' + }, { + label: 'Pagination', + icon: 'i-lucide-parking-meter', + description: 'Display a list of pages.', + to: '/components/pagination' + }, { + label: 'Popover', + icon: 'i-lucide-message-circle', + description: 'Display a non-modal dialog that floats around a trigger element.', + to: '/components/popover', + children: [{ + label: 'Button', + icon: 'i-lucide-square', + description: 'Display a modal dialog overlay for important content.', + to: '/components/modal' + }, { + label: 'Pagination', + icon: 'i-lucide-parking-meter', + description: 'Display a list of pages.', + to: '/components/pagination' + }, { + label: 'Popover', + icon: 'i-lucide-message-circle', + description: 'Display a non-modal dialog that floats around a trigger element.', + to: '/components/popover' + }, { + label: 'Progress', + icon: 'i-lucide-loader', + description: 'Show a horizontal bar to indicate task progression.', + to: '/components/progress' + }] + }, { + label: 'Progress', + icon: 'i-lucide-loader', + description: 'Show a horizontal bar to indicate task progression.', + to: '/components/progress' + }] }, { label: 'Modal', icon: 'i-lucide-square', diff --git a/src/runtime/components/NavigationMenu.vue b/src/runtime/components/NavigationMenu.vue index f74aa55cd1..fdf3a81f23 100644 --- a/src/runtime/components/NavigationMenu.vue +++ b/src/runtime/components/NavigationMenu.vue @@ -260,12 +260,13 @@ const contentProps = toRef(() => props.content) const tooltipProps = toRef(() => defu(typeof props.tooltip === 'boolean' ? {} : props.tooltip, { delayDuration: 0, content: { side: 'right' } }) as TooltipProps) const popoverProps = toRef(() => defu(typeof props.popover === 'boolean' ? {} : props.popover, { mode: 'hover', content: { side: 'right', align: 'start', alignOffset: 2 } }) as PopoverProps) -const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, active?: boolean }>() -const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, level?: number }>({ +const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, active?: boolean, withLabel?: boolean }>() +const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: NavigationMenuItem, index: number, level?: number, withLabel?: boolean }>({ props: { item: Object, index: Number, - level: Number + level: Number, + withLabel: Boolean } }) @@ -300,7 +301,7 @@ function getAccordionDefaultValue(list: NavigationMenuItem[], level = 0) {