@hoardodile/ui 0.1.2 → 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/plugin-download-consent.d.ts +8 -0
- package/dist/components/plugin-download-consent.js +2 -0
- package/dist/components/plugin-download-consent.js.map +1 -1
- 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/preview-card.d.ts +14 -0
- package/dist/components/preview-card.js +102 -0
- package/dist/components/preview-card.js.map +1 -0
- 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/plugin-download-consent.test.tsx +13 -0
- package/src/components/plugin-download-consent.tsx +10 -0
- package/src/components/popover.tsx +21 -0
- package/src/components/preview-card.tsx +100 -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,87 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactNode, ReactElement, MouseEvent, ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
|
|
4
|
+
/** The two sanctioned chip sizes: `sm` (default, `px-2 py-1`) for cards and
|
|
5
|
+
inline rows, `md` (`px-2 py-1.5`) for the filterer facets (Categories,
|
|
6
|
+
Traits, Relations). */
|
|
7
|
+
type TagChipSize = "sm" | "md";
|
|
8
|
+
type TagChipBaseProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Effective display color. Special names (`silver`, `gold`, `rainbow`,
|
|
11
|
+
* ...) render their SVG texture; an empty string falls back to the
|
|
12
|
+
* default muted chip, taking the primary fill when `active`. Ignored
|
|
13
|
+
* when `border` is set — bordered modes never take a tint.
|
|
14
|
+
*/
|
|
15
|
+
readonly color?: string;
|
|
16
|
+
/** Chip height tier — see {@link TagChipSize}. */
|
|
17
|
+
readonly size?: TagChipSize;
|
|
18
|
+
/**
|
|
19
|
+
* Border mode instead of the fill/ghost anatomies. Only `"dashed"`
|
|
20
|
+
* exists today (add pills, unused entities): a `border-dashed` hairline
|
|
21
|
+
* with muted ink and no color tint — `active` swaps in the accent fill
|
|
22
|
+
* with a transparent border so the width never moves with the state.
|
|
23
|
+
*/
|
|
24
|
+
readonly border?: "dashed";
|
|
25
|
+
/** Selected: colored chips deepen to their hover tint, special styles
|
|
26
|
+
switch to their own active appearance, uncolored chips take the
|
|
27
|
+
primary fill. */
|
|
28
|
+
readonly active?: boolean;
|
|
29
|
+
/** Leading icon; rides the chip's own gap, so no wrapper is needed. */
|
|
30
|
+
readonly icon?: ReactNode;
|
|
31
|
+
/** False removes the right border-radius so the chip can glue flush
|
|
32
|
+
against a sibling (e.g. the category rail's chevron). */
|
|
33
|
+
readonly roundedRight?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Root element mode: `"inline"` (default) renders a plain `<span>`,
|
|
36
|
+
* `"button"` a real `<button type="button">`. The element is chosen
|
|
37
|
+
* only from this prop (or `render`) — passing an `onClick` never
|
|
38
|
+
* changes the element, so interactive wrappers (hover cards,
|
|
39
|
+
* popovers) that merge click handlers onto the chip cannot swap its
|
|
40
|
+
* DOM node mid-interaction.
|
|
41
|
+
*/
|
|
42
|
+
readonly display?: "inline" | "button";
|
|
43
|
+
/**
|
|
44
|
+
* Polymorphic root: pass a `render={<button ... />}` element to render
|
|
45
|
+
* the chip as that element. The chip's own classes, style, handlers,
|
|
46
|
+
* texture and icon merge onto it, and the chip's children become the
|
|
47
|
+
* element's children — so the render element should carry only its own
|
|
48
|
+
* props. Wins over `display`; `display="button"` is the plain way to
|
|
49
|
+
* get a real button without supplying a render element.
|
|
50
|
+
*/
|
|
51
|
+
readonly render?: ReactElement<Record<string, unknown>>;
|
|
52
|
+
/**
|
|
53
|
+
* Trailing suffix, separated from the label by a middle dot (e.g. a
|
|
54
|
+
* trait's kind "cm" or a count). Rendered at the label's own size —
|
|
55
|
+
* same line box, so the chip height never depends on the suffix —
|
|
56
|
+
* with muted ink and a bold dot.
|
|
57
|
+
*/
|
|
58
|
+
readonly suffix?: ReactNode;
|
|
59
|
+
readonly children?: ReactNode;
|
|
60
|
+
readonly onMouseDown?: (event: MouseEvent<HTMLSpanElement>) => void;
|
|
61
|
+
};
|
|
62
|
+
type TagChipProps = TagChipBaseProps & Omit<ComponentPropsWithoutRef<"button">, keyof TagChipBaseProps>;
|
|
63
|
+
/**
|
|
64
|
+
* The one tag chip: a single rounded pill (inline-flex, `rounded-sm`,
|
|
65
|
+
* `px-2 py-1`, 12px text) that may carry an icon and a special SVG
|
|
66
|
+
* texture. It renders as a span by default; interactive surfaces pass
|
|
67
|
+
* `display="button"` (or `render={<button ... />}` for a custom root,
|
|
68
|
+
* e.g. a navigation anchor) and the chip's styling lands on that
|
|
69
|
+
* element — one element in the DOM plus a single text wrapper, no
|
|
70
|
+
* deeper nesting.
|
|
71
|
+
*
|
|
72
|
+
* The root element is decided purely by `display`/`render` — never by
|
|
73
|
+
* the presence of an `onClick`, so a chip's DOM element cannot change
|
|
74
|
+
* between renders (the hover-card trigger merge in {@link TagChipHover}
|
|
75
|
+
* relies on this).
|
|
76
|
+
*
|
|
77
|
+
* Coloring is delegated to {@link resolveTagChipSurface} so cards,
|
|
78
|
+
* pickers, the doc editor and the character pills all share one
|
|
79
|
+
* definition of "what a colored tag looks like".
|
|
80
|
+
*
|
|
81
|
+
* The chip forwards its root ref so composition wrappers (e.g. the
|
|
82
|
+
* {@link TagChipHover} preview-card trigger, which clones the chip and
|
|
83
|
+
* attaches a DOM ref for anchoring) can reach the actual element.
|
|
84
|
+
*/
|
|
85
|
+
declare const TagChip: React.ForwardRefExoticComponent<TagChipBaseProps & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, keyof TagChipBaseProps> & React.RefAttributes<HTMLElement>>;
|
|
86
|
+
|
|
87
|
+
export { TagChip, type TagChipProps, type TagChipSize };
|