feat: Add new breadcrumb component (#10268)
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import Breadcrumb from './Breadcrumb.vue';
|
||||||
|
|
||||||
|
const singleItem = ref([{ label: 'Home', link: '#' }]);
|
||||||
|
const twoItems = ref([
|
||||||
|
{ label: 'Home', link: '#' },
|
||||||
|
{ label: 'Categories', link: '#' },
|
||||||
|
]);
|
||||||
|
const threeItems = ref([
|
||||||
|
{ label: 'Home', link: '#' },
|
||||||
|
{ label: 'Categories', link: '#' },
|
||||||
|
{ label: 'Marketing', count: 6 },
|
||||||
|
]);
|
||||||
|
const longBreadcrumb = ref([
|
||||||
|
{ label: 'Home', link: '#' },
|
||||||
|
{ label: 'Categories', link: '#' },
|
||||||
|
{ label: 'Marketing', link: '#' },
|
||||||
|
{ label: 'Digital', link: '#' },
|
||||||
|
{ label: 'Social Media', count: 12 },
|
||||||
|
]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- eslint-disable vue/no-bare-strings-in-template -->
|
||||||
|
<!-- eslint-disable vue/no-undef-components -->
|
||||||
|
<template>
|
||||||
|
<Story
|
||||||
|
title="Components/Breadcrumb"
|
||||||
|
:layout="{ type: 'grid', width: '800px' }"
|
||||||
|
>
|
||||||
|
<Variant title="Single Item">
|
||||||
|
<div class="w-full p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Breadcrumb :items="singleItem" />
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
|
||||||
|
<Variant title="Two Items">
|
||||||
|
<div class="w-full p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Breadcrumb :items="twoItems" />
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
|
||||||
|
<Variant title="Three Items with Count">
|
||||||
|
<div class="w-full p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Breadcrumb :items="threeItems" count-label="articles" />
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
|
||||||
|
<Variant title="Long Breadcrumb">
|
||||||
|
<div class="w-full p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Breadcrumb :items="longBreadcrumb" count-label="articles" />
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
|
||||||
|
<Variant title="RTL Support">
|
||||||
|
<div dir="rtl">
|
||||||
|
<div class="w-full p-4 bg-white dark:bg-slate-900">
|
||||||
|
<Breadcrumb :items="threeItems" count-label="articles" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Variant>
|
||||||
|
</Story>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<script setup>
|
||||||
|
import { defineProps } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import FluentIcon from 'shared/components/FluentIcon/DashboardIcon.vue';
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
items: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
validator: value => {
|
||||||
|
return value.every(
|
||||||
|
item =>
|
||||||
|
typeof item.label === 'string' &&
|
||||||
|
(item.link === undefined || typeof item.link === 'string') &&
|
||||||
|
(item.count === undefined || typeof item.count === 'number')
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
countLabel: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<nav :aria-label="t('BREADCRUMB.ARIA_LABEL')" class="flex items-center h-8">
|
||||||
|
<ol class="flex items-center mb-0">
|
||||||
|
<li
|
||||||
|
v-for="(item, index) in items"
|
||||||
|
:key="index"
|
||||||
|
class="flex items-center gap-3"
|
||||||
|
>
|
||||||
|
<template v-if="index === items.length - 1">
|
||||||
|
<span class="text-sm text-slate-900 dark:text-slate-50">
|
||||||
|
{{
|
||||||
|
`${item.label}${item.count ? ` (${item.count} ${countLabel})` : ''}`
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<a
|
||||||
|
v-else
|
||||||
|
:href="item.link"
|
||||||
|
class="text-sm transition-colors duration-200 text-slate-300 dark:text-slate-500 hover:text-slate-700 dark:hover:text-slate-100"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</a>
|
||||||
|
<FluentIcon
|
||||||
|
v-if="index < items.length - 1"
|
||||||
|
icon="chevron-lucide-right"
|
||||||
|
size="18"
|
||||||
|
icon-lib="lucide"
|
||||||
|
class="flex-shrink-0 text-slate-300 dark:text-slate-500 ltr:mr-3 rtl:mr-0 rtl:ml-3"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
@@ -2,5 +2,8 @@
|
|||||||
"PAGINATION_FOOTER": {
|
"PAGINATION_FOOTER": {
|
||||||
"SHOWING": "Showing {startItem} - {endItem} of {totalItems} items",
|
"SHOWING": "Showing {startItem} - {endItem} of {totalItems} items",
|
||||||
"CURRENT_PAGE_INFO": "{currentPage} of {totalPages} pages"
|
"CURRENT_PAGE_INFO": "{currentPage} of {totalPages} pages"
|
||||||
|
},
|
||||||
|
"BREADCRUMB": {
|
||||||
|
"ARIA_LABEL": "Breadcrumb"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user