banhaten 0.1.0

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.
Files changed (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +361 -0
  3. package/banhaten.config.example.json +13 -0
  4. package/package.json +59 -0
  5. package/registry/assets/activity-feed-avatar.png +0 -0
  6. package/registry/assets/avatars/avatar-01.jpg +0 -0
  7. package/registry/assets/avatars/avatar-02.jpg +0 -0
  8. package/registry/assets/avatars/avatar-03.jpg +0 -0
  9. package/registry/assets/avatars/avatar-04.jpg +0 -0
  10. package/registry/assets/avatars/avatar-05.jpg +0 -0
  11. package/registry/assets/avatars/avatar-06.jpg +0 -0
  12. package/registry/assets/avatars/avatar-07.jpg +0 -0
  13. package/registry/assets/avatars/avatar-08.jpg +0 -0
  14. package/registry/assets/avatars/avatar-09.jpg +0 -0
  15. package/registry/assets/avatars/avatar-10.jpg +0 -0
  16. package/registry/assets/avatars/avatar-11.jpg +0 -0
  17. package/registry/assets/avatars/avatar-12.jpg +0 -0
  18. package/registry/assets/avatars/avatar-13.jpg +0 -0
  19. package/registry/assets/avatars/avatar-14.jpg +0 -0
  20. package/registry/assets/avatars/avatar-15.jpg +0 -0
  21. package/registry/assets/avatars/avatar-16.jpg +0 -0
  22. package/registry/assets/avatars/avatar-17.jpg +0 -0
  23. package/registry/assets/avatars/avatar-18.jpg +0 -0
  24. package/registry/assets/avatars/avatar-19.jpg +0 -0
  25. package/registry/assets/avatars/avatar-20.jpg +0 -0
  26. package/registry/assets/avatars/avatar-21.jpg +0 -0
  27. package/registry/assets/avatars/avatar-22.jpg +0 -0
  28. package/registry/assets/avatars/avatar-23.jpg +0 -0
  29. package/registry/assets/avatars/avatar-24.jpg +0 -0
  30. package/registry/assets/avatars/avatar-25.jpg +0 -0
  31. package/registry/assets/avatars/avatar-26.jpg +0 -0
  32. package/registry/assets/avatars/avatar-27.jpg +0 -0
  33. package/registry/assets/avatars/avatar-28.jpg +0 -0
  34. package/registry/assets/avatars/avatar-29.jpg +0 -0
  35. package/registry/assets/avatars/avatar-30.jpg +0 -0
  36. package/registry/assets/avatars/avatar-31.jpg +0 -0
  37. package/registry/assets/avatars/avatar-32.jpg +0 -0
  38. package/registry/assets/avatars/avatar-33.jpg +0 -0
  39. package/registry/assets/avatars/avatar-34.jpg +0 -0
  40. package/registry/assets/avatars/avatar-35.jpg +0 -0
  41. package/registry/assets/image-assets.json +744 -0
  42. package/registry/assets/images/art-01.jpg +0 -0
  43. package/registry/assets/images/art-02.jpg +0 -0
  44. package/registry/assets/images/art-03.jpg +0 -0
  45. package/registry/assets/images/art-04.jpg +0 -0
  46. package/registry/assets/images/art-05.jpg +0 -0
  47. package/registry/assets/images/art-06.jpg +0 -0
  48. package/registry/assets/images/art-07.jpg +0 -0
  49. package/registry/assets/images/art-08.jpg +0 -0
  50. package/registry/assets/images/art-09.jpg +0 -0
  51. package/registry/assets/images/art-10.jpg +0 -0
  52. package/registry/assets/images/art-11.jpg +0 -0
  53. package/registry/assets/images/art-12.jpg +0 -0
  54. package/registry/assets/images/art-13.jpg +0 -0
  55. package/registry/assets/images/art-14.jpg +0 -0
  56. package/registry/assets/images/art-15.jpg +0 -0
  57. package/registry/assets/images/art-16.jpg +0 -0
  58. package/registry/assets/images/art-17.jpg +0 -0
  59. package/registry/assets/images/art-18.jpg +0 -0
  60. package/registry/assets/images/art-19.jpg +0 -0
  61. package/registry/assets/images/art-20.jpg +0 -0
  62. package/registry/assets/images/art-21.jpg +0 -0
  63. package/registry/assets/images/art-22.jpg +0 -0
  64. package/registry/assets/images/art-23.jpg +0 -0
  65. package/registry/assets/images/art-24.jpg +0 -0
  66. package/registry/assets/images/art-25.jpg +0 -0
  67. package/registry/assets/images/art-26.jpg +0 -0
  68. package/registry/assets/images/art-27.jpg +0 -0
  69. package/registry/assets/images/nature-01.jpg +0 -0
  70. package/registry/assets/images/nature-02.jpg +0 -0
  71. package/registry/assets/images/nature-03.jpg +0 -0
  72. package/registry/assets/images/nature-04.jpg +0 -0
  73. package/registry/assets/images/nature-05.jpg +0 -0
  74. package/registry/assets/images/nature-06.jpg +0 -0
  75. package/registry/assets/images/nature-07.jpg +0 -0
  76. package/registry/assets/images/nature-08.jpg +0 -0
  77. package/registry/assets/images/nature-09.jpg +0 -0
  78. package/registry/assets/images/nature-10.jpg +0 -0
  79. package/registry/assets/images/nature-11.jpg +0 -0
  80. package/registry/assets/images/nature-12.jpg +0 -0
  81. package/registry/assets/images/nature-13.jpg +0 -0
  82. package/registry/assets/images/nature-14.jpg +0 -0
  83. package/registry/assets/images/nature-15.jpg +0 -0
  84. package/registry/assets/images/nature-16.jpg +0 -0
  85. package/registry/assets/images/nature-17.jpg +0 -0
  86. package/registry/assets/images/nature-18.jpg +0 -0
  87. package/registry/assets/images/nature-19.jpg +0 -0
  88. package/registry/assets/images/nature-20.jpg +0 -0
  89. package/registry/components/accordion.tsx +119 -0
  90. package/registry/components/alert.tsx +282 -0
  91. package/registry/components/attribute.tsx +452 -0
  92. package/registry/components/avatar.tsx +142 -0
  93. package/registry/components/badge.tsx +567 -0
  94. package/registry/components/button-group.tsx +246 -0
  95. package/registry/components/button.tsx +102 -0
  96. package/registry/components/card.tsx +613 -0
  97. package/registry/components/checkbox.tsx +244 -0
  98. package/registry/components/date-picker.tsx +1143 -0
  99. package/registry/components/divider.tsx +82 -0
  100. package/registry/components/expanded/ActivityFeed.tsx +226 -0
  101. package/registry/components/expanded/Banner.tsx +145 -0
  102. package/registry/components/expanded/BannerBoard.tsx +225 -0
  103. package/registry/components/expanded/Breadcrumbs.tsx +156 -0
  104. package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
  105. package/registry/components/expanded/CatalogDivider.tsx +48 -0
  106. package/registry/components/expanded/CatalogTag.tsx +92 -0
  107. package/registry/components/expanded/CommandBar.tsx +406 -0
  108. package/registry/components/expanded/FileUpload.tsx +231 -0
  109. package/registry/components/expanded/IconExplorer.tsx +612 -0
  110. package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
  111. package/registry/components/expanded/PageHeader.tsx +184 -0
  112. package/registry/components/expanded/Slideout.tsx +514 -0
  113. package/registry/components/expanded/Steps.tsx +266 -0
  114. package/registry/components/expanded/Table.tsx +1014 -0
  115. package/registry/components/expanded/Tabs.tsx +86 -0
  116. package/registry/components/expanded/Timeline.tsx +235 -0
  117. package/registry/components/expanded/TimelineShowcase.tsx +158 -0
  118. package/registry/components/expanded/activityFeed.css +292 -0
  119. package/registry/components/expanded/banner.css +312 -0
  120. package/registry/components/expanded/breadcrumbs.css +140 -0
  121. package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
  122. package/registry/components/expanded/commandBar.css +473 -0
  123. package/registry/components/expanded/divider.css +75 -0
  124. package/registry/components/expanded/fileUpload.css +228 -0
  125. package/registry/components/expanded/iconExplorer.css +764 -0
  126. package/registry/components/expanded/iconPacks.ts +866 -0
  127. package/registry/components/expanded/onboardingStepListItem.css +126 -0
  128. package/registry/components/expanded/pageHeader.css +287 -0
  129. package/registry/components/expanded/slideout.css +955 -0
  130. package/registry/components/expanded/steps.css +329 -0
  131. package/registry/components/expanded/table.css +607 -0
  132. package/registry/components/expanded/tabs.css +197 -0
  133. package/registry/components/expanded/tag.css +148 -0
  134. package/registry/components/expanded/timeline.css +282 -0
  135. package/registry/components/input-content.ts +106 -0
  136. package/registry/components/input.tsx +866 -0
  137. package/registry/components/menu.tsx +758 -0
  138. package/registry/components/modal.tsx +799 -0
  139. package/registry/components/pagination.tsx +543 -0
  140. package/registry/components/progress-slider.tsx +216 -0
  141. package/registry/components/progress.tsx +367 -0
  142. package/registry/components/radio-card.tsx +654 -0
  143. package/registry/components/radio-group.tsx +570 -0
  144. package/registry/components/select-content.tsx +313 -0
  145. package/registry/components/select.tsx +871 -0
  146. package/registry/components/slider.tsx +380 -0
  147. package/registry/components/social-button.tsx +360 -0
  148. package/registry/components/spinner.tsx +31 -0
  149. package/registry/components/tag.tsx +423 -0
  150. package/registry/components/textarea.tsx +625 -0
  151. package/registry/components/toggle.tsx +272 -0
  152. package/registry/components/toolbar.tsx +467 -0
  153. package/registry/components/tooltip.tsx +427 -0
  154. package/registry/examples/accordion-demo.tsx +34 -0
  155. package/registry/examples/alert-demo.tsx +14 -0
  156. package/registry/examples/attribute-demo.tsx +65 -0
  157. package/registry/examples/avatar-demo.tsx +74 -0
  158. package/registry/examples/badge-demo.tsx +53 -0
  159. package/registry/examples/button-demo.tsx +83 -0
  160. package/registry/examples/button-group-demo.tsx +42 -0
  161. package/registry/examples/card-demo.tsx +48 -0
  162. package/registry/examples/checkbox-demo.tsx +67 -0
  163. package/registry/examples/date-picker-demo.tsx +74 -0
  164. package/registry/examples/divider-demo.tsx +17 -0
  165. package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
  166. package/registry/examples/expanded/banner-demo.tsx +23 -0
  167. package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
  168. package/registry/examples/expanded/command-bar-demo.tsx +10 -0
  169. package/registry/examples/expanded/icons-demo.tsx +5 -0
  170. package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
  171. package/registry/examples/expanded/page-header-demo.tsx +19 -0
  172. package/registry/examples/expanded/slideout-demo.tsx +15 -0
  173. package/registry/examples/expanded/steps-demo.tsx +18 -0
  174. package/registry/examples/expanded/tabs-demo.tsx +13 -0
  175. package/registry/examples/expanded/timeline-demo.tsx +18 -0
  176. package/registry/examples/input-demo.tsx +87 -0
  177. package/registry/examples/menu-demo.tsx +109 -0
  178. package/registry/examples/modal-demo.tsx +16 -0
  179. package/registry/examples/pagination-demo.tsx +17 -0
  180. package/registry/examples/progress-demo.tsx +37 -0
  181. package/registry/examples/progress-slider-demo.tsx +29 -0
  182. package/registry/examples/radio-card-demo.tsx +51 -0
  183. package/registry/examples/radio-group-demo.tsx +62 -0
  184. package/registry/examples/select-demo.tsx +73 -0
  185. package/registry/examples/slider-demo.tsx +31 -0
  186. package/registry/examples/social-button-demo.tsx +51 -0
  187. package/registry/examples/tag-demo.tsx +29 -0
  188. package/registry/examples/textarea-demo.tsx +79 -0
  189. package/registry/examples/toggle-demo.tsx +59 -0
  190. package/registry/examples/toolbar-demo.tsx +80 -0
  191. package/registry/examples/tooltip-demo.tsx +115 -0
  192. package/registry/hooks/use-direction.ts +27 -0
  193. package/registry/index.json +1213 -0
  194. package/registry/styles/globals.css +4600 -0
  195. package/registry/utils/cn.ts +6 -0
  196. package/src/cli/index.js +826 -0
  197. package/tokens/Color mode.zip +0 -0
  198. package/tokens/Numbers.zip +0 -0
  199. package/tokens/Radius.zip +0 -0
  200. package/tokens/Theme.zip +0 -0
  201. package/tokens/banhaten.tokens.json +5525 -0
@@ -0,0 +1,92 @@
1
+ import type { ReactNode } from "react";
2
+ import "./tag.css";
3
+
4
+ export type TagType = "simple" | "dot" | "flag" | "avatar" | "icon";
5
+ export type TagSize = "xs" | "md" | "lg";
6
+ export type TagState = "default" | "active" | "disabled";
7
+
8
+ export type CatalogTagType = TagType;
9
+ export type CatalogTagSize = TagSize;
10
+ export type CatalogTagState = TagState;
11
+
12
+ export type CatalogTagProps = {
13
+ avatar?: ReactNode;
14
+ children?: ReactNode;
15
+ closeLabel?: string;
16
+ dir?: "ltr" | "rtl" | "auto";
17
+ disabled?: boolean;
18
+ flag?: ReactNode;
19
+ icon?: ReactNode;
20
+ onClose?: () => void;
21
+ showCloseButton?: boolean;
22
+ size?: TagSize;
23
+ state?: TagState;
24
+ type?: TagType;
25
+ };
26
+
27
+ function cx(...classes: Array<string | false | undefined>) {
28
+ return classes.filter(Boolean).join(" ");
29
+ }
30
+
31
+ export function CatalogTag({
32
+ avatar,
33
+ children,
34
+ closeLabel,
35
+ dir = "ltr",
36
+ disabled = false,
37
+ flag,
38
+ icon,
39
+ onClose,
40
+ showCloseButton = false,
41
+ size = "md",
42
+ state = "default",
43
+ type = "simple",
44
+ }: CatalogTagProps) {
45
+ const isDisabled = disabled || state === "disabled";
46
+ const hasLeadingSlot = type !== "simple";
47
+
48
+ return (
49
+ <span
50
+ aria-disabled={isDisabled || undefined}
51
+ className={cx(
52
+ "ds-tag",
53
+ `ds-tag--${type}`,
54
+ `ds-tag--${size}`,
55
+ `ds-tag--${state}`,
56
+ showCloseButton && "ds-tag--closeable",
57
+ )}
58
+ dir={dir}
59
+ >
60
+ {hasLeadingSlot && (
61
+ <span aria-hidden="true" className="ds-tag__leading">
62
+ {type === "dot" && <span className="ds-tag__dot" />}
63
+ {type === "flag" && (flag ?? <span className="ds-tag__flag" />)}
64
+ {type === "avatar" && avatar}
65
+ {type === "icon" && (icon ?? <PlusIcon />)}
66
+ </span>
67
+ )}
68
+ <span className="ds-tag__label">{children}</span>
69
+ {showCloseButton && (
70
+ <button aria-label={closeLabel} className="ds-tag__close" disabled={isDisabled} onClick={onClose} type="button">
71
+ <CloseIcon />
72
+ </button>
73
+ )}
74
+ </span>
75
+ );
76
+ }
77
+
78
+ function PlusIcon() {
79
+ return (
80
+ <svg aria-hidden="true" viewBox="0 0 16 16">
81
+ <path d="M8 3.5v9M3.5 8h9" fill="none" stroke="currentColor" strokeLinecap="round" strokeWidth="1.7" />
82
+ </svg>
83
+ );
84
+ }
85
+
86
+ function CloseIcon() {
87
+ return (
88
+ <svg aria-hidden="true" viewBox="0 0 16 16">
89
+ <path d="m4.5 4.5 7 7M11.5 4.5l-7 7" fill="none" stroke="currentColor" strokeLinecap="round" strokeWidth="1.6" />
90
+ </svg>
91
+ );
92
+ }
@@ -0,0 +1,406 @@
1
+ import "./commandBar.css";
2
+
3
+ export type CommandBarType = "default" | "recent" | "results" | "no-result";
4
+ export type CommandBarBreakpoint = "desktop" | "mobile";
5
+
6
+ export type CommandBarProps = {
7
+ breakpoint?: CommandBarBreakpoint;
8
+ className?: string;
9
+ dir?: "ltr" | "rtl";
10
+ nodeId?: string;
11
+ type?: CommandBarType;
12
+ };
13
+
14
+ type CommandBarCopy = {
15
+ clear: string;
16
+ commands: string;
17
+ description: string;
18
+ navigate: string;
19
+ noResults: string;
20
+ open: string;
21
+ placeholder: string;
22
+ recent: string;
23
+ results: string;
24
+ searchFor: string;
25
+ searchText: string;
26
+ tags: string[];
27
+ title: string;
28
+ tryDifferent: string;
29
+ };
30
+
31
+ type CommandRow = {
32
+ readonly highlighted?: boolean;
33
+ readonly shortcut?: boolean;
34
+ readonly visual: "avatar" | "icon";
35
+ };
36
+
37
+ const shortcutText = "\u2318K";
38
+
39
+ const ltrCopy: CommandBarCopy = {
40
+ clear: "Clear search",
41
+ commands: "Commands",
42
+ description: "Item description",
43
+ navigate: "Navigate",
44
+ noResults: "No results found",
45
+ open: "Open",
46
+ placeholder: "Search or type a command",
47
+ recent: "Recent",
48
+ results: "Results",
49
+ searchFor: "Search for",
50
+ searchText: "Search Text",
51
+ tags: ["All", "Tasks", "People", "Files", "Docs", "Comments"],
52
+ title: "Title",
53
+ tryDifferent: "Try using different keywords",
54
+ };
55
+
56
+ const rtlCopy: CommandBarCopy = {
57
+ clear: "\u0645\u0633\u062d \u0627\u0644\u0628\u062d\u062b",
58
+ commands: "\u0627\u0644\u0623\u0648\u0627\u0645\u0631",
59
+ description: "\u0627\u0644\u0646\u0635 \u0627\u0644\u062b\u0627\u0646\u0648\u064a",
60
+ navigate: "\u062a\u0646\u0642\u0644",
61
+ noResults:
62
+ "\u0644\u0645 \u064a\u062a\u0645 \u0627\u0644\u0639\u062b\u0648\u0631 \u0639\u0644\u0649 \u0646\u062a\u0627\u0626\u062c",
63
+ open: "\u0641\u062a\u062d",
64
+ placeholder:
65
+ "\u0627\u0628\u062d\u062b \u0623\u0648 \u0627\u0643\u062a\u0628 \u0623\u0645\u0631\u064b\u0627",
66
+ recent: "\u0627\u0644\u0623\u062e\u064a\u0631\u0629",
67
+ results: "\u0627\u0644\u0646\u062a\u0627\u0626\u062c",
68
+ searchFor: "\u0627\u0628\u062d\u062b \u0639\u0646",
69
+ searchText: "\u0646\u0635 \u0627\u0644\u0628\u062d\u062b",
70
+ tags: [
71
+ "\u0627\u0644\u0643\u0644",
72
+ "\u0627\u0644\u0645\u0647\u0627\u0645",
73
+ "\u0627\u0644\u0623\u0634\u062e\u0627\u0635",
74
+ "\u0627\u0644\u0645\u0644\u0641\u0627\u062a",
75
+ "\u0627\u0644\u0645\u0633\u062a\u0646\u062f\u0627\u062a",
76
+ "\u0627\u0644\u062a\u0639\u0644\u064a\u0642\u0627\u062a",
77
+ ],
78
+ title: "\u0627\u0644\u0639\u0646\u0648\u0627\u0646",
79
+ tryDifferent:
80
+ "\u062c\u0631\u0628 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0643\u0644\u0645\u0627\u062a \u0645\u062e\u062a\u0644\u0641\u0629",
81
+ };
82
+
83
+ const recentRows = [
84
+ { visual: "icon", shortcut: true },
85
+ { visual: "avatar" },
86
+ { visual: "icon", shortcut: true, highlighted: true },
87
+ { visual: "icon", shortcut: true },
88
+ { visual: "icon", shortcut: true },
89
+ ] as const;
90
+
91
+ const commandRows = [
92
+ { visual: "icon", shortcut: true },
93
+ { visual: "icon", shortcut: true },
94
+ { visual: "icon", shortcut: true },
95
+ { visual: "icon", shortcut: true },
96
+ { visual: "icon", shortcut: true },
97
+ { visual: "icon", shortcut: true },
98
+ ] as const;
99
+
100
+ const resultRows = [
101
+ { visual: "icon", shortcut: true },
102
+ { visual: "avatar" },
103
+ { visual: "icon", shortcut: true, highlighted: true },
104
+ { visual: "icon", shortcut: true },
105
+ { visual: "icon", shortcut: true },
106
+ { visual: "avatar" },
107
+ { visual: "icon", shortcut: true },
108
+ { visual: "icon", shortcut: true },
109
+ { visual: "icon", shortcut: true },
110
+ ] as const;
111
+
112
+ export function CommandBar({
113
+ breakpoint = "desktop",
114
+ className = "",
115
+ dir = "ltr",
116
+ nodeId,
117
+ type = "default",
118
+ }: CommandBarProps) {
119
+ const rtl = dir === "rtl";
120
+ const copy = rtl ? rtlCopy : ltrCopy;
121
+ const filled = type === "results" || type === "no-result";
122
+ const hasPanel = type !== "default";
123
+ const hasFooter = breakpoint === "desktop" && (type === "recent" || type === "results");
124
+
125
+ return (
126
+ <section
127
+ aria-label="Command bar"
128
+ className={[
129
+ "ds-command-bar",
130
+ `ds-command-bar--${breakpoint}`,
131
+ `ds-command-bar--${type}`,
132
+ rtl ? "ds-command-bar--rtl" : "ds-command-bar--ltr",
133
+ className,
134
+ ]
135
+ .filter(Boolean)
136
+ .join(" ")}
137
+ data-node-id={nodeId}
138
+ dir={dir}
139
+ >
140
+ <div className={breakpoint === "mobile" ? "ds-command-bar__input-wrap" : undefined}>
141
+ <SearchInput
142
+ breakpoint={breakpoint}
143
+ copy={copy}
144
+ filled={filled}
145
+ hasDivider={hasPanel && breakpoint === "desktop"}
146
+ />
147
+ </div>
148
+
149
+ {type === "recent" && <RecentPanel copy={copy} />}
150
+ {type === "results" && <ResultsPanel copy={copy} />}
151
+ {type === "no-result" && <EmptyPanel copy={copy} />}
152
+ {hasFooter && <CommandFooter copy={copy} />}
153
+ </section>
154
+ );
155
+ }
156
+
157
+ function SearchInput({
158
+ breakpoint,
159
+ copy,
160
+ filled,
161
+ hasDivider,
162
+ }: {
163
+ breakpoint: CommandBarBreakpoint;
164
+ copy: CommandBarCopy;
165
+ filled: boolean;
166
+ hasDivider: boolean;
167
+ }) {
168
+ const className = [
169
+ "ds-command-bar__search",
170
+ filled ? "ds-command-bar__search--filled" : "ds-command-bar__search--default",
171
+ hasDivider ? "ds-command-bar__search--divider" : "",
172
+ ]
173
+ .filter(Boolean)
174
+ .join(" ");
175
+ const iconSize = breakpoint === "mobile" ? 20 : 24;
176
+ const content = (
177
+ <>
178
+ <span className="ds-command-bar__search-content">
179
+ <SearchIcon size={iconSize} />
180
+ <span className={filled ? "ds-command-bar__search-text" : "ds-command-bar__placeholder"}>
181
+ {filled ? copy.searchText : copy.placeholder}
182
+ </span>
183
+ </span>
184
+ {filled ? (
185
+ <button aria-label={copy.clear} className="ds-command-bar__close" type="button">
186
+ <CloseIcon />
187
+ </button>
188
+ ) : (
189
+ breakpoint === "desktop" && <Shortcut />
190
+ )}
191
+ </>
192
+ );
193
+
194
+ if (filled) {
195
+ return (
196
+ <div className={className} role="search">
197
+ {content}
198
+ </div>
199
+ );
200
+ }
201
+
202
+ return (
203
+ <button className={className} type="button">
204
+ {content}
205
+ </button>
206
+ );
207
+ }
208
+
209
+ function RecentPanel({ copy }: { copy: CommandBarCopy }) {
210
+ return (
211
+ <div className="ds-command-bar__content">
212
+ <div className="ds-command-bar__main">
213
+ <CommandSection copy={copy} items={recentRows} label={copy.recent} />
214
+ <CommandSection copy={copy} items={commandRows} label={copy.commands} />
215
+ </div>
216
+ </div>
217
+ );
218
+ }
219
+
220
+ function ResultsPanel({ copy }: { copy: CommandBarCopy }) {
221
+ return (
222
+ <div className="ds-command-bar__content">
223
+ <div className="ds-command-bar__main">
224
+ <FilterSection copy={copy} />
225
+ <CommandSection copy={copy} items={resultRows} label={copy.results} />
226
+ </div>
227
+ </div>
228
+ );
229
+ }
230
+
231
+ function EmptyPanel({ copy }: { copy: CommandBarCopy }) {
232
+ return (
233
+ <div className="ds-command-bar__empty">
234
+ <div className="ds-command-bar__empty-wrap">
235
+ <span className="ds-command-bar__empty-icon">
236
+ <SearchIcon size={24} />
237
+ </span>
238
+ <strong>{copy.noResults}</strong>
239
+ <span>{copy.tryDifferent}</span>
240
+ </div>
241
+ </div>
242
+ );
243
+ }
244
+
245
+ function FilterSection({ copy }: { copy: CommandBarCopy }) {
246
+ return (
247
+ <div className="ds-command-bar__filter">
248
+ <SectionHeading>{copy.searchFor}</SectionHeading>
249
+ <div className="ds-command-bar__tags" aria-label={copy.searchFor}>
250
+ {copy.tags.map((tag) => (
251
+ <button className="ds-command-bar__tag" key={tag} type="button">
252
+ {tag}
253
+ </button>
254
+ ))}
255
+ </div>
256
+ </div>
257
+ );
258
+ }
259
+
260
+ function CommandSection({
261
+ copy,
262
+ items,
263
+ label,
264
+ }: {
265
+ copy: CommandBarCopy;
266
+ items: ReadonlyArray<CommandRow>;
267
+ label: string;
268
+ }) {
269
+ return (
270
+ <div className="ds-command-bar__section">
271
+ <SectionHeading>{label}</SectionHeading>
272
+ <div className="ds-command-bar__group">
273
+ {items.map((item, index) => (
274
+ <CommandItem copy={copy} item={item} key={`${label}-${index}`} />
275
+ ))}
276
+ </div>
277
+ </div>
278
+ );
279
+ }
280
+
281
+ function SectionHeading({ children }: { children: string }) {
282
+ return (
283
+ <div className="ds-command-bar__section-heading">
284
+ <span>{children}</span>
285
+ </div>
286
+ );
287
+ }
288
+
289
+ function CommandItem({
290
+ copy,
291
+ item,
292
+ }: {
293
+ copy: CommandBarCopy;
294
+ item: CommandRow;
295
+ }) {
296
+ return (
297
+ <button
298
+ className={["ds-command-bar__item", item.highlighted ? "is-highlighted" : ""].filter(Boolean).join(" ")}
299
+ type="button"
300
+ >
301
+ {item.visual === "avatar" ? <Avatar /> : <IconWrap />}
302
+ <span className="ds-command-bar__item-copy">
303
+ <strong>{copy.title}</strong>
304
+ <span>{copy.description}</span>
305
+ </span>
306
+ {item.shortcut && <Shortcut />}
307
+ </button>
308
+ );
309
+ }
310
+
311
+ function CommandFooter({ copy }: { copy: CommandBarCopy }) {
312
+ return (
313
+ <footer className="ds-command-bar__footer">
314
+ <span className="ds-command-bar__footer-content">
315
+ <span className="ds-command-bar__footer-hint">
316
+ <ArrowUpDownIcon />
317
+ <span>{copy.navigate}</span>
318
+ </span>
319
+ <span className="ds-command-bar__footer-hint">
320
+ <EnterIcon />
321
+ <span>{copy.open}</span>
322
+ </span>
323
+ </span>
324
+ </footer>
325
+ );
326
+ }
327
+
328
+ function Shortcut() {
329
+ return <kbd className="ds-command-bar__shortcut">{shortcutText}</kbd>;
330
+ }
331
+
332
+ function IconWrap() {
333
+ return (
334
+ <span className="ds-command-bar__icon-wrap">
335
+ <BookIcon />
336
+ </span>
337
+ );
338
+ }
339
+
340
+ function Avatar() {
341
+ return <span aria-hidden="true" className="ds-command-bar__avatar" />;
342
+ }
343
+
344
+ function SearchIcon({ size = 24 }: { size?: number }) {
345
+ return (
346
+ <svg aria-hidden="true" fill="none" height={size} viewBox="0 0 24 24" width={size}>
347
+ <path
348
+ d="M10.75 18.5a7.75 7.75 0 1 1 5.48-2.27l3.02 3.02"
349
+ stroke="currentColor"
350
+ strokeLinecap="round"
351
+ strokeLinejoin="round"
352
+ strokeWidth="2"
353
+ />
354
+ </svg>
355
+ );
356
+ }
357
+
358
+ function CloseIcon() {
359
+ return (
360
+ <svg aria-hidden="true" fill="none" height="20" viewBox="0 0 20 20" width="20">
361
+ <path d="m5 5 10 10M15 5 5 15" stroke="currentColor" strokeLinecap="round" strokeWidth="1.8" />
362
+ </svg>
363
+ );
364
+ }
365
+
366
+ function BookIcon() {
367
+ return (
368
+ <svg aria-hidden="true" fill="none" height="20" viewBox="0 0 20 20" width="20">
369
+ <path
370
+ d="M5.5 3.5h8.2c.9 0 1.6.7 1.6 1.6v10.4H6.2a1.5 1.5 0 0 0 0 3h9.1M5.5 3.5a2 2 0 0 0-2 2v11a2 2 0 0 1 2-2m0-11v11m2.4-7.8h4.8"
371
+ stroke="currentColor"
372
+ strokeLinecap="round"
373
+ strokeLinejoin="round"
374
+ strokeWidth="1.6"
375
+ />
376
+ </svg>
377
+ );
378
+ }
379
+
380
+ function ArrowUpDownIcon() {
381
+ return (
382
+ <svg aria-hidden="true" fill="none" height="16" viewBox="0 0 16 16" width="16">
383
+ <path
384
+ d="M5 2v12m0 0 2.5-2.5M5 14l-2.5-2.5M11 14V2m0 0 2.5 2.5M11 2 8.5 4.5"
385
+ stroke="currentColor"
386
+ strokeLinecap="round"
387
+ strokeLinejoin="round"
388
+ strokeWidth="1.45"
389
+ />
390
+ </svg>
391
+ );
392
+ }
393
+
394
+ function EnterIcon() {
395
+ return (
396
+ <svg aria-hidden="true" fill="none" height="16" viewBox="0 0 16 16" width="16">
397
+ <path
398
+ d="M12.5 3.5v3.25a3 3 0 0 1-3 3H3.75m0 0L6.2 7.3M3.75 9.75 6.2 12.2"
399
+ stroke="currentColor"
400
+ strokeLinecap="round"
401
+ strokeLinejoin="round"
402
+ strokeWidth="1.45"
403
+ />
404
+ </svg>
405
+ );
406
+ }