@hoardodile/ui 0.1.3 → 0.1.4
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/dist/components/popover.d.ts +10 -1
- package/dist/components/popover.js +9 -0
- package/dist/components/popover.js.map +1 -1
- package/dist/components/special-tag-surface.d.ts +36 -0
- package/dist/components/special-tag-surface.js +533 -0
- package/dist/components/special-tag-surface.js.map +1 -0
- package/dist/components/tag-chip.d.ts +87 -0
- package/dist/components/tag-chip.js +713 -0
- package/dist/components/tag-chip.js.map +1 -0
- package/dist/lib/colors.d.ts +33 -0
- package/dist/lib/colors.js +65 -0
- package/dist/lib/colors.js.map +1 -0
- package/dist/lib/tag-surface.d.ts +22 -0
- package/dist/lib/tag-surface.js +615 -0
- package/dist/lib/tag-surface.js.map +1 -0
- package/package.json +2 -2
- package/src/components/popover.tsx +21 -0
- package/src/components/special/gold.tsx +73 -0
- package/src/components/special/kintsugi.tsx +143 -0
- package/src/components/special/oilslick.tsx +138 -0
- package/src/components/special/rainbow.tsx +63 -0
- package/src/components/special/silver.tsx +73 -0
- package/src/components/special/types.ts +21 -0
- package/src/components/special-tag-surface.tsx +53 -0
- package/src/components/tag-chip.test.tsx +180 -0
- package/src/components/tag-chip.tsx +221 -0
- package/src/lib/colors.test.ts +94 -0
- package/src/lib/colors.ts +96 -0
- package/src/lib/tag-surface.ts +71 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getSpecialTagStyleConfig } from "@hoardodile/ui/components/special-tag-surface"
|
|
2
|
+
import {
|
|
3
|
+
computeTagChipColors,
|
|
4
|
+
isSpecialTagStyle,
|
|
5
|
+
type TagSpecialStyle,
|
|
6
|
+
} from "@hoardodile/ui/lib/colors"
|
|
7
|
+
import { cn } from "@hoardodile/ui/lib/utils"
|
|
8
|
+
import type { CSSProperties } from "react"
|
|
9
|
+
|
|
10
|
+
export type ResolvedTagChipSurface = {
|
|
11
|
+
readonly className: string
|
|
12
|
+
readonly style: CSSProperties | undefined
|
|
13
|
+
/** The special SVG texture to layer under the chip's content, or null. */
|
|
14
|
+
readonly texture: TagSpecialStyle | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a chip's visual surface for a user-assigned color — the single
|
|
19
|
+
* source of chip coloring shared by every tag/category pill in the app.
|
|
20
|
+
*
|
|
21
|
+
* A plain color tints the whole chip (a 6% wash as fill, the color as ink,
|
|
22
|
+
* deepening to the hover tint when `active`); the five special styles
|
|
23
|
+
* (silver, gold, rainbow, oilslick, kintsugi) render their SVG texture;
|
|
24
|
+
* an empty color falls back to the default muted chip, taking the primary
|
|
25
|
+
* fill when `active`.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveTagChipSurface(
|
|
28
|
+
color: string,
|
|
29
|
+
active: boolean,
|
|
30
|
+
): ResolvedTagChipSurface {
|
|
31
|
+
if (isSpecialTagStyle(color)) {
|
|
32
|
+
const config = getSpecialTagStyleConfig(color)
|
|
33
|
+
return {
|
|
34
|
+
className: cn(
|
|
35
|
+
"relative isolate group",
|
|
36
|
+
config.default.className,
|
|
37
|
+
active ? config.active?.className : undefined,
|
|
38
|
+
),
|
|
39
|
+
style: {
|
|
40
|
+
...config.default.style,
|
|
41
|
+
...(active ? config.active?.style : {}),
|
|
42
|
+
},
|
|
43
|
+
texture: color,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (color === "") {
|
|
48
|
+
return active
|
|
49
|
+
? {
|
|
50
|
+
className: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
51
|
+
style: undefined,
|
|
52
|
+
texture: null,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
className: "bg-muted text-foreground hover:bg-accent",
|
|
56
|
+
style: undefined,
|
|
57
|
+
texture: null,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const chipColors = computeTagChipColors(color)
|
|
62
|
+
return {
|
|
63
|
+
className: "bg-(--chip-bg) hover:bg-(--chip-hover-bg)",
|
|
64
|
+
style: {
|
|
65
|
+
["--chip-bg" as string]: active ? chipColors.hoverBg : chipColors.baseBg,
|
|
66
|
+
["--chip-hover-bg" as string]: chipColors.hoverBg,
|
|
67
|
+
color: chipColors.fg,
|
|
68
|
+
},
|
|
69
|
+
texture: null,
|
|
70
|
+
}
|
|
71
|
+
}
|