@brightweblabs/ui 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/lib/utils.test.ts +41 -0
- package/src/lib/utils.ts +23 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightweblabs/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.6",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
7
7
|
"files": [
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"recharts": "^2.15.4",
|
|
77
77
|
"sonner": "^2.0.7",
|
|
78
78
|
"tailwind-merge": "^3.6.0",
|
|
79
|
-
"@brightweblabs/theme": "0.7.
|
|
79
|
+
"@brightweblabs/theme": "0.7.4"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"lucide-react": "^1.8.0",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import assert from "node:assert/strict"
|
|
2
|
+
import test from "node:test"
|
|
3
|
+
|
|
4
|
+
import { cn } from "./utils.ts"
|
|
5
|
+
|
|
6
|
+
test("canonical typography utilities do not remove semantic foreground colors", () => {
|
|
7
|
+
const typographyUtilities = [
|
|
8
|
+
"text-heading-1",
|
|
9
|
+
"text-heading-2",
|
|
10
|
+
"text-heading-3",
|
|
11
|
+
"text-heading-4",
|
|
12
|
+
"text-title",
|
|
13
|
+
"text-body-lg",
|
|
14
|
+
"text-body",
|
|
15
|
+
"text-meta",
|
|
16
|
+
"text-label",
|
|
17
|
+
"text-micro",
|
|
18
|
+
"text-kpi",
|
|
19
|
+
"text-kpi-lg",
|
|
20
|
+
"text-data-sm",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
for (const typography of typographyUtilities) {
|
|
24
|
+
const result = cn("text-destructive-foreground", typography).split(" ")
|
|
25
|
+
|
|
26
|
+
assert.ok(result.includes(typography), `${typography} must remain a font-size utility`)
|
|
27
|
+
assert.ok(
|
|
28
|
+
result.includes("text-destructive-foreground"),
|
|
29
|
+
`${typography} must not remove semantic foreground colors`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test("canonical typography utilities preserve intentional consumer colors", () => {
|
|
35
|
+
const result = cn("text-label text-muted-foreground", "text-body text-destructive").split(" ")
|
|
36
|
+
|
|
37
|
+
assert.ok(result.includes("text-body"))
|
|
38
|
+
assert.ok(result.includes("text-destructive"))
|
|
39
|
+
assert.ok(!result.includes("text-label"))
|
|
40
|
+
assert.ok(!result.includes("text-muted-foreground"))
|
|
41
|
+
})
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { clsx, type ClassValue } from "clsx"
|
|
2
|
-
import {
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge"
|
|
3
|
+
|
|
4
|
+
const twMerge = extendTailwindMerge<"canonical-typography">({
|
|
5
|
+
extend: {
|
|
6
|
+
classGroups: {
|
|
7
|
+
"canonical-typography": [
|
|
8
|
+
"text-heading-1",
|
|
9
|
+
"text-heading-2",
|
|
10
|
+
"text-heading-3",
|
|
11
|
+
"text-heading-4",
|
|
12
|
+
"text-title",
|
|
13
|
+
"text-body-lg",
|
|
14
|
+
"text-body",
|
|
15
|
+
"text-meta",
|
|
16
|
+
"text-label",
|
|
17
|
+
"text-micro",
|
|
18
|
+
"text-kpi",
|
|
19
|
+
"text-kpi-lg",
|
|
20
|
+
"text-data-sm",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
3
25
|
|
|
4
26
|
export function cn(...inputs: ClassValue[]) {
|
|
5
27
|
return twMerge(clsx(inputs))
|