-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create breadcrumb plugin component (#16)
Co-authored-by: Sacha Stafyniak <sacha@digisquad.io>
- Loading branch information
1 parent
299e3b3
commit 460ca11
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}, | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters