Skip to content

Commit

Permalink
Merge pull request #155 from PrestaShopCorp/feat/menu-slot-props
Browse files Browse the repository at this point in the history
[Feature]: add menu open state to slot props
  • Loading branch information
Kelhel authored Jul 7, 2023
2 parents 7c81dc8 + 942afa7 commit 95054c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/components/menu/src/menu.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<Popover
v-slot="{ open }"
class="puik-menu"
:class="[`puik-menu--position-${position}`, `puik-menu--align-${align}`]"
as="div"
>
<PopoverButton class="puik-menu__trigger" as="template">
<slot name="trigger"></slot>
<slot name="trigger" :open="open"></slot>
</PopoverButton>

<transition
Expand All @@ -21,7 +22,7 @@
class="puik-menu__content"
:style="{ maxHeight, width }"
>
<slot :close="close"></slot>
<slot :close="close" :open="open"></slot>
</PopoverPanel>
</transition>
</Popover>
Expand Down
21 changes: 21 additions & 0 deletions packages/components/menu/stories/menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,31 @@ export default {
trigger: {
control: 'none',
description: 'Trigger used to show or hide menu',
table: {
type: {
summary: 'SlotProps',
detail: `
{
open: boolean
}
`,
},
},
},
default: {
control: 'none',
description: 'Menu content',
table: {
type: {
summary: 'SlotProps',
detail: `
{
open: boolean,
close: () => void
}
`,
},
},
},
},
args: {
Expand Down

0 comments on commit 95054c2

Please sign in to comment.