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.
- package/LICENSE +21 -0
- package/README.md +361 -0
- package/banhaten.config.example.json +13 -0
- package/package.json +59 -0
- package/registry/assets/activity-feed-avatar.png +0 -0
- package/registry/assets/avatars/avatar-01.jpg +0 -0
- package/registry/assets/avatars/avatar-02.jpg +0 -0
- package/registry/assets/avatars/avatar-03.jpg +0 -0
- package/registry/assets/avatars/avatar-04.jpg +0 -0
- package/registry/assets/avatars/avatar-05.jpg +0 -0
- package/registry/assets/avatars/avatar-06.jpg +0 -0
- package/registry/assets/avatars/avatar-07.jpg +0 -0
- package/registry/assets/avatars/avatar-08.jpg +0 -0
- package/registry/assets/avatars/avatar-09.jpg +0 -0
- package/registry/assets/avatars/avatar-10.jpg +0 -0
- package/registry/assets/avatars/avatar-11.jpg +0 -0
- package/registry/assets/avatars/avatar-12.jpg +0 -0
- package/registry/assets/avatars/avatar-13.jpg +0 -0
- package/registry/assets/avatars/avatar-14.jpg +0 -0
- package/registry/assets/avatars/avatar-15.jpg +0 -0
- package/registry/assets/avatars/avatar-16.jpg +0 -0
- package/registry/assets/avatars/avatar-17.jpg +0 -0
- package/registry/assets/avatars/avatar-18.jpg +0 -0
- package/registry/assets/avatars/avatar-19.jpg +0 -0
- package/registry/assets/avatars/avatar-20.jpg +0 -0
- package/registry/assets/avatars/avatar-21.jpg +0 -0
- package/registry/assets/avatars/avatar-22.jpg +0 -0
- package/registry/assets/avatars/avatar-23.jpg +0 -0
- package/registry/assets/avatars/avatar-24.jpg +0 -0
- package/registry/assets/avatars/avatar-25.jpg +0 -0
- package/registry/assets/avatars/avatar-26.jpg +0 -0
- package/registry/assets/avatars/avatar-27.jpg +0 -0
- package/registry/assets/avatars/avatar-28.jpg +0 -0
- package/registry/assets/avatars/avatar-29.jpg +0 -0
- package/registry/assets/avatars/avatar-30.jpg +0 -0
- package/registry/assets/avatars/avatar-31.jpg +0 -0
- package/registry/assets/avatars/avatar-32.jpg +0 -0
- package/registry/assets/avatars/avatar-33.jpg +0 -0
- package/registry/assets/avatars/avatar-34.jpg +0 -0
- package/registry/assets/avatars/avatar-35.jpg +0 -0
- package/registry/assets/image-assets.json +744 -0
- package/registry/assets/images/art-01.jpg +0 -0
- package/registry/assets/images/art-02.jpg +0 -0
- package/registry/assets/images/art-03.jpg +0 -0
- package/registry/assets/images/art-04.jpg +0 -0
- package/registry/assets/images/art-05.jpg +0 -0
- package/registry/assets/images/art-06.jpg +0 -0
- package/registry/assets/images/art-07.jpg +0 -0
- package/registry/assets/images/art-08.jpg +0 -0
- package/registry/assets/images/art-09.jpg +0 -0
- package/registry/assets/images/art-10.jpg +0 -0
- package/registry/assets/images/art-11.jpg +0 -0
- package/registry/assets/images/art-12.jpg +0 -0
- package/registry/assets/images/art-13.jpg +0 -0
- package/registry/assets/images/art-14.jpg +0 -0
- package/registry/assets/images/art-15.jpg +0 -0
- package/registry/assets/images/art-16.jpg +0 -0
- package/registry/assets/images/art-17.jpg +0 -0
- package/registry/assets/images/art-18.jpg +0 -0
- package/registry/assets/images/art-19.jpg +0 -0
- package/registry/assets/images/art-20.jpg +0 -0
- package/registry/assets/images/art-21.jpg +0 -0
- package/registry/assets/images/art-22.jpg +0 -0
- package/registry/assets/images/art-23.jpg +0 -0
- package/registry/assets/images/art-24.jpg +0 -0
- package/registry/assets/images/art-25.jpg +0 -0
- package/registry/assets/images/art-26.jpg +0 -0
- package/registry/assets/images/art-27.jpg +0 -0
- package/registry/assets/images/nature-01.jpg +0 -0
- package/registry/assets/images/nature-02.jpg +0 -0
- package/registry/assets/images/nature-03.jpg +0 -0
- package/registry/assets/images/nature-04.jpg +0 -0
- package/registry/assets/images/nature-05.jpg +0 -0
- package/registry/assets/images/nature-06.jpg +0 -0
- package/registry/assets/images/nature-07.jpg +0 -0
- package/registry/assets/images/nature-08.jpg +0 -0
- package/registry/assets/images/nature-09.jpg +0 -0
- package/registry/assets/images/nature-10.jpg +0 -0
- package/registry/assets/images/nature-11.jpg +0 -0
- package/registry/assets/images/nature-12.jpg +0 -0
- package/registry/assets/images/nature-13.jpg +0 -0
- package/registry/assets/images/nature-14.jpg +0 -0
- package/registry/assets/images/nature-15.jpg +0 -0
- package/registry/assets/images/nature-16.jpg +0 -0
- package/registry/assets/images/nature-17.jpg +0 -0
- package/registry/assets/images/nature-18.jpg +0 -0
- package/registry/assets/images/nature-19.jpg +0 -0
- package/registry/assets/images/nature-20.jpg +0 -0
- package/registry/components/accordion.tsx +119 -0
- package/registry/components/alert.tsx +282 -0
- package/registry/components/attribute.tsx +452 -0
- package/registry/components/avatar.tsx +142 -0
- package/registry/components/badge.tsx +567 -0
- package/registry/components/button-group.tsx +246 -0
- package/registry/components/button.tsx +102 -0
- package/registry/components/card.tsx +613 -0
- package/registry/components/checkbox.tsx +244 -0
- package/registry/components/date-picker.tsx +1143 -0
- package/registry/components/divider.tsx +82 -0
- package/registry/components/expanded/ActivityFeed.tsx +226 -0
- package/registry/components/expanded/Banner.tsx +145 -0
- package/registry/components/expanded/BannerBoard.tsx +225 -0
- package/registry/components/expanded/Breadcrumbs.tsx +156 -0
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
- package/registry/components/expanded/CatalogDivider.tsx +48 -0
- package/registry/components/expanded/CatalogTag.tsx +92 -0
- package/registry/components/expanded/CommandBar.tsx +406 -0
- package/registry/components/expanded/FileUpload.tsx +231 -0
- package/registry/components/expanded/IconExplorer.tsx +612 -0
- package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
- package/registry/components/expanded/PageHeader.tsx +184 -0
- package/registry/components/expanded/Slideout.tsx +514 -0
- package/registry/components/expanded/Steps.tsx +266 -0
- package/registry/components/expanded/Table.tsx +1014 -0
- package/registry/components/expanded/Tabs.tsx +86 -0
- package/registry/components/expanded/Timeline.tsx +235 -0
- package/registry/components/expanded/TimelineShowcase.tsx +158 -0
- package/registry/components/expanded/activityFeed.css +292 -0
- package/registry/components/expanded/banner.css +312 -0
- package/registry/components/expanded/breadcrumbs.css +140 -0
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
- package/registry/components/expanded/commandBar.css +473 -0
- package/registry/components/expanded/divider.css +75 -0
- package/registry/components/expanded/fileUpload.css +228 -0
- package/registry/components/expanded/iconExplorer.css +764 -0
- package/registry/components/expanded/iconPacks.ts +866 -0
- package/registry/components/expanded/onboardingStepListItem.css +126 -0
- package/registry/components/expanded/pageHeader.css +287 -0
- package/registry/components/expanded/slideout.css +955 -0
- package/registry/components/expanded/steps.css +329 -0
- package/registry/components/expanded/table.css +607 -0
- package/registry/components/expanded/tabs.css +197 -0
- package/registry/components/expanded/tag.css +148 -0
- package/registry/components/expanded/timeline.css +282 -0
- package/registry/components/input-content.ts +106 -0
- package/registry/components/input.tsx +866 -0
- package/registry/components/menu.tsx +758 -0
- package/registry/components/modal.tsx +799 -0
- package/registry/components/pagination.tsx +543 -0
- package/registry/components/progress-slider.tsx +216 -0
- package/registry/components/progress.tsx +367 -0
- package/registry/components/radio-card.tsx +654 -0
- package/registry/components/radio-group.tsx +570 -0
- package/registry/components/select-content.tsx +313 -0
- package/registry/components/select.tsx +871 -0
- package/registry/components/slider.tsx +380 -0
- package/registry/components/social-button.tsx +360 -0
- package/registry/components/spinner.tsx +31 -0
- package/registry/components/tag.tsx +423 -0
- package/registry/components/textarea.tsx +625 -0
- package/registry/components/toggle.tsx +272 -0
- package/registry/components/toolbar.tsx +467 -0
- package/registry/components/tooltip.tsx +427 -0
- package/registry/examples/accordion-demo.tsx +34 -0
- package/registry/examples/alert-demo.tsx +14 -0
- package/registry/examples/attribute-demo.tsx +65 -0
- package/registry/examples/avatar-demo.tsx +74 -0
- package/registry/examples/badge-demo.tsx +53 -0
- package/registry/examples/button-demo.tsx +83 -0
- package/registry/examples/button-group-demo.tsx +42 -0
- package/registry/examples/card-demo.tsx +48 -0
- package/registry/examples/checkbox-demo.tsx +67 -0
- package/registry/examples/date-picker-demo.tsx +74 -0
- package/registry/examples/divider-demo.tsx +17 -0
- package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
- package/registry/examples/expanded/banner-demo.tsx +23 -0
- package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
- package/registry/examples/expanded/command-bar-demo.tsx +10 -0
- package/registry/examples/expanded/icons-demo.tsx +5 -0
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
- package/registry/examples/expanded/page-header-demo.tsx +19 -0
- package/registry/examples/expanded/slideout-demo.tsx +15 -0
- package/registry/examples/expanded/steps-demo.tsx +18 -0
- package/registry/examples/expanded/tabs-demo.tsx +13 -0
- package/registry/examples/expanded/timeline-demo.tsx +18 -0
- package/registry/examples/input-demo.tsx +87 -0
- package/registry/examples/menu-demo.tsx +109 -0
- package/registry/examples/modal-demo.tsx +16 -0
- package/registry/examples/pagination-demo.tsx +17 -0
- package/registry/examples/progress-demo.tsx +37 -0
- package/registry/examples/progress-slider-demo.tsx +29 -0
- package/registry/examples/radio-card-demo.tsx +51 -0
- package/registry/examples/radio-group-demo.tsx +62 -0
- package/registry/examples/select-demo.tsx +73 -0
- package/registry/examples/slider-demo.tsx +31 -0
- package/registry/examples/social-button-demo.tsx +51 -0
- package/registry/examples/tag-demo.tsx +29 -0
- package/registry/examples/textarea-demo.tsx +79 -0
- package/registry/examples/toggle-demo.tsx +59 -0
- package/registry/examples/toolbar-demo.tsx +80 -0
- package/registry/examples/tooltip-demo.tsx +115 -0
- package/registry/hooks/use-direction.ts +27 -0
- package/registry/index.json +1213 -0
- package/registry/styles/globals.css +4600 -0
- package/registry/utils/cn.ts +6 -0
- package/src/cli/index.js +826 -0
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
- 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
|
+
}
|