Skip to content

Commit

Permalink
feat: add menuClasses prop to NeDropdown (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 authored Oct 4, 2024
1 parent 7b0fbf9 commit afba335
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/NeDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export interface Props {
items: NeDropdownItem[]
alignToRight: boolean
openMenuAriaLabel?: string
menuClasses?: string
}

const props = withDefaults(defineProps<Props>(), {
items: () => [],
alignToRight: false,
openMenuAriaLabel: 'Open menu'
openMenuAriaLabel: 'Open menu',
menuClasses: ''
})

export interface NeDropdownItem {
Expand Down Expand Up @@ -104,7 +106,7 @@ watch(
{ top: top + 'px' },
alignToRight ? { right: right + 'px' } : { left: left + 'px' }
]"
class="absolute z-50 mt-2.5 min-w-[10rem] rounded-md bg-white py-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none dark:bg-gray-950 dark:ring-gray-500/50"
:class="`absolute z-50 mt-2.5 min-w-[10rem] rounded-md bg-white py-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none dark:bg-gray-950 dark:ring-gray-500/50 ${menuClasses}`"
>
<template v-for="item in items" :key="item.id">
<!-- divider -->
Expand Down
16 changes: 15 additions & 1 deletion stories/NeDropdown.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const meta = {
}
],
alignToRight: false,
openMenuAriaLabel: 'Open menu'
openMenuAriaLabel: 'Open menu',
menuClasses: ''
}
} satisfies Meta<typeof NeDropdown>

Expand Down Expand Up @@ -114,3 +115,16 @@ export const WithSlot: Story = {
}),
args: {}
}

export const MenuClasses: Story = {
render: (args) => ({
components: { NeDropdown },
setup() {
return { args }
},
template: template
}),
args: {
menuClasses: '!bg-fuchsia-200 dark:!bg-fuchsia-900'
}
}

0 comments on commit afba335

Please sign in to comment.