@bearmenu/ui 0.8.2 → 0.8.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/chunk-2WDJR6K7.js +76 -0
- package/dist/components/icon.d.ts +18 -0
- package/dist/components/icon.js +31 -0
- package/dist/components/motion-icon-controls.d.ts +26 -0
- package/dist/components/motion-icon-controls.js +380 -0
- package/dist/components/motion-icon-set.d.ts +27 -0
- package/dist/components/motion-icon-set.js +139 -0
- package/dist/components/motion-icon.d.ts +44 -0
- package/dist/components/motion-icon.js +3 -0
- package/dist/lib/icon-registry.d.ts +58 -0
- package/dist/lib/icon-registry.js +39 -0
- package/package.json +2 -1
- package/src/components/accordion.stories.tsx +1 -1
- package/src/components/combobox.stories.tsx +1 -1
- package/src/components/currency-input.stories.tsx +3 -3
- package/src/components/empty-state.stories.tsx +3 -3
- package/src/components/form.stories.tsx +1 -1
- package/src/components/icon.tsx +57 -0
- package/src/components/input-otp.stories.tsx +1 -1
- package/src/components/markdown-renderer.stories.tsx +1 -1
- package/src/components/motion-icon-controls.test.tsx +78 -0
- package/src/components/motion-icon-controls.tsx +552 -0
- package/src/components/motion-icon-set.stories.tsx +185 -0
- package/src/components/motion-icon-set.tsx +219 -0
- package/src/components/motion-icon.test.tsx +159 -0
- package/src/components/motion-icon.tsx +163 -0
- package/src/components/multi-select-combobox.stories.tsx +1 -1
- package/src/components/phone-frame.stories.tsx +1 -1
- package/src/components/rating.stories.tsx +3 -3
- package/src/components/searchable-select.stories.tsx +1 -1
- package/src/components/selection-bar.stories.tsx +1 -1
- package/src/components/skeleton-card.stories.tsx +3 -3
- package/src/components/sliding-panels.stories.tsx +1 -1
- package/src/components/stepper.stories.tsx +1 -1
- package/src/components/sticky-container.stories.tsx +3 -3
- package/src/components/toggle-group.stories.tsx +1 -1
- package/src/components/tooltip.stories.tsx +2 -2
- package/src/globals.css +162 -40
- package/src/lib/icon-registry.ts +139 -0
- package/src/test/setup.ts +5 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The purpose → glyph registry.
|
|
3
|
+
*
|
|
4
|
+
* One place recording which glyph means what. Before this existed, ~10 ad-hoc
|
|
5
|
+
* glyph maps were scattered across the app and the same purpose ended up drawn
|
|
6
|
+
* two different ways: back as both an arrow and a chevron, "open filters" as
|
|
7
|
+
* both a funnel and sliders (one surface used both, chosen by which view you
|
|
8
|
+
* were in), clear and close sharing a bare X.
|
|
9
|
+
*
|
|
10
|
+
* Only GENERIC action vocabulary lives here. Product taxonomy — cuisine
|
|
11
|
+
* shortcuts, facet dimensions, digest categories — stays in the consuming app.
|
|
12
|
+
*
|
|
13
|
+
* ## The rules this encodes
|
|
14
|
+
*
|
|
15
|
+
* 1. **Arrow leaves, chevron stays.** `ArrowRight` means "you are going to a new
|
|
16
|
+
* destination" (see-all links, banner CTAs). `ChevronRight` means "reveal
|
|
17
|
+
* more, in place" and is scoped to exactly two jobs: carousel paging and
|
|
18
|
+
* row-contained drill-in. Collapsing these is what produced a glyph with
|
|
19
|
+
* four meanings.
|
|
20
|
+
* 2. **Sliders, not a funnel.** A funnel reads as "narrow a list" and collides
|
|
21
|
+
* with search and sort iconography at 24px; three sliders read
|
|
22
|
+
* unambiguously as "adjust parameters" and carry a badge count cleanly.
|
|
23
|
+
* 3. **Containment separates clear from close.** A bare `X` leaves a layer. A
|
|
24
|
+
* contained `XCircle` resets a value in place without leaving. In a dense
|
|
25
|
+
* filter row, bare Xs beside each other cannot say which layer they close.
|
|
26
|
+
* 4. **Tappable has a container or a colour state; information is muted and
|
|
27
|
+
* bare.** This is what disambiguates the overloaded glyphs (`MapPin`,
|
|
28
|
+
* `Star`) rather than picking different glyphs for each sense. An
|
|
29
|
+
* interactive instance sits in a chip or button and takes an active colour;
|
|
30
|
+
* a decorative one is `text-muted-foreground`, `aria-hidden`, outside any
|
|
31
|
+
* button, with no hover or active transition.
|
|
32
|
+
* 5. **Loved and want-to-try are two actions, not one.** `Heart` is
|
|
33
|
+
* retrospective ("I have had this and I love it"), `Bookmark` is prospective
|
|
34
|
+
* ("I want to try this"). They feed different lists and are mutually
|
|
35
|
+
* exclusive per item.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
ArrowLeft,
|
|
40
|
+
ArrowRight,
|
|
41
|
+
ArrowUpDown,
|
|
42
|
+
Bookmark,
|
|
43
|
+
Check,
|
|
44
|
+
ChevronDown,
|
|
45
|
+
ChevronLeft,
|
|
46
|
+
ChevronRight,
|
|
47
|
+
ExternalLink,
|
|
48
|
+
Flag,
|
|
49
|
+
Heart,
|
|
50
|
+
Info,
|
|
51
|
+
Navigation,
|
|
52
|
+
Phone,
|
|
53
|
+
Plus,
|
|
54
|
+
RefreshCw,
|
|
55
|
+
Search,
|
|
56
|
+
Share2,
|
|
57
|
+
SlidersHorizontal,
|
|
58
|
+
Trash2,
|
|
59
|
+
X,
|
|
60
|
+
XCircle,
|
|
61
|
+
type LucideIcon,
|
|
62
|
+
} from "lucide-react";
|
|
63
|
+
|
|
64
|
+
export type IconPurpose =
|
|
65
|
+
// navigation
|
|
66
|
+
| "back"
|
|
67
|
+
| "seeAll"
|
|
68
|
+
| "drillIn"
|
|
69
|
+
| "carouselPrev"
|
|
70
|
+
| "carouselNext"
|
|
71
|
+
| "directions"
|
|
72
|
+
| "externalLink"
|
|
73
|
+
// layers and values
|
|
74
|
+
| "close"
|
|
75
|
+
| "clear"
|
|
76
|
+
| "expand"
|
|
77
|
+
// list controls
|
|
78
|
+
| "filter"
|
|
79
|
+
| "sort"
|
|
80
|
+
| "search"
|
|
81
|
+
// actions
|
|
82
|
+
| "share"
|
|
83
|
+
| "favorite"
|
|
84
|
+
| "wantToTry"
|
|
85
|
+
| "confirm"
|
|
86
|
+
| "add"
|
|
87
|
+
| "remove"
|
|
88
|
+
| "refresh"
|
|
89
|
+
| "call"
|
|
90
|
+
| "report"
|
|
91
|
+
| "info";
|
|
92
|
+
|
|
93
|
+
export const iconFor: Record<IconPurpose, LucideIcon> = {
|
|
94
|
+
back: ArrowLeft,
|
|
95
|
+
seeAll: ArrowRight,
|
|
96
|
+
drillIn: ChevronRight,
|
|
97
|
+
carouselPrev: ChevronLeft,
|
|
98
|
+
carouselNext: ChevronRight,
|
|
99
|
+
directions: Navigation,
|
|
100
|
+
externalLink: ExternalLink,
|
|
101
|
+
|
|
102
|
+
close: X,
|
|
103
|
+
clear: XCircle,
|
|
104
|
+
expand: ChevronDown,
|
|
105
|
+
|
|
106
|
+
filter: SlidersHorizontal,
|
|
107
|
+
sort: ArrowUpDown,
|
|
108
|
+
search: Search,
|
|
109
|
+
|
|
110
|
+
share: Share2,
|
|
111
|
+
favorite: Heart,
|
|
112
|
+
wantToTry: Bookmark,
|
|
113
|
+
confirm: Check,
|
|
114
|
+
add: Plus,
|
|
115
|
+
remove: Trash2,
|
|
116
|
+
refresh: RefreshCw,
|
|
117
|
+
call: Phone,
|
|
118
|
+
report: Flag,
|
|
119
|
+
info: Info,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Purposes whose glyph must rotate to show state, and by how much.
|
|
124
|
+
* `expand` is the disclosure chevron: pointing down at rest, up when open.
|
|
125
|
+
*/
|
|
126
|
+
export const iconRotation: Partial<Record<IconPurpose, number>> = {
|
|
127
|
+
expand: 180,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Retired glyphs and what replaced them. Kept so a reviewer can tell a
|
|
132
|
+
* deliberate choice from a regression, and so lint/codemods have a source.
|
|
133
|
+
*/
|
|
134
|
+
export const retiredIcons = {
|
|
135
|
+
Filter: "filter → SlidersHorizontal",
|
|
136
|
+
ChevronRightAsSeeAll: "seeAll → ArrowRight",
|
|
137
|
+
ChevronLeftAsBack: "back → ArrowLeft",
|
|
138
|
+
XAsClear: "clear → XCircle",
|
|
139
|
+
} as const;
|
package/src/test/setup.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
2
|
|
|
3
|
-
global
|
|
3
|
+
// `globalThis`, not `global`: the latter is a Node-only global, and this
|
|
4
|
+
// project's `lib` is dom / dom.iterable / esnext with no `@types/node`, so it
|
|
5
|
+
// did not typecheck. This file already reaches for `window` below — the test
|
|
6
|
+
// environment is jsdom, and `globalThis` is the spelling that is typed in both.
|
|
7
|
+
globalThis.ResizeObserver = class ResizeObserver {
|
|
4
8
|
observe() {}
|
|
5
9
|
unobserve() {}
|
|
6
10
|
disconnect() {}
|