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(breadcrumb): add breadcrumb component #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"prettier": "~3.3.3",
"prettier-plugin-tailwindcss": "~0.6.6",
"storybook": "~8.2.9",
"storybook-vue3-router": "^5.0.0",
"tailwindcss": "~3.4.10",
"typescript": "~5.5.4",
"typescript-eslint": "~8.2.0",
Expand Down
64 changes: 64 additions & 0 deletions src/primevue/breadcrumb/breadcrumb.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Meta, StoryObj } from "@storybook/vue3";
import Breadcrumb from "primevue/breadcrumb";
import { html } from "@/lib/tags.ts";
import { ref } from "vue";
import { vueRouter } from "storybook-vue3-router";
import HomeOutlineIcon from "~icons/material-symbols/home-outline";
import ChevronRightIcon from "~icons/material-symbols/chevron-right";

const meta: Meta<typeof Breadcrumb> = {
component: Breadcrumb,
tags: ["autodocs"],
args: {},
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
render: (args) => ({
components: { Breadcrumb, HomeOutlineIcon, ChevronRightIcon },
setup() {
const items = ref([
{ label: "", type: "home", route: "/" },
{ label: "Gesetze & Verordnungen", route: "/laws" },
{ label: "BGB Bürgerliches Gesetzbuch", route: "/bgb" },
{ label: "Buch 2", route: "/book-2" },
{ label: "Abschnitt 3" },
{ label: "Untertitel 2" },
{ label: "Kapitel 2" },
{ label: "§ 312e Verletzung von Informationspflichten über Kosten" },
]);

return { args, items };
},
template: html`
<div class="card flex justify-center">
<Breadcrumb :model="items">
<template #item="{ item, props }">
<router-link
v-if="item.route"
v-slot="{ href, navigate }"
:to="item.route"
custom
>
<a :href="href" v-bind="props.action" @click="navigate">
<span v-if="item.type === 'home'">
<HomeOutlineIcon />
</span>
<span v-else> {{ item.label }} </span>
</a>
</router-link>
<span v-else>{{ item.label }}</span>
</template>
<template #separator>
<ChevronRightIcon />
</template>
</Breadcrumb>
</div>
`,
}),
decorators: [
vueRouter(), // This adds basic router functionality for the story
],
};
40 changes: 40 additions & 0 deletions src/primevue/breadcrumb/breadcrumb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { BreadcrumbPassThroughOptions } from "primevue/breadcrumb";
import { tw } from "@/lib/tags.ts";

const breadcrumb: BreadcrumbPassThroughOptions = {
list: () => {
const base = tw`m-0 flex list-none flex-wrap items-center p-0 leading-none`;
return {
class: {
[base]: true,
},
};
},
item: () => {
const base = tw`flex-no-wrap my-2 flex items-center`;
hamo225 marked this conversation as resolved.
Show resolved Hide resolved
return {
class: {
[base]: true,
},
};
},
itemLink: () => {
const states = tw`outline-4 outline-offset-4 outline-blue-800 focus:outline`;
return {
class: {
"underline ris-link1-bold cursor-pointer inline-flex items-center":
true,
[states]: true,
},
};
},
separator: () => {
return {
class: {
"flex items-center text-gray-600 mx-2": true,
},
};
},
};

export default breadcrumb;
2 changes: 2 additions & 0 deletions src/primevue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import textarea from "./textarea/textarea";
import toast from "./toast/toast";
import select from "./select/select";
import inputMask from "./inputMask/inputMask";
import breadcrumb from "@/primevue/breadcrumb/breadcrumb";

import { deDE } from "@/config/locale";

Expand All @@ -38,6 +39,7 @@ export const RisUiTheme = {
autocomplete,
select,
inputMask,
breadcrumb,
};

export const RisUiLocale = {
Expand Down
Loading