Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create progress-circle plugin component #28

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ export default withShurikenUI({
text: 'primary-800',
textDark: 'primary-200',
},
progressCircle: {
circleDuration: '500',
default: {
text: 'muted-200',
textDark: 'muted-700',
stroke: 'current',
},
contrast: {
text: 'muted-200',
textDark: 'muted-900',
stroke: 'current',
}
},
slimscroll: {
width: '[6px]',
bg: 'black/5',
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import label from './label'
import mark from './mark'
import mask from './mask'
import placeload from './placeload'
import progressCircle from './progress-circle'
import slimscroll from './slimscroll'
import tooltip from './tooltip'

Expand All @@ -17,6 +18,7 @@ const components = [
mark,
mask,
placeload,
progressCircle,
slimscroll,
tooltip,
]
Expand Down
58 changes: 58 additions & 0 deletions src/plugins/components/progress-circle.ts
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)`]: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driss-chelouati why is there a circle tag selector here? Should we be inside a svg tag? I would prefer having a class selector here

// 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,
},
},
}
}
)