Skip to content

Commit

Permalink
feat: create breadcrumb plugin component (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Sacha Stafyniak <sacha@digisquad.io>
  • Loading branch information
bpsmartdesign and stafyniaksacha authored Jul 23, 2023
1 parent 299e3b3 commit 460ca11
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ 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',
},
},
}
avatarGroup: {
avatarOuter: {
bgDark: 'muted-800',
Expand Down
87 changes: 87 additions & 0 deletions src/plugins/components/breadcrumb.ts
Original file line number Diff line number Diff line change
@@ -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,
},
},
}
}
)
2 changes: 2 additions & 0 deletions src/plugins/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import switchThin from './switch-thin'
import switchBall from './switch-ball'
import textarea from './textarea'
import tooltip from './tooltip'
import breadcrumb from './breadcrumb'

const components = [
breadcrumb,
avatarGroup,
autocomplete,
avatar,
Expand Down

0 comments on commit 460ca11

Please sign in to comment.