From 4e967845e033a33767afc5da8f33858ab92ac0ba Mon Sep 17 00:00:00 2001 From: BIYA Paul Date: Wed, 5 Jul 2023 20:00:23 +0100 Subject: [PATCH] feat: handle breadcrumb --- README.md | 24 ++++++++ src/plugins/components/breadcrumb.ts | 87 ++++++++++++++++++++++++++++ src/plugins/components/index.ts | 2 + 3 files changed, 113 insertions(+) create mode 100644 src/plugins/components/breadcrumb.ts diff --git a/README.md b/README.md index 6f9337f..d2ce33a 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,30 @@ export default withShurikenUI({ theme: { extend: { shurikenUi: { + breadcrumb: { + list: { + font: 'sans', + text: '[0.85rem]', + itemInner: { + text: 'muted-500', + duration: '300', + icon: { + size: '4', + dot: { + text: 'xl', + }, + }, + link: { + textHover: 'primary-500', + texFocus: 'primary-500', + }, + itemText: { + text: 'muted-500', + space: '2', + }, + }, + } + }, dropdownDivider: { space: '2', border: 'muted-200', // you can use arbitrary value like '[#fff]' diff --git a/src/plugins/components/breadcrumb.ts b/src/plugins/components/breadcrumb.ts new file mode 100644 index 0000000..428f74b --- /dev/null +++ b/src/plugins/components/breadcrumb.ts @@ -0,0 +1,87 @@ +import plugin from 'tailwindcss/plugin' +import { defu } from 'defu' +import { type PluginOption, defaultPluginOptions } from '../options' + +const defaultBreadcrumbConfig = { + list: { + font: 'sans', + text: '[0.85rem]', + itemInner: { + text: 'muted-500', + duration: '300', + icon: { + size: '4', + dot: { + text: 'xl', + }, + }, + link: { + textHover: 'primary-500', + texFocus: 'primary-500', + }, + itemText: { + text: 'muted-500', + space: '2', + }, + }, + }, +} + +export default plugin.withOptions( + function (options: PluginOption) { + const { prefix } = defu(options, defaultPluginOptions) + + return function ({ addComponents, theme }) { + const config = theme( + 'shurikenUi.breadcrumb' + ) satisfies typeof defaultBreadcrumbConfig + + addComponents({ + [`.${prefix}-breadcrumb`]: { + [`.${prefix}-breadcrumb-list`]: { + [`@apply mb-6 flex items-center font-${config.list.font} text-${config.list.text}`]: + {}, + [`.${prefix}-breadcrumb-item-mobile`]: { + [`@apply me-3 sm:hidden`]: {}, + }, + [`.${prefix}-breadcrumb-item:not(:last-child)`]: { + [`@apply flex`]: {}, + }, + [`.${prefix}-breadcrumb-item:last-child`]: { + [`@apply hidden sm:flex`]: {}, + }, + [`.${prefix}-item-inner`]: { + [`@apply text-${config.list.itemInner.text} flex items-center gap-x-1 transition-colors duration-${config.list.itemInner.duration}`]: + {}, + + [`.${prefix}-item-icon`]: { + [`@apply flex items-center justify-center h-${config.list.itemInner.icon.size} w-${config.list.itemInner.icon.size} shrink-0`]: + {}, + [`&.${prefix}-has-dot`]: { + [`@apply text-${config.list.itemInner.icon.dot.text}`]: {}, + }, + }, + [`&.${prefix}-has-link`]: { + [`@apply hover:text-${config.list.itemInner.link.textHover} focus:text-${config.list.itemInner.link.texFocus}`]: + {}, + }, + [`.${prefix}-item-text`]: { + [`@apply text-${config.list.itemInner.itemText.text} px-${config.list.itemInner.itemText.space}`]: + {}, + }, + }, + }, + }, + }) + } + }, + function () { + return { + theme: { + shurikenUi: { + breadcrumb: defaultBreadcrumbConfig, + }, + }, + } + } +) diff --git a/src/plugins/components/index.ts b/src/plugins/components/index.ts index 6ef2b32..dc63ba8 100644 --- a/src/plugins/components/index.ts +++ b/src/plugins/components/index.ts @@ -9,8 +9,10 @@ import mask from './mask' import placeload from './placeload' import slimscroll from './slimscroll' import tooltip from './tooltip' +import breadcrumb from './breadcrumb' const components = [ + breadcrumb, dropdown, focus, label,