chore(tailwind): support tailwind class ordering in clsx functions [r8s-949] (#2292)

This commit is contained in:
Ali
2026-04-13 17:13:40 +12:00
committed by GitHub
parent ab3e0956a4
commit 0d836f1e30
7 changed files with 51 additions and 52 deletions
+2 -1
View File
@@ -17,5 +17,6 @@
} }
} }
], ],
"plugins": ["prettier-plugin-tailwindcss"] "plugins": ["prettier-plugin-tailwindcss"],
"tailwindFunctions": ["clsx"]
} }
+27 -27
View File
@@ -17,50 +17,50 @@ export type BadgeType =
// the classes are typed in full because tailwind doesn't render the interpolated classes // the classes are typed in full because tailwind doesn't render the interpolated classes
const typeClasses: Record<BadgeType, string> = { const typeClasses: Record<BadgeType, string> = {
success: clsx( success: clsx(
'text-success-9 bg-success-2', 'bg-success-2 text-success-9',
'th-dark:text-success-3 th-dark:bg-success-10', 'th-dark:bg-success-10 th-dark:text-success-3',
'th-highcontrast:text-success-3 th-highcontrast:bg-success-10' 'th-highcontrast:bg-success-10 th-highcontrast:text-success-3'
), ),
warn: clsx( warn: clsx(
'text-warning-9 bg-warning-2', 'bg-warning-2 text-warning-9',
'th-dark:text-warning-3 th-dark:bg-warning-10', 'th-dark:bg-warning-10 th-dark:text-warning-3',
'th-highcontrast:text-warning-3 th-highcontrast:bg-warning-10' 'th-highcontrast:bg-warning-10 th-highcontrast:text-warning-3'
), ),
danger: clsx( danger: clsx(
'text-error-9 bg-error-2', 'bg-error-2 text-error-9',
'th-dark:text-error-3 th-dark:bg-error-10', 'th-dark:bg-error-10 th-dark:text-error-3',
'th-highcontrast:text-error-3 th-highcontrast:bg-error-10' 'th-highcontrast:bg-error-10 th-highcontrast:text-error-3'
), ),
info: clsx( info: clsx(
'text-blue-9 bg-blue-2', 'bg-blue-2 text-blue-9',
'th-dark:text-blue-3 th-dark:bg-blue-10', 'th-dark:bg-blue-10 th-dark:text-blue-3',
'th-highcontrast:text-blue-3 th-highcontrast:bg-blue-10' 'th-highcontrast:bg-blue-10 th-highcontrast:text-blue-3'
), ),
// the secondary classes are a bit darker in light mode and a bit lighter in dark mode // the secondary classes are a bit darker in light mode and a bit lighter in dark mode
successSecondary: clsx( successSecondary: clsx(
'text-success-9 bg-success-3', 'bg-success-3 text-success-9',
'th-dark:text-success-3 th-dark:bg-success-9', 'th-dark:bg-success-9 th-dark:text-success-3',
'th-highcontrast:text-success-3 th-highcontrast:bg-success-9' 'th-highcontrast:bg-success-9 th-highcontrast:text-success-3'
), ),
warnSecondary: clsx( warnSecondary: clsx(
'text-warning-9 bg-warning-3', 'bg-warning-3 text-warning-9',
'th-dark:text-warning-3 th-dark:bg-warning-9', 'th-dark:bg-warning-9 th-dark:text-warning-3',
'th-highcontrast:text-warning-3 th-highcontrast:bg-warning-9' 'th-highcontrast:bg-warning-9 th-highcontrast:text-warning-3'
), ),
dangerSecondary: clsx( dangerSecondary: clsx(
'text-error-9 bg-error-3', 'bg-error-3 text-error-9',
'th-dark:text-error-3 th-dark:bg-error-9', 'th-dark:bg-error-9 th-dark:text-error-3',
'th-highcontrast:text-error-3 th-highcontrast:bg-error-9' 'th-highcontrast:bg-error-9 th-highcontrast:text-error-3'
), ),
infoSecondary: clsx( infoSecondary: clsx(
'text-blue-9 bg-blue-3', 'bg-blue-3 text-blue-9',
'th-dark:text-blue-3 th-dark:bg-blue-9', 'th-dark:bg-blue-9 th-dark:text-blue-3',
'th-highcontrast:text-blue-3 th-highcontrast:bg-blue-9' 'th-highcontrast:bg-blue-9 th-highcontrast:text-blue-3'
), ),
muted: clsx( muted: clsx(
'text-gray-9 bg-gray-3', 'bg-gray-3 text-gray-9',
'th-dark:text-gray-3 th-dark:bg-gray-9', 'th-dark:bg-gray-9 th-dark:text-gray-3',
'th-highcontrast:text-gray-3 th-highcontrast:bg-gray-9' 'th-highcontrast:bg-gray-9 th-highcontrast:text-gray-3'
), ),
}; };
@@ -44,8 +44,8 @@ export function BoxSelector<T extends Value>({
}: Props<T>) { }: Props<T>) {
const rootClassName = clsx( const rootClassName = clsx(
useGridLayout useGridLayout
? 'grid gap-2.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4' ? 'grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
: 'w-full flex flex-wrap gap-2.5 overflow-hidden mb-1 mt-1', : 'mb-1 mt-1 flex w-full flex-wrap gap-2.5 overflow-hidden',
className className
); );
@@ -6,9 +6,7 @@ type Props = IconProps;
export function LogoIcon({ icon, iconClass }: Props) { export function LogoIcon({ icon, iconClass }: Props) {
return ( return (
<div <div className="inline-flex h-14 w-14 items-center justify-center text-7xl">
className="inline-flex h-14 w-14 items-center justify-center text-7xl"
>
<Icon icon={icon} className={clsx('!flex', iconClass)} /> <Icon icon={icon} className={clsx('!flex', iconClass)} />
</div> </div>
); );
+17 -17
View File
@@ -17,38 +17,38 @@ export type StatusBadgeType =
const typeClasses: Record<StatusBadgeType, string> = { const typeClasses: Record<StatusBadgeType, string> = {
success: clsx( success: clsx(
'text-white bg-success-7', 'bg-success-7 text-white',
'th-dark:text-white th-dark:bg-success-9' 'th-dark:bg-success-9 th-dark:text-white'
), ),
warning: clsx( warning: clsx(
'text-white bg-warning-7', 'bg-warning-7 text-white',
'th-dark:text-white th-dark:bg-warning-9' 'th-dark:bg-warning-9 th-dark:text-white'
), ),
danger: clsx( danger: clsx(
'text-white bg-error-7', 'bg-error-7 text-white',
'th-dark:text-white th-dark:bg-error-9' 'th-dark:bg-error-9 th-dark:text-white'
), ),
info: clsx('text-white bg-blue-7', 'th-dark:text-white th-dark:bg-blue-9'), info: clsx('bg-blue-7 text-white', 'th-dark:bg-blue-9 th-dark:text-white'),
// the lite classes are a bit lighter in light mode and the same in dark mode // the lite classes are a bit lighter in light mode and the same in dark mode
successLite: clsx( successLite: clsx(
'text-success-9 bg-success-3', 'bg-success-3 text-success-9',
'th-dark:text-white th-dark:bg-success-9' 'th-dark:bg-success-9 th-dark:text-white'
), ),
warningLite: clsx( warningLite: clsx(
'text-warning-9 bg-warning-3', 'bg-warning-3 text-warning-9',
'th-dark:text-white th-dark:bg-warning-9' 'th-dark:bg-warning-9 th-dark:text-white'
), ),
dangerLite: clsx( dangerLite: clsx(
'text-error-9 bg-error-3', 'bg-error-3 text-error-9',
'th-dark:text-white th-dark:bg-error-9' 'th-dark:bg-error-9 th-dark:text-white'
), ),
mutedLite: clsx( mutedLite: clsx(
'text-gray-9 bg-gray-3', 'bg-gray-3 text-gray-9',
'th-dark:text-white th-dark:bg-gray-9' 'th-dark:bg-gray-9 th-dark:text-white'
), ),
infoLite: clsx( infoLite: clsx(
'text-blue-9 bg-blue-3', 'bg-blue-3 text-blue-9',
'th-dark:text-white th-dark:bg-blue-9' 'th-dark:bg-blue-9 th-dark:text-white'
), ),
default: '', default: '',
}; };
+1 -1
View File
@@ -85,7 +85,7 @@ function getStepState({
function getButtonClasses({ isActive, isCompleted, isClickable }: StepState) { function getButtonClasses({ isActive, isCompleted, isClickable }: StepState) {
return clsx( return clsx(
'flex items-center gap-2 rounded-lg border border-solid px-3 py-2 transition-all text-inherit font-medium', 'flex items-center gap-2 rounded-lg border border-solid px-3 py-2 font-medium text-inherit transition-all',
getButtonStateClasses({ isActive, isCompleted }), getButtonStateClasses({ isActive, isCompleted }),
isClickable isClickable
? clsx( ? clsx(
@@ -22,7 +22,7 @@ export function EditButtons({ environment }: { environment: Environment }) {
const configRoute = getConfigRoute(environment); const configRoute = getConfigRoute(environment);
const buttonsClasses = clsx( const buttonsClasses = clsx(
'w-full h-full !ml-0 !rounded-none', '!ml-0 h-full w-full !rounded-none',
'hover:bg-gray-3', 'hover:bg-gray-3',
'th-dark:hover:bg-gray-9', 'th-dark:hover:bg-gray-9',
'th-highcontrast:hover:bg-white th-highcontrast:hover:text-black' 'th-highcontrast:hover:bg-white th-highcontrast:hover:text-black'