@conveyorhq/arrow-ds 1.168.0 → 1.170.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/package.json +1 -1
- package/public/components/Avatar/Avatar.d.ts +1 -0
- package/public/components/Avatar/Avatar.js +5 -6
- package/public/components/Banner/Banner.d.ts +12 -3
- package/public/components/Banner/Banner.js +16 -5
- package/src/components/Avatar/Avatar.tsx +12 -2
- package/src/components/Banner/Banner.stories.mdx +30 -6
- package/src/components/Banner/Banner.tsx +64 -8
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ type SystemAvatarProps = SharedAvatarProps & {
|
|
|
19
19
|
interface UserAvatarComponentProps extends GravatarOrInitialsProps {
|
|
20
20
|
imgSrc?: string;
|
|
21
21
|
enableTooltip?: boolean;
|
|
22
|
+
tooltipClassName?: string;
|
|
22
23
|
}
|
|
23
24
|
type UserAvatarProps = SharedAvatarProps & UserAvatarComponentProps & {
|
|
24
25
|
type: AVATAR_TYPE.USER;
|
|
@@ -142,13 +142,12 @@ const Avatar = ({ size: sizeProp = "medium", square, bordered, className, style,
|
|
|
142
142
|
const avatarContext = (0, react_1.useContext)(context_1.AvatarContext);
|
|
143
143
|
const size = avatarContext ? avatarContext.size : sizeProp;
|
|
144
144
|
if (rest.type === types_1.AVATAR_TYPE.USER && (rest.email || rest.imgSrc)) {
|
|
145
|
-
const { type, email, imgSrc, name, firstInitial, lastInitial, enableTooltip = false, ...userRest } = rest;
|
|
146
|
-
return (react_1.default.createElement(exports.AvatarWrapper, { size: size, square: square, bordered: bordered, className: className, style: style, title: alt, ...userRest }, enableTooltip && (name || email) ? (react_1.default.createElement(Tooltip_1.Tooltip, { placement: "top", referenceElement: react_1.default.createElement(Box_1.Box, { className: "h-full" },
|
|
145
|
+
const { type, email, imgSrc, name, firstInitial, lastInitial, enableTooltip = false, tooltipClassName, ...userRest } = rest;
|
|
146
|
+
return (react_1.default.createElement(exports.AvatarWrapper, { size: size, square: square, bordered: bordered, className: className, style: style, title: alt, ...userRest }, enableTooltip && (name || email) ? (react_1.default.createElement(Tooltip_1.Tooltip, { placement: "top", className: tooltipClassName, referenceElement: react_1.default.createElement(Box_1.Box, { className: "h-full" },
|
|
147
147
|
react_1.default.createElement(UserAvatar, { email: email, imgSrc: imgSrc, name: name, firstInitial: firstInitial, lastInitial: lastInitial, size: size, alt: alt })) },
|
|
148
|
-
|
|
149
|
-
name,
|
|
150
|
-
"
|
|
151
|
-
react_1.default.createElement("span", { className: "text-gray-400" }, email))) : (react_1.default.createElement(UserAvatar, { email: email, imgSrc: imgSrc, name: name, firstInitial: firstInitial, lastInitial: lastInitial, size: size, alt: alt }))));
|
|
148
|
+
react_1.default.createElement(Flex_1.Flex, { className: "flex-col items-start" },
|
|
149
|
+
name && react_1.default.createElement("span", null, name),
|
|
150
|
+
react_1.default.createElement("span", { className: name ? "text-gray-400" : undefined }, email)))) : (react_1.default.createElement(UserAvatar, { email: email, imgSrc: imgSrc, name: name, firstInitial: firstInitial, lastInitial: lastInitial, size: size, alt: alt }))));
|
|
152
151
|
}
|
|
153
152
|
const { type, ...nonUserRest } = rest;
|
|
154
153
|
if (type === types_1.AVATAR_TYPE.USER) {
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { BoxProps } from "../Box";
|
|
3
3
|
import { HeadingProps } from "../Heading";
|
|
4
4
|
import { STATUS_VARIANT } from "../../types";
|
|
5
|
-
import { StatusIconProps } from "../Icon";
|
|
5
|
+
import { CUSTOM_ICON_TYPE, ICON_STYLE_PREFIX, ICON_TYPE, StatusIconProps } from "../Icon";
|
|
6
6
|
import { CloseButtonProps } from "../CloseButton";
|
|
7
7
|
interface SharedBannerRootProps extends BoxProps {
|
|
8
8
|
variant?: STATUS_VARIANT;
|
|
@@ -10,17 +10,26 @@ interface SharedBannerRootProps extends BoxProps {
|
|
|
10
10
|
export interface BannerProps extends SharedBannerRootProps {
|
|
11
11
|
title?: string;
|
|
12
12
|
withIcon?: boolean;
|
|
13
|
+
icon?: ICON_TYPE | CUSTOM_ICON_TYPE;
|
|
14
|
+
iconPrefix?: ICON_STYLE_PREFIX;
|
|
13
15
|
}
|
|
14
16
|
export interface BannerRootProps extends SharedBannerRootProps {
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
}
|
|
17
|
-
export
|
|
19
|
+
export interface BannerIconProps extends StatusIconProps {
|
|
20
|
+
icon?: ICON_TYPE | CUSTOM_ICON_TYPE;
|
|
21
|
+
iconPrefix?: ICON_STYLE_PREFIX;
|
|
22
|
+
}
|
|
23
|
+
export type BannerContentStackProps = BoxProps;
|
|
18
24
|
export type BannerTitleProps = HeadingProps;
|
|
25
|
+
export type BannerBodyProps = BoxProps;
|
|
19
26
|
export type BannerDismissProps = CloseButtonProps;
|
|
20
27
|
declare const CompoundBanner: React.ForwardRefExoticComponent<Omit<BannerProps, "ref"> & React.RefAttributes<HTMLDivElement>> & {
|
|
21
28
|
Root: React.ForwardRefExoticComponent<Omit<BannerRootProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
Icon: React.ForwardRefExoticComponent<Omit<
|
|
29
|
+
Icon: React.ForwardRefExoticComponent<Omit<BannerIconProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
30
|
+
ContentStack: React.ForwardRefExoticComponent<Omit<BoxProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
23
31
|
Title: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
32
|
+
Body: React.ForwardRefExoticComponent<Omit<BoxProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
24
33
|
Dismiss: React.ForwardRefExoticComponent<CloseButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
34
|
};
|
|
26
35
|
export { CompoundBanner as Banner };
|
|
@@ -44,12 +44,21 @@ const BannerRoot = (0, react_1.forwardRef)(function BannerRoot(props, ref) {
|
|
|
44
44
|
react_1.default.createElement(Flex_1.Flex, { ref: ref, "data-component": "banner", className: (0, classnames_1.default)(cn(), cn({ m: variant }), className), role: "alert", ...rest }, children)));
|
|
45
45
|
});
|
|
46
46
|
const BannerIcon = (0, react_1.forwardRef)(function BannerIcon(props, ref) {
|
|
47
|
-
const { className, ...rest } = props;
|
|
47
|
+
const { icon, iconPrefix, className, ...rest } = props;
|
|
48
|
+
if (icon) {
|
|
49
|
+
return (react_1.default.createElement(Icon_1.Icon, { ref: ref, icon: icon, className: (0, classnames_1.default)(cn({ e: "icon" }), className), prefix: iconPrefix, ...rest }));
|
|
50
|
+
}
|
|
48
51
|
return (react_1.default.createElement(Icon_1.StatusIcon, { ref: ref, className: (0, classnames_1.default)(cn({ e: "icon" }), className), ...rest }));
|
|
49
52
|
});
|
|
53
|
+
const BannerContentStack = (0, react_1.forwardRef)(function BannerContentStack({ children, className, ...props }, ref) {
|
|
54
|
+
return (react_1.default.createElement(Flex_1.Flex, { ref: ref, className: (0, classnames_1.default)("flex-col gap-y-1 w-full", className), ...props }, children));
|
|
55
|
+
});
|
|
50
56
|
const BannerTitle = (0, react_1.forwardRef)(function BannerTitle({ children, ...props }, ref) {
|
|
51
57
|
return (react_1.default.createElement(Heading_1.Heading.H5, { ref: ref, ...props }, children));
|
|
52
58
|
});
|
|
59
|
+
const BannerBody = (0, react_1.forwardRef)(function BannerBody({ children, className, ...props }, ref) {
|
|
60
|
+
return (react_1.default.createElement(Box_1.Box, { className: (0, classnames_1.default)("w-full", className), ref: ref, ...props }, children));
|
|
61
|
+
});
|
|
53
62
|
const BannerDismiss = (0, react_1.forwardRef)(function BannerDismiss({ className, ...props }, ref) {
|
|
54
63
|
return (react_1.default.createElement(CloseButton_1.CloseButton, { ref: ref, className: (0, classnames_1.default)([
|
|
55
64
|
"text-gray-800 hover:text-gray-700",
|
|
@@ -59,17 +68,19 @@ const BannerDismiss = (0, react_1.forwardRef)(function BannerDismiss({ className
|
|
|
59
68
|
]), ...props }));
|
|
60
69
|
});
|
|
61
70
|
const Banner = (0, react_1.forwardRef)(function Banner(props, ref) {
|
|
62
|
-
const { variant = types_1.STATUS_VARIANT.DEFAULT, title, className, children, withIcon = false, ...rest } = props;
|
|
71
|
+
const { variant = types_1.STATUS_VARIANT.DEFAULT, title, className, children, withIcon = false, icon, iconPrefix, ...rest } = props;
|
|
63
72
|
return (react_1.default.createElement(BannerRoot, { ref: ref, className: className, variant: variant, ...rest },
|
|
64
|
-
withIcon && react_1.default.createElement(BannerIcon,
|
|
65
|
-
title ? (react_1.default.createElement(
|
|
73
|
+
(withIcon || icon) && react_1.default.createElement(BannerIcon, { icon: icon, iconPrefix: iconPrefix }),
|
|
74
|
+
title ? (react_1.default.createElement(BannerContentStack, null,
|
|
66
75
|
react_1.default.createElement(BannerTitle, null, title),
|
|
67
|
-
react_1.default.createElement(
|
|
76
|
+
react_1.default.createElement(BannerBody, null, children))) : (react_1.default.createElement(BannerBody, null, children))));
|
|
68
77
|
});
|
|
69
78
|
const CompoundBanner = Object.assign(Banner, {
|
|
70
79
|
Root: BannerRoot,
|
|
71
80
|
Icon: BannerIcon,
|
|
81
|
+
ContentStack: BannerContentStack,
|
|
72
82
|
Title: BannerTitle,
|
|
83
|
+
Body: BannerBody,
|
|
73
84
|
Dismiss: BannerDismiss,
|
|
74
85
|
});
|
|
75
86
|
exports.Banner = CompoundBanner;
|
|
@@ -116,6 +116,10 @@ interface UserAvatarComponentProps extends GravatarOrInitialsProps {
|
|
|
116
116
|
* missing.
|
|
117
117
|
*/
|
|
118
118
|
enableTooltip?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Classname to be applied to the underlying tooltip component.
|
|
121
|
+
*/
|
|
122
|
+
tooltipClassName?: string;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
type UserAvatarProps = SharedAvatarProps &
|
|
@@ -356,6 +360,7 @@ export const Avatar = ({
|
|
|
356
360
|
firstInitial,
|
|
357
361
|
lastInitial,
|
|
358
362
|
enableTooltip = false,
|
|
363
|
+
tooltipClassName,
|
|
359
364
|
...userRest
|
|
360
365
|
} = rest;
|
|
361
366
|
return (
|
|
@@ -371,6 +376,7 @@ export const Avatar = ({
|
|
|
371
376
|
{enableTooltip && (name || email) ? (
|
|
372
377
|
<Tooltip
|
|
373
378
|
placement="top"
|
|
379
|
+
className={tooltipClassName}
|
|
374
380
|
referenceElement={
|
|
375
381
|
<Box className="h-full">
|
|
376
382
|
<UserAvatar
|
|
@@ -385,8 +391,12 @@ export const Avatar = ({
|
|
|
385
391
|
</Box>
|
|
386
392
|
}
|
|
387
393
|
>
|
|
388
|
-
|
|
389
|
-
|
|
394
|
+
<Flex className="flex-col items-start">
|
|
395
|
+
{name && <span>{name}</span>}
|
|
396
|
+
<span className={name ? "text-gray-400" : undefined}>
|
|
397
|
+
{email}
|
|
398
|
+
</span>
|
|
399
|
+
</Flex>
|
|
390
400
|
</Tooltip>
|
|
391
401
|
) : (
|
|
392
402
|
<UserAvatar
|
|
@@ -4,7 +4,7 @@ import { STATUS_VARIANT } from "../../types";
|
|
|
4
4
|
import { Link } from "../Link";
|
|
5
5
|
import { Text } from "../Text";
|
|
6
6
|
import { Tooltip } from "../Tooltip";
|
|
7
|
-
import {
|
|
7
|
+
import { ICON_STYLE_PREFIX, ICON_TYPE } from "../Icon";
|
|
8
8
|
import { Banner } from "./Banner";
|
|
9
9
|
|
|
10
10
|
export const variants = Object.values(STATUS_VARIANT);
|
|
@@ -56,19 +56,19 @@ most flexibility in your consuming app.
|
|
|
56
56
|
|
|
57
57
|
<Canvas sourceState="shown">
|
|
58
58
|
<Story name="Banner composition">
|
|
59
|
-
<Banner.Root>
|
|
59
|
+
<Banner.Root variant={STATUS_VARIANT.WARNING}>
|
|
60
60
|
<Banner.Icon />
|
|
61
|
-
<
|
|
61
|
+
<Banner.ContentStack>
|
|
62
62
|
<Banner.Title>
|
|
63
63
|
You are inviting this person to be a Conveyor user
|
|
64
64
|
</Banner.Title>
|
|
65
|
-
<
|
|
65
|
+
<Banner.Body>
|
|
66
66
|
By adding this person as a Conveyor user, they’ll receive an invite to
|
|
67
67
|
join your Conveyor organization. Once this user accepts their
|
|
68
68
|
invitation, they’ll be able to complete workforce training, own
|
|
69
69
|
assets, and complete tickets.
|
|
70
|
-
</
|
|
71
|
-
</
|
|
70
|
+
</Banner.Body>
|
|
71
|
+
</Banner.ContentStack>
|
|
72
72
|
<Banner.Dismiss className="self-center" />
|
|
73
73
|
</Banner.Root>
|
|
74
74
|
</Story>
|
|
@@ -101,6 +101,8 @@ most flexibility in your consuming app.
|
|
|
101
101
|
|
|
102
102
|
### Status Variants With Icons
|
|
103
103
|
|
|
104
|
+
Set the `withIcon` prop to `true` to show an icon next to the title. The icon is pre-defined based on the status variant.
|
|
105
|
+
|
|
104
106
|
<Canvas sourceState="shown">
|
|
105
107
|
<Story name="Banners with Icons">
|
|
106
108
|
{variants.map((variant) => (
|
|
@@ -120,6 +122,28 @@ most flexibility in your consuming app.
|
|
|
120
122
|
</Story>
|
|
121
123
|
</Canvas>
|
|
122
124
|
|
|
125
|
+
Instead of using `withIcon` and the pre-defined icon, you can set a custom icon using the `icon` prop paired with the optional `iconPrefix` prop.
|
|
126
|
+
|
|
127
|
+
<Canvas sourceState="shown">
|
|
128
|
+
<Story name="Banners with Custom Icons">
|
|
129
|
+
{variants.map((variant) => (
|
|
130
|
+
<Banner
|
|
131
|
+
key={variant}
|
|
132
|
+
title="You are inviting this person to be a Conveyor user"
|
|
133
|
+
className="mb-4"
|
|
134
|
+
variant={STATUS_VARIANT[variant.toUpperCase()]}
|
|
135
|
+
icon={ICON_TYPE.STAR}
|
|
136
|
+
iconPrefix={ICON_STYLE_PREFIX.SOLID}
|
|
137
|
+
>
|
|
138
|
+
By adding this person as a Conveyor user, they’ll receive an invite to
|
|
139
|
+
join your Conveyor organization. Once this user accepts their
|
|
140
|
+
invitation, they’ll be able to complete workforce training, own assets,
|
|
141
|
+
and complete tickets.
|
|
142
|
+
</Banner>
|
|
143
|
+
))}
|
|
144
|
+
</Story>
|
|
145
|
+
</Canvas>
|
|
146
|
+
|
|
123
147
|
### No Title
|
|
124
148
|
|
|
125
149
|
<Canvas sourceState="shown">
|
|
@@ -5,7 +5,14 @@ import { Box, BoxProps } from "../Box";
|
|
|
5
5
|
import { Heading, HeadingProps } from "../Heading";
|
|
6
6
|
import { bemHOF } from "../../utilities/bem";
|
|
7
7
|
import { STATUS_VARIANT } from "../../types";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
CUSTOM_ICON_TYPE,
|
|
10
|
+
Icon,
|
|
11
|
+
ICON_STYLE_PREFIX,
|
|
12
|
+
ICON_TYPE,
|
|
13
|
+
StatusIcon,
|
|
14
|
+
StatusIconProps,
|
|
15
|
+
} from "../Icon";
|
|
9
16
|
import { Flex } from "../Flex";
|
|
10
17
|
import { CloseButton, CloseButtonProps } from "../CloseButton";
|
|
11
18
|
|
|
@@ -19,6 +26,8 @@ interface SharedBannerRootProps extends BoxProps {
|
|
|
19
26
|
export interface BannerProps extends SharedBannerRootProps {
|
|
20
27
|
title?: string;
|
|
21
28
|
withIcon?: boolean;
|
|
29
|
+
icon?: ICON_TYPE | CUSTOM_ICON_TYPE;
|
|
30
|
+
iconPrefix?: ICON_STYLE_PREFIX;
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
export interface BannerRootProps extends SharedBannerRootProps {
|
|
@@ -50,11 +59,26 @@ const BannerRoot = forwardRef<HTMLDivElement, BannerRootProps>(
|
|
|
50
59
|
},
|
|
51
60
|
);
|
|
52
61
|
|
|
53
|
-
export
|
|
62
|
+
export interface BannerIconProps extends StatusIconProps {
|
|
63
|
+
icon?: ICON_TYPE | CUSTOM_ICON_TYPE;
|
|
64
|
+
iconPrefix?: ICON_STYLE_PREFIX;
|
|
65
|
+
}
|
|
54
66
|
|
|
55
67
|
const BannerIcon = forwardRef<HTMLSpanElement, BannerIconProps>(
|
|
56
68
|
function BannerIcon(props, ref) {
|
|
57
|
-
const { className, ...rest } = props;
|
|
69
|
+
const { icon, iconPrefix, className, ...rest } = props;
|
|
70
|
+
if (icon) {
|
|
71
|
+
return (
|
|
72
|
+
<Icon
|
|
73
|
+
ref={ref}
|
|
74
|
+
icon={icon}
|
|
75
|
+
className={classNames(cn({ e: "icon" }), className)}
|
|
76
|
+
prefix={iconPrefix}
|
|
77
|
+
{...rest}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
58
82
|
return (
|
|
59
83
|
<StatusIcon
|
|
60
84
|
ref={ref}
|
|
@@ -65,6 +89,22 @@ const BannerIcon = forwardRef<HTMLSpanElement, BannerIconProps>(
|
|
|
65
89
|
},
|
|
66
90
|
);
|
|
67
91
|
|
|
92
|
+
export type BannerContentStackProps = BoxProps;
|
|
93
|
+
|
|
94
|
+
const BannerContentStack = forwardRef<HTMLDivElement, BannerContentStackProps>(
|
|
95
|
+
function BannerContentStack({ children, className, ...props }, ref) {
|
|
96
|
+
return (
|
|
97
|
+
<Flex
|
|
98
|
+
ref={ref}
|
|
99
|
+
className={classNames("flex-col gap-y-1 w-full", className)}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
</Flex>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
68
108
|
export type BannerTitleProps = HeadingProps;
|
|
69
109
|
|
|
70
110
|
const BannerTitle = forwardRef<HTMLHeadingElement, BannerTitleProps>(
|
|
@@ -77,6 +117,18 @@ const BannerTitle = forwardRef<HTMLHeadingElement, BannerTitleProps>(
|
|
|
77
117
|
},
|
|
78
118
|
);
|
|
79
119
|
|
|
120
|
+
export type BannerBodyProps = BoxProps;
|
|
121
|
+
|
|
122
|
+
const BannerBody = forwardRef<HTMLDivElement, BannerBodyProps>(
|
|
123
|
+
function BannerBody({ children, className, ...props }, ref) {
|
|
124
|
+
return (
|
|
125
|
+
<Box className={classNames("w-full", className)} ref={ref} {...props}>
|
|
126
|
+
{children}
|
|
127
|
+
</Box>
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
80
132
|
export type BannerDismissProps = CloseButtonProps;
|
|
81
133
|
|
|
82
134
|
const BannerDismiss = forwardRef<HTMLButtonElement, CloseButtonProps>(
|
|
@@ -112,20 +164,22 @@ const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(
|
|
|
112
164
|
className,
|
|
113
165
|
children,
|
|
114
166
|
withIcon = false,
|
|
167
|
+
icon,
|
|
168
|
+
iconPrefix,
|
|
115
169
|
...rest
|
|
116
170
|
} = props;
|
|
117
171
|
|
|
118
172
|
return (
|
|
119
173
|
<BannerRoot ref={ref} className={className} variant={variant} {...rest}>
|
|
120
|
-
{withIcon && <BannerIcon />}
|
|
174
|
+
{(withIcon || icon) && <BannerIcon icon={icon} iconPrefix={iconPrefix} />}
|
|
121
175
|
|
|
122
176
|
{title ? (
|
|
123
|
-
<
|
|
177
|
+
<BannerContentStack>
|
|
124
178
|
<BannerTitle>{title}</BannerTitle>
|
|
125
|
-
<
|
|
126
|
-
</
|
|
179
|
+
<BannerBody>{children}</BannerBody>
|
|
180
|
+
</BannerContentStack>
|
|
127
181
|
) : (
|
|
128
|
-
<
|
|
182
|
+
<BannerBody>{children}</BannerBody>
|
|
129
183
|
)}
|
|
130
184
|
</BannerRoot>
|
|
131
185
|
);
|
|
@@ -134,7 +188,9 @@ const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(
|
|
|
134
188
|
const CompoundBanner = Object.assign(Banner, {
|
|
135
189
|
Root: BannerRoot,
|
|
136
190
|
Icon: BannerIcon,
|
|
191
|
+
ContentStack: BannerContentStack,
|
|
137
192
|
Title: BannerTitle,
|
|
193
|
+
Body: BannerBody,
|
|
138
194
|
Dismiss: BannerDismiss,
|
|
139
195
|
});
|
|
140
196
|
|