Skip to content

Commit d0338e5

Browse files
committed
refactor(variants): separate grouped styles into individual ones to generate valid style outputs.
1 parent f0865f3 commit d0338e5

33 files changed

+140
-137
lines changed

src/variants/accordion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const accordionVariants = tv({
1313
description: '',
1414
trigger: [
1515
`flex-1 flex items-center justify-start font-medium transition-all-200 bg-transparent`,
16-
`focus-visible:(outline-none ring-2 ring-offset-2 ring-offset-background ring-primary)`,
16+
`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:ring-primary`,
1717
`hover:underline [&[data-state=open]>.trigger-icon]:rotate-180`
1818
],
1919
triggerLeadingIcon: `shrink-0`,

src/variants/breadcrumb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const breadcrumbVariants = tv({
99
page: 'font-normal text-foreground',
1010
separator: 'text-muted-foreground flex-shrink-0 list-none',
1111
ellipsis: 'flex items-center justify-center',
12-
link: 'hover:text-foreground transition-colors-200 rounded-sm focus-visible:(outline-none ring-2 ring-offset-2 ring-offset-background ring-primary)'
12+
link: 'hover:text-foreground transition-colors-200 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:ring-primary'
1313
},
1414
variants: {
1515
size: {

src/variants/button.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type { VariantProps } from 'tailwind-variants';
55
export const buttonVariants = tv({
66
base: [
77
'inline-flex items-center justify-center font-medium',
8-
'focus-visible:(outline-none ring-2 ring-offset-2 ring-offset-background)',
9-
'data-[disabled]:(cursor-not-allowed opacity-50)'
8+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background',
9+
'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50'
1010
],
1111
variants: {
1212
color: {
@@ -173,42 +173,42 @@ export const buttonVariants = tv({
173173
{
174174
color: 'primary',
175175
variant: 'plain',
176-
class: 'hover:(border-primary text-primary)'
176+
class: 'hover:border-primary hover:text-primary'
177177
},
178178
{
179179
color: 'destructive',
180180
variant: 'plain',
181-
class: 'hover:(border-destructive text-destructive)'
181+
class: 'hover:border-destructive hover:text-destructive'
182182
},
183183
{
184184
color: 'success',
185185
variant: 'plain',
186-
class: 'hover:(border-success text-success)'
186+
class: 'hover:border-success hover:text-success'
187187
},
188188
{
189189
color: 'warning',
190190
variant: 'plain',
191-
class: 'hover:(border-warning text-warning)'
191+
class: 'hover:border-warning hover:text-warning'
192192
},
193193
{
194194
color: 'info',
195195
variant: 'plain',
196-
class: 'hover:(border-info text-info)'
196+
class: 'hover:border-info hover:text-info'
197197
},
198198
{
199199
color: 'carbon',
200200
variant: 'plain',
201-
class: 'hover:(border-carbon text-carbon)'
201+
class: 'hover:border-carbon hover:text-carbon'
202202
},
203203
{
204204
color: 'secondary',
205205
variant: 'plain',
206-
class: 'hover:(border-secondary-foreground text-secondary-foreground)'
206+
class: 'hover:border-secondary-foreground hover:text-secondary-foreground'
207207
},
208208
{
209209
color: 'accent',
210210
variant: 'plain',
211-
class: 'hover:(border-accent-foreground text-accent-foreground)'
211+
class: 'hover:border-accent-foreground hover:text-accent-foreground'
212212
},
213213
{
214214
color: 'primary',

src/variants/checkbox.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ export const checkboxVariants = tv({
88
root: 'inline-flex items-center',
99
control: [
1010
'peer shrink-0 border shadow',
11-
'focus-visible:(outline-none ring-2 ring-offset-2 ring-offset-background) disabled:(cursor-not-allowed opacity-50)'
11+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50'
1212
],
1313
indicator: 'size-full flex items-center justify-center text-current',
1414
label: ''
1515
},
1616
variants: {
1717
color: {
1818
primary: {
19-
control: `border-primary focus-visible:ring-primary data-[state=checked]:(bg-primary text-primary-foreground) data-[state=indeterminate]:(bg-primary text-primary-foreground)`
19+
control: `border-primary focus-visible:ring-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground`
2020
},
2121
destructive: {
22-
control: `border-destructive focus-visible:ring-destructive data-[state=checked]:(bg-destructive text-destructive-foreground) data-[state=indeterminate]:(bg-destructive text-destructive-foreground)`
22+
control: `border-destructive focus-visible:ring-destructive data-[state=checked]:bg-destructive data-[state=checked]:text-destructive-foreground data-[state=indeterminate]:bg-destructive data-[state=indeterminate]:text-destructive-foreground`
2323
},
2424
success: {
25-
control: `border-success focus-visible:ring-success data-[state=checked]:(bg-success text-success-foreground) data-[state=indeterminate]:(bg-success text-success-foreground)`
25+
control: `border-success focus-visible:ring-success data-[state=checked]:bg-success data-[state=checked]:text-success-foreground data-[state=indeterminate]:bg-success data-[state=indeterminate]:text-success-foreground`
2626
},
2727
warning: {
28-
control: `border-warning focus-visible:ring-warning data-[state=checked]:(bg-warning text-warning-foreground) data-[state=indeterminate]:(bg-warning text-warning-foreground)`
28+
control: `border-warning focus-visible:ring-warning data-[state=checked]:bg-warning data-[state=checked]:text-warning-foreground data-[state=indeterminate]:bg-warning data-[state=indeterminate]:text-warning-foreground`
2929
},
3030
info: {
31-
control: `border-info focus-visible:ring-info data-[state=checked]:(bg-info text-info-foreground) data-[state=indeterminate]:(bg-info text-info-foreground)`
31+
control: `border-info focus-visible:ring-info data-[state=checked]:bg-info data-[state=checked]:text-info-foreground data-[state=indeterminate]:bg-info data-[state=indeterminate]:text-info-foreground`
3232
},
3333
carbon: {
34-
control: `border-carbon focus-visible:ring-carbon data-[state=checked]:(bg-carbon text-carbon-foreground) data-[state=indeterminate]:(bg-carbon text-carbon-foreground)`
34+
control: `border-carbon focus-visible:ring-carbon data-[state=checked]:bg-carbon data-[state=checked]:text-carbon-foreground data-[state=indeterminate]:bg-carbon data-[state=indeterminate]:text-carbon-foreground`
3535
},
3636
secondary: {
37-
control: `border-secondary-foreground/50 focus-visible:ring-secondary-foreground/20 data-[state=checked]:(bg-secondary-foreground/5 text-secondary-foreground) data-[state=indeterminate]:(bg-secondary-foreground/5 text-secondary-foreground)`
37+
control: `border-secondary-foreground/50 focus-visible:ring-secondary-foreground/20 data-[state=checked]:bg-secondary-foreground/5 data-[state=checked]:text-secondary-foreground data-[state=indeterminate]:bg-secondary-foreground/5 data-[state=indeterminate]:text-secondary-foreground`
3838
},
3939
accent: {
40-
control: `border-accent-foreground/50 focus-visible:ring-accent-foreground/20 data-[state=checked]:(bg-accent-foreground/5 text-accent-foreground) data-[state=indeterminate]:(bg-accent-foreground/5 text-accent-foreground)`
40+
control: `border-accent-foreground/50 focus-visible:ring-accent-foreground/20 data-[state=checked]:bg-accent-foreground/5 data-[state=checked]:text-accent-foreground data-[state=indeterminate]:bg-accent-foreground/5 data-[state=indeterminate]:text-accent-foreground`
4141
}
4242
},
4343
size: {
@@ -108,7 +108,7 @@ export const checkboxCardVariants = tv({
108108
description: 'text-muted-foreground',
109109
control: [
110110
'peer shrink-0 border shadow',
111-
'focus-visible:(outline-none ring-2 ring-offset-2 ring-offset-background) disabled:(cursor-not-allowed opacity-50)',
111+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50',
112112
'order-1 after:absolute after:inset-0 after:content-empty'
113113
],
114114
indicator: 'size-full flex items-center justify-center text-current'
@@ -117,35 +117,35 @@ export const checkboxCardVariants = tv({
117117
color: {
118118
primary: {
119119
root: 'data-[state=checked]:border-primary',
120-
control: `border-primary focus-visible:ring-primary data-[state=checked]:(bg-primary text-primary-foreground) data-[state=indeterminate]:(bg-primary text-primary-foreground)`
120+
control: `border-primary focus-visible:ring-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground`
121121
},
122122
destructive: {
123123
root: 'data-[state=checked]:border-destructive',
124-
control: `border-destructive focus-visible:ring-destructive data-[state=checked]:(bg-destructive text-destructive-foreground) data-[state=indeterminate]:(bg-destructive text-destructive-foreground)`
124+
control: `border-destructive focus-visible:ring-destructive data-[state=checked]:bg-destructive data-[state=checked]:text-destructive-foreground data-[state=indeterminate]:bg-destructive data-[state=indeterminate]:text-destructive-foreground`
125125
},
126126
success: {
127127
root: 'data-[state=checked]:border-success',
128-
control: `border-success focus-visible:ring-success data-[state=checked]:(bg-success text-success-foreground) data-[state=indeterminate]:(bg-success text-success-foreground)`
128+
control: `border-success focus-visible:ring-success data-[state=checked]:bg-success data-[state=checked]:text-success-foreground data-[state=indeterminate]:bg-success data-[state=indeterminate]:text-success-foreground`
129129
},
130130
warning: {
131131
root: 'data-[state=checked]:border-warning',
132-
control: `border-warning focus-visible:ring-warning data-[state=checked]:(bg-warning text-warning-foreground) data-[state=indeterminate]:(bg-warning text-warning-foreground)`
132+
control: `border-warning focus-visible:ring-warning data-[state=checked]:bg-warning data-[state=checked]:text-warning-foreground data-[state=indeterminate]:bg-warning data-[state=indeterminate]:text-warning-foreground`
133133
},
134134
info: {
135135
root: 'data-[state=checked]:border-info',
136-
control: `border-info focus-visible:ring-info data-[state=checked]:(bg-info text-info-foreground) data-[state=indeterminate]:(bg-info text-info-foreground)`
136+
control: `border-info focus-visible:ring-info data-[state=checked]:bg-info data-[state=checked]:text-info-foreground data-[state=indeterminate]:bg-info data-[state=indeterminate]:text-info-foreground`
137137
},
138138
carbon: {
139139
root: 'data-[state=checked]:border-carbon',
140-
control: `border-carbon focus-visible:ring-carbon data-[state=checked]:(bg-carbon text-carbon-foreground) data-[state=indeterminate]:(bg-carbon text-carbon-foreground)`
140+
control: `border-carbon focus-visible:ring-carbon data-[state=checked]:bg-carbon data-[state=checked]:text-carbon-foreground data-[state=indeterminate]:bg-carbon data-[state=indeterminate]:text-carbon-foreground`
141141
},
142142
secondary: {
143143
root: 'data-[state=checked]:border-secondary-foreground/50',
144-
control: `border-secondary-foreground/50 focus-visible:ring-secondary-foreground/20 data-[state=checked]:(bg-secondary-foreground/5 text-secondary-foreground) data-[state=indeterminate]:(bg-secondary-foreground/5 text-secondary-foreground)`
144+
control: `border-secondary-foreground/50 focus-visible:ring-secondary-foreground/20 data-[state=checked]:bg-secondary-foreground/5 data-[state=checked]:text-secondary-foreground data-[state=indeterminate]:bg-secondary-foreground/5 data-[state=indeterminate]:text-secondary-foreground`
145145
},
146146
accent: {
147147
root: 'data-[state=checked]:border-accent-foreground/50',
148-
control: `border-accent-foreground/50 focus-visible:ring-accent-foreground/20 data-[state=checked]:(bg-accent-foreground/5 text-accent-foreground) data-[state=indeterminate]:(bg-accent-foreground/5 text-accent-foreground)`
148+
control: `border-accent-foreground/50 focus-visible:ring-accent-foreground/20 data-[state=checked]:bg-accent-foreground/5 data-[state=checked]:text-accent-foreground data-[state=indeterminate]:bg-accent-foreground/5 data-[state=indeterminate]:text-accent-foreground`
149149
}
150150
},
151151
size: {

src/variants/combobox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const comboboxVariants = tv({
99
empty: `text-center`,
1010
content: [
1111
`z-50 w-[--soybean-combobox-trigger-width] rounded-md border bg-popover text-popover-foreground shadow-md outline-none`,
12-
`data-[state=open]:(animate-in fade-in-0 zoom-in-95) data-[state=closed]:(animate-out fade-out-0 zoom-out-95)`,
12+
`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,
1313
`data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`
1414
],
1515
list: `overflow-y-auto overflow-x-hidden`,
@@ -18,11 +18,11 @@ export const comboboxVariants = tv({
1818
inputWrapper: `flex items-center`,
1919
input: [
2020
`flex w-full bg-transparent transition-colors-200`,
21-
`placeholder:text-muted-foreground outline-none disabled:(cursor-not-allowed opacity-50)`
21+
`placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50`
2222
],
2323
item: [
2424
`relative flex justify-start items-center cursor-default select-none rounded-sm outline-none`,
25-
`data-[highlighted]:(bg-accent text-accent-foreground) data-[disabled]:(pointer-events-none opacity-50)`
25+
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`
2626
],
2727
itemIcon: 'shrink-0',
2828
itemIndicator: 'ml-auto',

src/variants/command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const commandVariants = tv({
55
slots: {
66
root: `flex w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,
77
inputRoot: 'group flex items-center border-b',
8-
inputControl: `flex w-full rounded-md bg-transparent outline-none placeholder:text-muted-foreground disabled:(cursor-not-allowed opacity-50)`,
8+
inputControl: `flex w-full rounded-md bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,
99
inputIcon: `shrink-0 opacity-50`,
1010
inputClearable: 'hidden group-hover:block size-1em cursor-pointer opacity-50 hover:opacity-100',
1111
empty: `text-center`,
@@ -14,7 +14,7 @@ export const commandVariants = tv({
1414
groupLabel: `font-medium text-muted-foreground`,
1515
item: [
1616
`relative flex cursor-default select-none items-center rounded-sm outline-none`,
17-
`data-[highlighted]:(bg-accent text-accent-foreground) data-[disabled]:(pointer-events-none opacity-50)`
17+
`data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`
1818
],
1919
itemLabel: '',
2020
itemIcon: 'shrink-0',

src/variants/dialog.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export const dialogVariants = tv({
55
slots: {
66
overlay: [
77
`fixed inset-0 z-50 bg-black/80`,
8-
`data-[state=open]:(animate-in fade-in-0)`,
9-
`data-[state=closed]:(animate-out fade-out-0)`
8+
`data-[state=open]:animate-in data-[state=open]:fade-in-0`,
9+
`data-[state=closed]:animate-out data-[state=closed]:fade-out-0`
1010
],
1111
content: [
1212
`fixed left-[50%] top-[50%] z-50 flex flex-col w-full border bg-background shadow-lg outline-none translate-x-[-50%] translate-y-[-50%] md:w-full duration-200 sm:rounded-lg`,
13-
`data-[state=open]:(animate-in fade-in-0 zoom-in-95 slide-in-from-left-1/2 slide-in-from-top-[48%])`,
14-
`data-[state=closed]:(animate-out fade-out-0 zoom-out-95 slide-out-to-left-1/2 slide-out-to-top-[48%])`
13+
`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-left-1/2`,
14+
`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-to-left-1/2`
1515
],
1616
header: `flex flex-col text-center sm:text-left`,
1717
title: `flex items-center font-semibold leading-none tracking-tight`,

src/variants/drawer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { tv } from 'tailwind-variants';
44
export const drawerContentVariants = tv({
55
base: [
66
`fixed z-50 flex flex-col justify-between items-stretch border bg-background rounded-md outline-none transition ease-in-out`,
7-
`data-[state=open]:(animate-in duration-500)`,
8-
`data-[state=closed]:(animate-out duration-300)`
7+
`data-[state=open]:animate-in data-[state=open]:duration-500`,
8+
`data-[state=closed]:animate-out data-[state=closed]:duration-300`
99
],
1010
variants: {
1111
size: {

src/variants/hover-card.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export const hoverCardVariants = tv({
55
slots: {
66
content: [
77
`w-auto p-4 rounded-md border bg-popover text-popover-foreground shadow-md outline-none z-50 will-change-transform`,
8-
`data-[state=open]:(zoom-in-95 fade-in-0 animate-in)`,
9-
`data-[state=closed]:(zoom-out-95 fade-out-0 animate-out)`,
8+
`data-[state=open]:zoom-in-95 data-[state=open]:fade-in-0 data-[state=open]:animate-in`,
9+
`data-[state=closed]:zoom-out-95 data-[state=closed]:fade-out-0 data-[state=closed]:animate-out`,
1010
`data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`
1111
],
1212
arrow: 'fill-popover stroke-border'

src/variants/input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export const inputVariants = tv({
55
slots: {
66
root: [
77
`group flex items-center w-full rounded-md border border-solid border-input bg-background`,
8-
`focus-within:(outline-none ring-2 ring-offset-2 ring-offset-background ring-primary)`
8+
`focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-offset-background focus-within:ring-primary`
99
],
1010
control: [
1111
'grow bg-transparent outline-none',
1212
'placeholder:text-muted-foreground',
13-
'disabled:(cursor-not-allowed opacity-50)',
14-
'file:(border-0 bg-transparent font-medium)'
13+
'disabled:cursor-not-allowed disabled:opacity-50',
14+
'file:border-0 file:bg-transparent file:font-medium'
1515
],
1616
clearable: 'hidden group-hover:block size-1em cursor-pointer opacity-50 hover:opacity-100',
1717
visible: 'cursor-pointer'

0 commit comments

Comments
 (0)