-
-
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 progress-circle plugin component (#28)
- Loading branch information
1 parent
038bf40
commit 94b59dd
Showing
3 changed files
with
73 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,58 @@ | ||
import plugin from 'tailwindcss/plugin' | ||
import { defu } from 'defu' | ||
import { type PluginOption, defaultPluginOptions } from '../options' | ||
|
||
const defaultProgressCircleConfig = { | ||
circleDuration: '500', | ||
default: { | ||
text: 'muted-200', | ||
textDark: 'muted-700', | ||
stroke: 'current', | ||
}, | ||
contrast: { | ||
text: 'muted-200', | ||
textDark: 'muted-900', | ||
stroke: 'current', | ||
}, | ||
} | ||
|
||
export default plugin.withOptions( | ||
function (options: PluginOption) { | ||
const { prefix } = defu(options, defaultPluginOptions) | ||
|
||
return function ({ addComponents, theme }) { | ||
const config = theme( | ||
'shurikenUi.progressCircle' | ||
) satisfies typeof defaultProgressCircleConfig | ||
|
||
addComponents({ | ||
[`.${prefix}-progress-circle`]: { | ||
[`@apply relative inline-flex items-center justify-center`]: {}, | ||
|
||
[`circle:nth-child(2)`]: { | ||
// Is this a component or a class? | ||
[`@apply stroke-current transition-all duration-${config.circleDuration}`]: | ||
{}, | ||
}, | ||
[`&.${prefix}-progress-default circle:first-child`]: { | ||
[`@apply text-${config.default.text} dark:text-${config.default.textDark} stroke-${config.default.stroke}`]: | ||
{}, | ||
}, | ||
[`&.${prefix}-progress-contrast circle:first-child`]: { | ||
[`@apply text-${config.contrast.text} dark:text-${config.contrast.textDark} stroke-${config.contrast.stroke}`]: | ||
{}, | ||
}, | ||
}, | ||
}) | ||
} | ||
}, | ||
function () { | ||
return { | ||
theme: { | ||
shurikenUi: { | ||
progressCircle: defaultProgressCircleConfig, | ||
}, | ||
}, | ||
} | ||
} | ||
) |