Skip to content

Commit 81bd2ab

Browse files
authored
Fix disabled: Tailwind variant (#2302)
* fix disabled variant in the tw config * eliminate svg: variant * delete unused between: variant
1 parent de7e443 commit 81bd2ab

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

app/components/Sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Button } from '~/ui/lib/Button'
1515
import { Truncate } from '~/ui/lib/Truncate'
1616

1717
const linkStyles =
18-
'flex h-7 items-center rounded px-2 text-sans-md hover:bg-hover svg:mr-2 svg:text-quinary text-secondary'
18+
'flex h-7 items-center rounded px-2 text-sans-md hover:bg-hover [&>svg]:mr-2 [&>svg]:text-quinary text-secondary'
1919

2020
// TODO: this probably doesn't go to the docs root. maybe it even opens a
2121
// menu with links to several relevant docs for the page
@@ -97,7 +97,7 @@ export const NavLinkItem = (props: {
9797
to={props.to}
9898
className={({ isActive }) =>
9999
cn(linkStyles, {
100-
'text-accent !bg-accent-secondary hover:!bg-accent-secondary-hover svg:!text-accent-tertiary':
100+
'text-accent !bg-accent-secondary hover:!bg-accent-secondary-hover [&>svg]:!text-accent-tertiary':
101101
isActive || currentPathIsCreateForm,
102102
'pointer-events-none text-disabled': props.disabled,
103103
})

app/ui/lib/Button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export type ButtonSize = (typeof buttonSizes)[number]
1919
export type Variant = (typeof variants)[number]
2020

2121
const sizeStyle: Record<ButtonSize, string> = {
22-
sm: 'h-8 px-3 text-mono-sm svg:w-4',
22+
sm: 'h-8 px-3 text-mono-sm [&>svg]:w-4',
2323
// meant for buttons that only contain a single icon
24-
icon: 'h-8 w-8 text-mono-sm svg:w-4',
25-
base: 'h-10 px-4 text-mono-sm svg:w-5',
24+
icon: 'h-8 w-8 text-mono-sm [&>svg]:w-4',
25+
base: 'h-10 px-4 text-mono-sm [&>svg]:w-5',
2626
}
2727

2828
type ButtonStyleProps = {

app/ui/lib/Message.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export const Message = ({
8484
className
8585
)}
8686
>
87-
<div className="mt-[2px] flex svg:h-3 svg:w-3">{icon || defaultIcon[variant]}</div>
87+
<div className="mt-[2px] flex [&>svg]:h-3 [&>svg]:w-3">
88+
{icon || defaultIcon[variant]}
89+
</div>
8890
<div className="flex-1 pl-2.5">
8991
{title && <div className="text-sans-semi-md">{title}</div>}
9092
<div

app/ui/lib/TipIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function TipIcon({ children, className }: TipIconProps) {
1919
return (
2020
<Tooltip content={children} placement="top">
2121
<button
22-
className={cn('inline-flex svg:pointer-events-none', className)}
22+
className={cn('inline-flex [&>svg]:pointer-events-none', className)}
2323
type="button"
2424
>
2525
<Question12Icon className="text-quinary" />

app/ui/lib/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const Toast = ({
9393
textColor[variant]
9494
)}
9595
>
96-
<div className="mt-[2px] flex svg:h-3 svg:w-3">{icon[variant]}</div>
96+
<div className="mt-[2px] flex [&>svg]:h-3 [&>svg]:w-3">{icon[variant]}</div>
9797
<div className="flex-1 pl-2.5">
9898
<div className="text-sans-semi-md">{title || defaultTitle[variant]}</div>
9999
<div className={cn('text-sans-md', secondaryTextColor[variant])}>{content}</div>

tailwind.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@ module.exports = {
6565
},
6666
plugins: [
6767
plugin(({ addVariant, addUtilities, variants }) => {
68-
// imitation of the twin.macro svg: variant. svg:text-green-500 puts green
69-
// on an SVG that's an immediate child of the element
70-
addVariant('svg', '& > svg')
7168
addVariant('children', '& > *')
72-
addVariant('between', '& > * + *')
7369
addVariant('selected', '.is-selected &')
74-
addVariant('disabled', '&.visually-disabled, &:disabled')
70+
addVariant('disabled', ['&.visually-disabled', '&:disabled'])
7571
addUtilities(
7672
Array.from({ length: 12 }, (_, i) => i)
7773
.map((i) => ({

0 commit comments

Comments
 (0)