Skip to content

Commit

Permalink
feat: create button-group plugin component (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpsmartdesign authored Jul 23, 2023
1 parent 2dc957f commit 038bf40
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/plugins/components/button-group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import plugin from 'tailwindcss/plugin'
import { defu } from 'defu'
import { type PluginOption, defaultPluginOptions } from '../options'

const defaultButtonGroupConfig = {}

export default plugin.withOptions(
function (options: PluginOption) {
const { prefix } = defu(options, defaultPluginOptions)

return function ({ addComponents, theme }) {
const config = theme(
'shurikenUi.buttonGroup'
) satisfies typeof defaultButtonGroupConfig

addComponents({
[`.${prefix}-button-group`]: {
[`@apply flex`]: {},

[`.${prefix}-button, .${prefix}-button-action, .${prefix}-button-icon`]:
{
[`@apply !border-e-0`]: {},
[`&:not(:first-child):not(:last-child)`]: {
[`@apply !rounded-none`]: {},
},
[`&:first-child`]: {
[`@apply !rounded-e-none`]: {},
},
[`&:last-child`]: {
[`@apply !border-e !rounded-s-none`]: {},
},
},
},
})
}
},
function () {
return {
theme: {
shurikenUi: {
buttonGroup: defaultButtonGroupConfig,
},
},
}
}
)
2 changes: 2 additions & 0 deletions src/plugins/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import plugin from 'tailwindcss/plugin'
import { defu } from 'defu'
import { type PluginOption } from '../options'
import buttonGroup from './button-group'
import dropdown from './dropdown'
import focus from './focus'
import label from './label'
Expand All @@ -11,6 +12,7 @@ import slimscroll from './slimscroll'
import tooltip from './tooltip'

const components = [
buttonGroup,
dropdown,
focus,
label,
Expand Down

0 comments on commit 038bf40

Please sign in to comment.