diff --git a/src/primevue/index.ts b/src/primevue/index.ts index c86b983..bc36467 100644 --- a/src/primevue/index.ts +++ b/src/primevue/index.ts @@ -19,6 +19,7 @@ import toast from "./toast/toast"; import select from "./select/select"; import inputMask from "./inputMask/inputMask"; import breadcrumb from "@/primevue/breadcrumb/breadcrumb"; +import panelmenu from "./panelMenu/panelMenu"; import tree from "./tree/tree"; import { deDE } from "@/config/locale"; @@ -44,6 +45,7 @@ export const RisUiTheme = { inputMask, breadcrumb, tree, + panelmenu, }; export const RisUiLocale = { diff --git a/src/primevue/panelMenu/panelMenu.stories.ts b/src/primevue/panelMenu/panelMenu.stories.ts new file mode 100644 index 0000000..2869bd6 --- /dev/null +++ b/src/primevue/panelMenu/panelMenu.stories.ts @@ -0,0 +1,55 @@ +import { html } from "@/lib/tags"; +import { Meta, StoryObj } from "@storybook/vue3"; +import PanelMenu from "primevue/panelmenu"; +import { MenuItem } from "primevue/menuitem"; +import { ref } from "vue"; + +const meta: Meta = { + component: PanelMenu, + tags: ["autodocs"], + args: {}, + + argTypes: {}, +}; + +const items: MenuItem[] = [ + { + label: "Alle Dokumentarten", + key: "all", + }, + { + label: "Gesetze & Verordnungen", + key: "N", + }, + { + label: "Gerichtsentscheidungen", + key: "R", + items: [ + { label: "Alle Gerichtsentscheidungen", key: "R-A" }, + { label: "Urteil", key: "R-U" }, + { label: "Beschluss", key: "R-B" }, + { label: "Sonstige Entscheidungen", key: "R-S" }, + ], + }, +]; + +export default meta; + +export const Default: StoryObj = { + render: (args) => ({ + components: { PanelMenu }, + setup() { + const expandedKeys = ref({ R: true, "R-A": true }); + return { args, items, expandedKeys }; + }, + template: html``, + }), +}; diff --git a/src/primevue/panelMenu/panelMenu.ts b/src/primevue/panelMenu/panelMenu.ts new file mode 100644 index 0000000..d4868ca --- /dev/null +++ b/src/primevue/panelMenu/panelMenu.ts @@ -0,0 +1,55 @@ +import { tw } from "@/lib/tags"; +import { PanelMenuPassThroughOptions } from "primevue/panelmenu"; + +const pointer = tw`cursor-pointer`; +const selected = tw`ris-label2-bold border-l-blue-800 bg-blue-200 text-black`; +const hover = tw`hover:bg-blue-200`; +const hoverSelected = tw`hover:bg-blue-300`; + +const focusVisible = tw`focus-visible:outline-none focus-visible:outline-4 focus-visible:outline-offset-4 focus-visible:outline-blue-800`; +const panelMenu: PanelMenuPassThroughOptions = { + root: { + class: tw`text-blue-800`, + }, + + header: ({ context }) => { + const base = tw`group flex h-64 items-center border-l-4 border-transparent py-8 pl-10 pr-20`; + return { + class: { + [base]: true, + [focusVisible]: true, + [pointer]: true, + [selected]: context.active, + [hover]: !context.active, + [hoverSelected]: context.active, + }, + }; + }, + content: { + class: tw`ml-28 mt-8`, + }, + rootList: { + class: tw`focus-visible:outline-none`, + }, + panel: { + class: tw`focus-visible:outline-none`, + }, + itemContent: ({ context }) => { + const base = tw`group flex h-48 items-center border-l-4 border-transparent py-8 pl-10 pr-20`; + const focusVisible = tw`focus-visible:outline-none focus-visible:outline-4 focus-visible:outline-offset-4 focus-visible:outline-blue-800`; + const likeHover = tw`bg-blue-200`; + return { + class: { + [base]: true, + [likeHover]: context.focused, // workaround for https://github.com/primefaces/primevue/issues/6836 + [focusVisible]: true, + [pointer]: true, + [selected]: context.active, + [hover]: !context.active, + [hoverSelected]: context.active, + }, + }; + }, +}; + +export default panelMenu;