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,82 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
const dividerVariants = cva("shrink-0 border-0 p-0", {
|
|
7
|
+
variants: {
|
|
8
|
+
direction: {
|
|
9
|
+
horizontal:
|
|
10
|
+
"h-[var(--bh-space-xxxs-1)] w-[var(--bh-space-15xl-224)]",
|
|
11
|
+
vertical:
|
|
12
|
+
"h-[var(--bh-space-15xl-224)] w-[var(--bh-space-xxxs-1)]",
|
|
13
|
+
},
|
|
14
|
+
type: {
|
|
15
|
+
solid: "bg-[var(--bh-border-subtle)]",
|
|
16
|
+
dotted: "bg-transparent",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
direction: "horizontal",
|
|
21
|
+
type: "solid",
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
type DividerDirection = NonNullable<
|
|
26
|
+
VariantProps<typeof dividerVariants>["direction"]
|
|
27
|
+
>
|
|
28
|
+
type DividerType = NonNullable<VariantProps<typeof dividerVariants>["type"]>
|
|
29
|
+
|
|
30
|
+
type DividerProps = React.ComponentProps<"div"> &
|
|
31
|
+
VariantProps<typeof dividerVariants> & {
|
|
32
|
+
decorative?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Divider({
|
|
36
|
+
className,
|
|
37
|
+
direction = "horizontal",
|
|
38
|
+
type = "solid",
|
|
39
|
+
decorative = false,
|
|
40
|
+
role,
|
|
41
|
+
style,
|
|
42
|
+
"aria-hidden": ariaHidden,
|
|
43
|
+
...props
|
|
44
|
+
}: DividerProps) {
|
|
45
|
+
const selectedDirection = direction || "horizontal"
|
|
46
|
+
const selectedType = type || "solid"
|
|
47
|
+
const dottedStyle =
|
|
48
|
+
selectedType === "dotted"
|
|
49
|
+
? getDottedDividerStyle(selectedDirection)
|
|
50
|
+
: undefined
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
aria-hidden={decorative ? true : ariaHidden}
|
|
55
|
+
aria-orientation={decorative ? undefined : selectedDirection}
|
|
56
|
+
data-direction={selectedDirection}
|
|
57
|
+
data-slot="divider"
|
|
58
|
+
data-type={selectedType}
|
|
59
|
+
role={decorative ? "presentation" : role || "separator"}
|
|
60
|
+
style={{ ...dottedStyle, ...style }}
|
|
61
|
+
className={cn(
|
|
62
|
+
dividerVariants({
|
|
63
|
+
direction: selectedDirection,
|
|
64
|
+
type: selectedType,
|
|
65
|
+
className,
|
|
66
|
+
})
|
|
67
|
+
)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getDottedDividerStyle(direction: DividerDirection): React.CSSProperties {
|
|
74
|
+
const axis = direction === "vertical" ? "bottom" : "right"
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
backgroundImage: `repeating-linear-gradient(to ${axis}, var(--bh-border-subtle) 0 var(--bh-space-xxs-2), transparent var(--bh-space-xxs-2) calc(var(--bh-space-xxs-2) + var(--bh-space-xxs-2)))`,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { Divider, dividerVariants }
|
|
82
|
+
export type { DividerDirection, DividerProps, DividerType }
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./activityFeed.css";
|
|
3
|
+
|
|
4
|
+
const defaultAvatarSrc = new URL("../assets/activity-feed-avatar.png", import.meta.url).href;
|
|
5
|
+
|
|
6
|
+
export type ActivityFeedItemType = "caption" | "slot";
|
|
7
|
+
export type ActivityFeedActionVariant = "primary" | "secondary";
|
|
8
|
+
|
|
9
|
+
export type ActivityFeedAction = {
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
href?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
variant?: ActivityFeedActionVariant;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ActivityFeedItemProps = {
|
|
19
|
+
actions?: ActivityFeedAction[] | false;
|
|
20
|
+
avatarAlt?: string;
|
|
21
|
+
avatarSrc?: string;
|
|
22
|
+
caption?: ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
hasActionButtons?: boolean;
|
|
25
|
+
hasCaption?: boolean;
|
|
26
|
+
hasLink?: boolean;
|
|
27
|
+
hasStatus?: boolean;
|
|
28
|
+
hasSupportText?: boolean;
|
|
29
|
+
hasTimestamp?: boolean;
|
|
30
|
+
hasTwoActionButtons?: boolean;
|
|
31
|
+
label?: ReactNode;
|
|
32
|
+
link?: ReactNode;
|
|
33
|
+
dir?: "ltr" | "rtl";
|
|
34
|
+
showLine?: boolean;
|
|
35
|
+
showPaddingBottom?: boolean;
|
|
36
|
+
slotContent?: ReactNode;
|
|
37
|
+
supportText?: ReactNode;
|
|
38
|
+
timestamp?: ReactNode;
|
|
39
|
+
type?: ActivityFeedItemType;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type ActivityFeedProps = {
|
|
43
|
+
ariaLabel?: string;
|
|
44
|
+
avatarSrc?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
dir?: "ltr" | "rtl";
|
|
47
|
+
items?: ActivityFeedItemProps[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function classes(...names: Array<string | false | undefined>) {
|
|
51
|
+
return names.filter(Boolean).join(" ");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function StatusDot() {
|
|
55
|
+
return (
|
|
56
|
+
<span className="ds-activity-feed-item__status" aria-hidden="true" data-node-id="188:64134">
|
|
57
|
+
<span data-node-id="188:64135" />
|
|
58
|
+
</span>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function Indicator({
|
|
63
|
+
avatarAlt,
|
|
64
|
+
avatarSrc,
|
|
65
|
+
rtl,
|
|
66
|
+
showLine,
|
|
67
|
+
type,
|
|
68
|
+
}: {
|
|
69
|
+
avatarAlt: string;
|
|
70
|
+
avatarSrc: string;
|
|
71
|
+
rtl: boolean;
|
|
72
|
+
showLine: boolean;
|
|
73
|
+
type: ActivityFeedItemType;
|
|
74
|
+
}) {
|
|
75
|
+
const avatarNodeId = rtl ? (type === "caption" ? "587:18722" : "587:18703") : type === "caption" ? "584:18593" : "584:10955";
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<span className="ds-activity-feed-item__indicator" aria-hidden={avatarAlt ? undefined : "true"}>
|
|
79
|
+
<span className="ds-activity-feed-item__avatar" data-node-id={avatarNodeId}>
|
|
80
|
+
<img alt={avatarAlt} src={avatarSrc} />
|
|
81
|
+
</span>
|
|
82
|
+
{showLine && <span className="ds-activity-feed-item__line" />}
|
|
83
|
+
</span>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function ActionButton({ action }: { action: ActivityFeedAction }) {
|
|
88
|
+
const className = classes("ds-activity-feed-item__button", `ds-activity-feed-item__button--${action.variant ?? "secondary"}`);
|
|
89
|
+
|
|
90
|
+
if (action.href) {
|
|
91
|
+
return (
|
|
92
|
+
<a aria-label={action.ariaLabel} className={className} href={action.href}>
|
|
93
|
+
{action.label}
|
|
94
|
+
</a>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<button
|
|
100
|
+
aria-label={action.ariaLabel}
|
|
101
|
+
className={className}
|
|
102
|
+
disabled={action.disabled}
|
|
103
|
+
onClick={action.onClick}
|
|
104
|
+
type="button"
|
|
105
|
+
>
|
|
106
|
+
{action.label}
|
|
107
|
+
</button>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function ActivityFeedItem({
|
|
112
|
+
actions,
|
|
113
|
+
avatarAlt = "",
|
|
114
|
+
avatarSrc = defaultAvatarSrc,
|
|
115
|
+
caption,
|
|
116
|
+
className,
|
|
117
|
+
hasActionButtons = true,
|
|
118
|
+
hasCaption = true,
|
|
119
|
+
hasLink = true,
|
|
120
|
+
hasStatus = true,
|
|
121
|
+
hasSupportText = true,
|
|
122
|
+
hasTimestamp = true,
|
|
123
|
+
hasTwoActionButtons = true,
|
|
124
|
+
label,
|
|
125
|
+
link,
|
|
126
|
+
dir = "ltr",
|
|
127
|
+
showLine = true,
|
|
128
|
+
showPaddingBottom = true,
|
|
129
|
+
slotContent,
|
|
130
|
+
supportText,
|
|
131
|
+
timestamp,
|
|
132
|
+
type = "caption",
|
|
133
|
+
}: ActivityFeedItemProps) {
|
|
134
|
+
const actionItems = actions === false || !hasActionButtons ? [] : (actions ?? []).slice(0, hasTwoActionButtons ? 2 : 1);
|
|
135
|
+
const rtl = dir === "rtl";
|
|
136
|
+
const nodeId = rtl ? (type === "caption" ? "587:18720" : "587:18701") : type === "caption" ? "584:18591" : "584:10411";
|
|
137
|
+
|
|
138
|
+
const textParts = rtl
|
|
139
|
+
? [
|
|
140
|
+
hasLink && link && <span className="ds-activity-feed-item__link" key="link">{link}</span>,
|
|
141
|
+
hasSupportText && supportText && <span className="ds-activity-feed-item__support" key="support">{supportText}</span>,
|
|
142
|
+
label && <strong key="label">{label}</strong>,
|
|
143
|
+
]
|
|
144
|
+
: [
|
|
145
|
+
label && <strong key="label">{label}</strong>,
|
|
146
|
+
hasSupportText && supportText && <span className="ds-activity-feed-item__support" key="support">{supportText}</span>,
|
|
147
|
+
hasLink && link && <span className="ds-activity-feed-item__link" key="link">{link}</span>,
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<article
|
|
152
|
+
className={classes(
|
|
153
|
+
"ds-activity-feed-item",
|
|
154
|
+
`ds-activity-feed-item--${type}`,
|
|
155
|
+
rtl ? "ds-activity-feed-item--rtl" : "ds-activity-feed-item--ltr",
|
|
156
|
+
className,
|
|
157
|
+
)}
|
|
158
|
+
data-node-id={nodeId}
|
|
159
|
+
dir={rtl ? "rtl" : "ltr"}
|
|
160
|
+
>
|
|
161
|
+
{!rtl && <Indicator avatarAlt={avatarAlt} avatarSrc={avatarSrc} rtl={rtl} showLine={showLine} type={type} />}
|
|
162
|
+
|
|
163
|
+
<div className="ds-activity-feed-item__content">
|
|
164
|
+
<div className="ds-activity-feed-item__container">
|
|
165
|
+
<div className="ds-activity-feed-item__topline">
|
|
166
|
+
{rtl && hasStatus && <StatusDot />}
|
|
167
|
+
<div className="ds-activity-feed-item__text">{textParts}</div>
|
|
168
|
+
{!rtl && hasStatus && <StatusDot />}
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
{type === "slot" ? (
|
|
172
|
+
slotContent ? <div className="ds-activity-feed-item__slot">{slotContent}</div> : null
|
|
173
|
+
) : (
|
|
174
|
+
hasCaption && caption && (
|
|
175
|
+
<div className="ds-activity-feed-item__caption">{caption}</div>
|
|
176
|
+
)
|
|
177
|
+
)}
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
{hasTimestamp && timestamp && (
|
|
181
|
+
<div className="ds-activity-feed-item__timestamp">{timestamp}</div>
|
|
182
|
+
)}
|
|
183
|
+
|
|
184
|
+
{actionItems.length > 0 && (
|
|
185
|
+
<div className="ds-activity-feed-item__actions">
|
|
186
|
+
{actionItems.map((action, index) => (
|
|
187
|
+
<ActionButton action={action} key={`${action.label}-${index}`} />
|
|
188
|
+
))}
|
|
189
|
+
</div>
|
|
190
|
+
)}
|
|
191
|
+
|
|
192
|
+
{showPaddingBottom && <div className="ds-activity-feed-item__bottom-space" aria-hidden="true" />}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
{rtl && <Indicator avatarAlt={avatarAlt} avatarSrc={avatarSrc} rtl={rtl} showLine={showLine} type={type} />}
|
|
196
|
+
</article>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function ActivityFeed({
|
|
201
|
+
ariaLabel,
|
|
202
|
+
avatarSrc = defaultAvatarSrc,
|
|
203
|
+
className,
|
|
204
|
+
dir = "ltr",
|
|
205
|
+
items = [],
|
|
206
|
+
}: ActivityFeedProps) {
|
|
207
|
+
const rtl = dir === "rtl";
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<section
|
|
211
|
+
aria-label={ariaLabel}
|
|
212
|
+
className={classes("ds-activity-feed", rtl ? "ds-activity-feed--rtl" : "ds-activity-feed--ltr", className)}
|
|
213
|
+
data-node-id={rtl ? "587:19711" : "587:19381"}
|
|
214
|
+
dir={rtl ? "rtl" : "ltr"}
|
|
215
|
+
>
|
|
216
|
+
{items.map((item, index) => (
|
|
217
|
+
<ActivityFeedItem
|
|
218
|
+
{...item}
|
|
219
|
+
avatarSrc={item.avatarSrc ?? avatarSrc}
|
|
220
|
+
key={index}
|
|
221
|
+
dir={item.dir ?? dir}
|
|
222
|
+
/>
|
|
223
|
+
))}
|
|
224
|
+
</section>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./banner.css";
|
|
3
|
+
|
|
4
|
+
export type BannerType = "slim" | "single-action-inline" | "single-action" | "input";
|
|
5
|
+
export type BannerSize = "floating" | "full-width";
|
|
6
|
+
export type BannerColor = "brand" | "grey" | "brand-light";
|
|
7
|
+
export type BannerContent = "title" | "title-description";
|
|
8
|
+
export type BannerDirection = "ltr" | "rtl";
|
|
9
|
+
|
|
10
|
+
export type BannerProps = {
|
|
11
|
+
actionLabel?: string;
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
closeLabel?: string;
|
|
15
|
+
color?: BannerColor;
|
|
16
|
+
content?: BannerContent;
|
|
17
|
+
dir?: BannerDirection;
|
|
18
|
+
description?: string;
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
inputAriaLabel?: string;
|
|
21
|
+
inputPlaceholder?: string;
|
|
22
|
+
linkLabel?: string;
|
|
23
|
+
onAction?: () => void;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
showIcon?: boolean;
|
|
26
|
+
showInlineAction?: boolean;
|
|
27
|
+
size?: BannerSize;
|
|
28
|
+
title?: string;
|
|
29
|
+
type?: BannerType;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function MegaphoneIcon() {
|
|
33
|
+
return (
|
|
34
|
+
<svg aria-hidden="true" className="ds-banner__icon" viewBox="0 0 24 24">
|
|
35
|
+
<path d="M3 10.5v3a2.5 2.5 0 0 0 2.5 2.5h.63l1.15 3.44A1.5 1.5 0 0 0 8.7 20.5h1.1a1 1 0 0 0 .95-1.32L9.7 16H11l7.24 3.1A1.25 1.25 0 0 0 20 17.95V6.05a1.25 1.25 0 0 0-1.76-1.14L11 8H5.5A2.5 2.5 0 0 0 3 10.5Zm15 6.69-6-2.58V9.39l6-2.58v10.38ZM5 10.5A.5.5 0 0 1 5.5 10H10v4H5.5a.5.5 0 0 1-.5-.5v-3Z" />
|
|
36
|
+
</svg>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function CloseIcon() {
|
|
41
|
+
return (
|
|
42
|
+
<svg aria-hidden="true" className="ds-banner__close-icon" viewBox="0 0 24 24">
|
|
43
|
+
<path d="m12 10.59 5.3-5.3 1.41 1.42-5.3 5.29 5.3 5.3-1.41 1.41-5.3-5.3-5.29 5.3-1.42-1.41 5.3-5.3-5.3-5.29 1.42-1.42 5.29 5.3Z" />
|
|
44
|
+
</svg>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function cx(...classes: Array<string | false | undefined>) {
|
|
49
|
+
return classes.filter(Boolean).join(" ");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Banner({
|
|
53
|
+
actionLabel,
|
|
54
|
+
ariaLabel,
|
|
55
|
+
className = "",
|
|
56
|
+
closeLabel,
|
|
57
|
+
color = "brand",
|
|
58
|
+
content = "title",
|
|
59
|
+
description,
|
|
60
|
+
dir = "ltr",
|
|
61
|
+
icon,
|
|
62
|
+
inputAriaLabel,
|
|
63
|
+
inputPlaceholder,
|
|
64
|
+
linkLabel,
|
|
65
|
+
onAction,
|
|
66
|
+
onClose,
|
|
67
|
+
showIcon = true,
|
|
68
|
+
showInlineAction,
|
|
69
|
+
size = "floating",
|
|
70
|
+
title,
|
|
71
|
+
type = "slim",
|
|
72
|
+
}: BannerProps) {
|
|
73
|
+
const hasDescription = content === "title-description" && Boolean(title || description);
|
|
74
|
+
const titleOnlyMessage = title ?? description;
|
|
75
|
+
const isInlineAction = type === "slim" || type === "single-action-inline";
|
|
76
|
+
const inlineActionLabel = type === "single-action-inline" ? actionLabel : linkLabel;
|
|
77
|
+
const hasInlineAction = isInlineAction && (showInlineAction ?? true) && Boolean(inlineActionLabel);
|
|
78
|
+
const closeButton = (
|
|
79
|
+
<button className="ds-banner__close" onClick={onClose} type="button" aria-label={closeLabel}>
|
|
80
|
+
<CloseIcon />
|
|
81
|
+
</button>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<section
|
|
86
|
+
aria-label={ariaLabel}
|
|
87
|
+
className={cx(
|
|
88
|
+
"ds-banner",
|
|
89
|
+
`ds-banner--${type}`,
|
|
90
|
+
`ds-banner--${size}`,
|
|
91
|
+
`ds-banner--${color}`,
|
|
92
|
+
`ds-banner--${content}`,
|
|
93
|
+
dir === "rtl" && "ds-banner--rtl",
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
96
|
+
dir={dir}
|
|
97
|
+
>
|
|
98
|
+
<div className="ds-banner__main">
|
|
99
|
+
<div className="ds-banner__leading">
|
|
100
|
+
{showIcon && <span className="ds-banner__icon-wrap">{icon ?? <MegaphoneIcon />}</span>}
|
|
101
|
+
{hasDescription ? (
|
|
102
|
+
<span className="ds-banner__message">
|
|
103
|
+
{title && <strong className="ds-banner__title">{title}</strong>}
|
|
104
|
+
{title && description && <span className="ds-banner__separator">{"\u00b7"}</span>}
|
|
105
|
+
{description && <span className="ds-banner__description">{description}</span>}
|
|
106
|
+
</span>
|
|
107
|
+
) : titleOnlyMessage ? (
|
|
108
|
+
<span className="ds-banner__title-only">{titleOnlyMessage}</span>
|
|
109
|
+
) : null}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{hasInlineAction && (
|
|
113
|
+
<button className="ds-banner__link" onClick={onAction} type="button">
|
|
114
|
+
{inlineActionLabel}
|
|
115
|
+
</button>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{type === "single-action" && (
|
|
120
|
+
<div className="ds-banner__tail">
|
|
121
|
+
{actionLabel && (
|
|
122
|
+
<button className="ds-banner__action" onClick={onAction} type="button">
|
|
123
|
+
{actionLabel}
|
|
124
|
+
</button>
|
|
125
|
+
)}
|
|
126
|
+
{closeButton}
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
|
|
130
|
+
{type === "input" && (
|
|
131
|
+
<div className="ds-banner__tail ds-banner__tail--input">
|
|
132
|
+
<input aria-label={inputAriaLabel} className="ds-banner__input" placeholder={inputPlaceholder} type="text" />
|
|
133
|
+
{actionLabel && (
|
|
134
|
+
<button className="ds-banner__action" onClick={onAction} type="button">
|
|
135
|
+
{actionLabel}
|
|
136
|
+
</button>
|
|
137
|
+
)}
|
|
138
|
+
{closeButton}
|
|
139
|
+
</div>
|
|
140
|
+
)}
|
|
141
|
+
|
|
142
|
+
{isInlineAction && closeButton}
|
|
143
|
+
</section>
|
|
144
|
+
);
|
|
145
|
+
}
|