Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(panelmenu): implement PanelMenu #75

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/primevue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -44,6 +45,7 @@ export const RisUiTheme = {
inputMask,
breadcrumb,
tree,
panelmenu,
};

export const RisUiLocale = {
Expand Down
55 changes: 55 additions & 0 deletions src/primevue/panelMenu/panelMenu.stories.ts
Original file line number Diff line number Diff line change
@@ -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<typeof PanelMenu> = {
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<typeof meta> = {
render: (args) => ({
components: { PanelMenu },
setup() {
const expandedKeys = ref({ R: true, "R-A": true });
return { args, items, expandedKeys };
},
template: html`<label class="ris-label2-regular mb-16 block"
>Dokumentarten</label
><PanelMenu
:model="items"
v-model:expandedKeys="expandedKeys"
class="md:w-200 w-full"
multiple
><template #submenuicon><i /></template
></PanelMenu>`,
}),
};
55 changes: 55 additions & 0 deletions src/primevue/panelMenu/panelMenu.ts
Original file line number Diff line number Diff line change
@@ -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;