refactor(ui-web): leave the cn() fix to #115
#115 fixes the same tailwind-merge bug more completely (text, control, icon and spacing scales, guarded against styles.css) and adds the same two files, so this branch drops its narrower copy to avoid the overlap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016or6oqCqP8wbNafvhnbLQT
This commit is contained in:
parent
0ef8849f24
commit
48e80611c6
@ -1,19 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { buttonVariants } from "../components/ui/button";
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
describe("cn", () => {
|
|
||||||
it("treats the ui type scale as font size, not color", () => {
|
|
||||||
expect(cn("text-primary-foreground", "text-ui-body")).toBe(
|
|
||||||
"text-primary-foreground text-ui-body",
|
|
||||||
);
|
|
||||||
expect(cn("text-ui-body", "text-base")).toBe("text-base");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("keeps the variant label color on resized buttons", () => {
|
|
||||||
const classes = cn(buttonVariants({ size: "lg", className: "text-base" })).split(" ");
|
|
||||||
expect(classes).toContain("text-primary-foreground");
|
|
||||||
expect(classes).toContain("text-base");
|
|
||||||
expect(classes).not.toContain("text-ui-body");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,27 +1,5 @@
|
|||||||
import { type ClassValue, clsx } from "clsx";
|
import { type ClassValue, clsx } from "clsx";
|
||||||
import { extendTailwindMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
// The shared type scale (`text-ui-*`) is a font size, not a color. Without this,
|
|
||||||
// `text-ui-body` would replace `text-primary-foreground` and hide button labels.
|
|
||||||
const twMerge = extendTailwindMerge({
|
|
||||||
extend: {
|
|
||||||
classGroups: {
|
|
||||||
"font-size": [
|
|
||||||
{
|
|
||||||
text: [
|
|
||||||
"ui-caption",
|
|
||||||
"ui-label",
|
|
||||||
"ui-body-sm",
|
|
||||||
"ui-body",
|
|
||||||
"ui-reading",
|
|
||||||
"ui-title-sm",
|
|
||||||
"ui-title",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user