-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(menu): implement PrimeVue menu styles
- Loading branch information
1 parent
0979da2
commit 9966fe4
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { html } from "@/lib/tags"; | ||
import { Meta, StoryObj } from "@storybook/vue3"; | ||
import PrimevueMenu from "primevue/menu"; | ||
import PrimevueButton from "primevue/button"; | ||
import { MenuItem } from "primevue/menuitem"; | ||
import MdiDotsVertical from "~icons/mdi/dots-vertical"; | ||
import EyeOutline from "~icons/mdi/eye-outline"; | ||
import MdiTrayDownload from "~icons/mdi/tray-download"; | ||
import { useTemplateRef } from "vue"; | ||
|
||
const meta: Meta<typeof PrimevueMenu> = { | ||
component: PrimevueMenu, | ||
tags: ["autodocs"], | ||
args: { | ||
model: [ | ||
{ | ||
label: "XML im Browser anzeigen", | ||
icon: "view", | ||
}, | ||
{ | ||
label: "XML herunterladen", | ||
icon: "download", | ||
}, | ||
{ label: "Andere Aktion" }, | ||
] as MenuItem[], | ||
}, | ||
|
||
argTypes: {}, | ||
}; | ||
|
||
const getIcon = (name: string) => { | ||
switch (name) { | ||
case "view": | ||
return EyeOutline; | ||
case "download": | ||
return MdiTrayDownload; | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<typeof meta> = { | ||
render: (args) => ({ | ||
components: { PrimevueMenu }, | ||
setup() { | ||
return { args, getIcon }; | ||
}, | ||
template: html`<PrimevueMenu v-bind="args"> | ||
<template #itemicon="{item}" | ||
><component :is="getIcon(item.icon)" v-if="item.icon" | ||
/></template> | ||
</PrimevueMenu>`, | ||
}), | ||
}; | ||
|
||
export const Popup: StoryObj<typeof meta> = { | ||
render: (args) => ({ | ||
components: { PrimevueMenu, PrimevueButton, MdiDotsVertical }, | ||
setup() { | ||
const menuRef = useTemplateRef<typeof PrimevueMenu>("menu"); | ||
|
||
const toggle = (event: Event) => { | ||
menuRef.value?.toggle(event); | ||
}; | ||
return { args, toggle, getIcon }; | ||
}, | ||
template: html`<div> | ||
<PrimevueButton label="Aktionen" text @click="toggle"> | ||
<template #icon> <MdiDotsVertical /> </template></PrimevueButton | ||
><PrimevueMenu :popup="true" v-bind="args" ref="menu" | ||
><template #itemicon="{item}" | ||
><component :is="getIcon(item.icon)" v-if="item.icon" /></template | ||
></PrimevueMenu> | ||
</div> `, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { tw } from "@/lib/tags"; | ||
import { MenuPassThroughOptions } from "primevue/menu"; | ||
|
||
const menu: MenuPassThroughOptions = { | ||
root: { | ||
class: tw`ris-body2-regular bg-white shadow`, | ||
}, | ||
list: { | ||
class: tw``, | ||
}, | ||
item: { | ||
class: tw`relative h-48 pl-16 pr-12 after:absolute after:-bottom-1 after:left-16 after:right-16 after:border-b after:border-gray-300 after:content-[''] last:after:border-b-0 hover:bg-gray-100`, | ||
}, | ||
itemContent: { | ||
class: tw`flex h-full items-center py-4`, | ||
}, | ||
itemLink: { | ||
class: tw`flex items-center gap-8`, | ||
}, | ||
}; | ||
|
||
export default menu; |