-
-
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 button-group plugin component (#42)
- Loading branch information
1 parent
2dc957f
commit 038bf40
Showing
2 changed files
with
48 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
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, | ||
}, | ||
}, | ||
} | ||
} | ||
) |
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