-
-
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 list plugin component (#23)
Co-authored-by: Sacha Stafyniak <sacha@digisquad.io>
- Loading branch information
1 parent
2ab85c5
commit 9d6e7c1
Showing
3 changed files
with
78 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
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,61 @@ | ||
import plugin from 'tailwindcss/plugin' | ||
import { defu } from 'defu' | ||
import { type PluginOption, defaultPluginOptions } from '../options' | ||
|
||
const defaultlistConfig = { | ||
ul: 'disc', | ||
ol: 'decimal', | ||
base: { | ||
list: 'disc', | ||
textMarker: 'muted-500', | ||
textMarkerDark: 'muted-400', | ||
text: 'slate-700', | ||
textDark: 'slate-300', | ||
font: 'sans', | ||
}, | ||
media: { | ||
textMarker: 'slate-500', | ||
textMarkerDark: 'slate-400', | ||
}, | ||
} | ||
|
||
export default plugin.withOptions( | ||
function (options: PluginOption) { | ||
const { prefix } = defu(options, defaultPluginOptions) | ||
|
||
return function ({ addComponents, theme }) { | ||
const config = theme('shurikenUi.list') satisfies typeof defaultlistConfig | ||
|
||
addComponents({ | ||
[`.${prefix}-list`]: { | ||
[`&.${prefix}-list-ul`]: { | ||
[`@apply list-${config.ul}`]: {}, | ||
}, | ||
[`&.${prefix}-list-ol`]: { | ||
[`@apply list-${config.ol}`]: {}, | ||
}, | ||
[`&.${prefix}-list-base`]: { | ||
[`@apply list-${config.base.list} space-y-1 marker:text-${config.base.textMarker} dark:marker:text-${config.base.textMarkerDark} font-${config.base.font} text-${config.base.text} dark:text-${config.base.textDark}`]: | ||
{}, | ||
}, | ||
[`&.${prefix}-list-media`]: { | ||
[`@apply space-y-4 marker:text-${config.media.textMarker} dark:marker:text-${config.media.textMarkerDark}`]: | ||
{}, | ||
[`.${prefix}-list-item`]: { | ||
[`@apply flex gap-2`]: {}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
}, | ||
function () { | ||
return { | ||
theme: { | ||
shurikenUi: { | ||
list: defaultlistConfig, | ||
}, | ||
}, | ||
} | ||
} | ||
) |