oneslash-design-system 2.13.1 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button.d.ts +15 -4
- package/dist/components/button.jsx +47 -12
- package/dist/components/icon.d.ts +7 -3
- package/dist/components/icon.jsx +3 -8
- package/dist/components/iconButton.d.ts +16 -6
- package/dist/components/iconButton.jsx +57 -16
- package/dist/components/iconSlot.d.ts +27 -0
- package/dist/components/iconSlot.jsx +38 -0
- package/dist/components/menuItem.d.ts +2 -2
- package/dist/components/menuItem.jsx +3 -6
- package/dist/components/namedIcon.d.ts +10 -0
- package/dist/components/namedIcon.jsx +15 -0
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.jsx +2 -3
- package/dist/components/tab.jsx +4 -7
- package/dist/components/tag.d.ts +5 -2
- package/dist/components/tag.jsx +3 -5
- package/dist/components/textField.d.ts +7 -1
- package/dist/components/textField.jsx +2 -2
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +2 -2
- package/dist/components/userImage.d.ts +5 -1
- package/dist/components/userImage.jsx +14 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/stories/Button.stories.d.ts +4 -0
- package/dist/stories/Button.stories.jsx +38 -0
- package/dist/stories/Icon.stories.d.ts +1 -0
- package/dist/stories/Icon.stories.jsx +10 -0
- package/dist/stories/IconButton.stories.d.ts +2 -0
- package/dist/stories/IconButton.stories.jsx +18 -0
- package/dist/stories/Tag.stories.d.ts +1 -0
- package/dist/stories/Tag.stories.jsx +8 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/Textarea.stories.d.ts +1 -0
- package/dist/stories/Textarea.stories.jsx +12 -0
- package/dist/stories/UserImage.stories.d.ts +1 -0
- package/dist/stories/UserImage.stories.jsx +10 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import { type IconSource } from './iconSlot';
|
|
3
|
+
/** `aria-*`, `data-*`, `id` and `title` are forwarded to the rendered `<button>` (or `<a>` when `href` is set) */
|
|
3
4
|
interface ButtonProps extends React.AriaAttributes {
|
|
4
5
|
id?: string;
|
|
5
6
|
title?: string;
|
|
@@ -10,13 +11,23 @@ interface ButtonProps extends React.AriaAttributes {
|
|
|
10
11
|
state: 'enabled' | 'hovered' | 'focused' | 'disabled' | 'selected';
|
|
11
12
|
label: string;
|
|
12
13
|
secondLabel?: string;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/** A Lucide icon name, an icon component (only that icon is bundled) or an element (`<Plus />`, the form a Server Component can pass) */
|
|
15
|
+
decoIcon?: IconSource;
|
|
16
|
+
/** A Lucide icon name, an icon component (only that icon is bundled) or an element (`<Plus />`, the form a Server Component can pass) */
|
|
17
|
+
actionIcon?: IconSource;
|
|
15
18
|
onClickButton?: any;
|
|
16
19
|
onClickActionIcon?: () => void;
|
|
17
20
|
className?: string;
|
|
18
21
|
/** Shows a spinner in the icon slot, keeps the label, and disables the button */
|
|
19
22
|
loading?: boolean;
|
|
23
|
+
/** Renders a link that looks like the button. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
|
|
24
|
+
href?: string;
|
|
25
|
+
/** With `href`: open the link in a new tab */
|
|
26
|
+
openInNewTab?: boolean;
|
|
27
|
+
/** With `href` to a path: replace the current history entry instead of adding one */
|
|
28
|
+
replace?: boolean;
|
|
29
|
+
/** The `<button>`'s own `type`. Use `submit` for a form's submit button. Defaults to `button`. */
|
|
30
|
+
htmlType?: 'button' | 'submit' | 'reset';
|
|
20
31
|
}
|
|
21
|
-
export default function Button({ size, type, color, state, label, secondLabel, decoIcon, actionIcon, onClickButton, onClickActionIcon, className, loading, ...rest }: ButtonProps): React.JSX.Element;
|
|
32
|
+
export default function Button({ size, type, color, state, label, secondLabel, decoIcon, actionIcon, onClickButton, onClickActionIcon, className, loading, href, openInNewTab, replace, htmlType, ...rest }: ButtonProps): React.JSX.Element;
|
|
22
33
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
14
|
var t = {};
|
|
4
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -11,14 +22,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
22
|
return t;
|
|
12
23
|
};
|
|
13
24
|
import React from 'react';
|
|
14
|
-
import
|
|
25
|
+
import NextLink from 'next/link';
|
|
26
|
+
import IconSlot from './iconSlot';
|
|
15
27
|
import { LoadingSmall } from './loadingScreen';
|
|
16
|
-
import { focusRing, focusRingDanger, pressFeedback, stateTransition } from './sharedStyles';
|
|
28
|
+
import { focusRing, focusRingDanger, pressFeedback, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
17
29
|
export default function Button(_a) {
|
|
18
|
-
var size = _a.size, type = _a.type, _b = _a.color, color = _b === void 0 ? 'default' : _b, state = _a.state, label = _a.label, secondLabel = _a.secondLabel, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.loading, loading = _d === void 0 ? false : _d, rest = __rest(_a, ["size", "type", "color", "state", "label", "secondLabel", "decoIcon", "actionIcon", "onClickButton", "onClickActionIcon", "className", "loading"]);
|
|
19
|
-
|
|
20
|
-
var IconLeft = decoIcon ? LucideIcons[decoIcon] : null;
|
|
21
|
-
var IconRight = actionIcon ? LucideIcons[actionIcon] : null;
|
|
30
|
+
var size = _a.size, type = _a.type, _b = _a.color, color = _b === void 0 ? 'default' : _b, state = _a.state, label = _a.label, secondLabel = _a.secondLabel, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, onClickButton = _a.onClickButton, onClickActionIcon = _a.onClickActionIcon, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.loading, loading = _d === void 0 ? false : _d, href = _a.href, _e = _a.openInNewTab, openInNewTab = _e === void 0 ? false : _e, replace = _a.replace, _f = _a.htmlType, htmlType = _f === void 0 ? 'button' : _f, rest = __rest(_a, ["size", "type", "color", "state", "label", "secondLabel", "decoIcon", "actionIcon", "onClickButton", "onClickActionIcon", "className", "loading", "href", "openInNewTab", "replace", "htmlType"]);
|
|
31
|
+
var isLink = href !== undefined;
|
|
22
32
|
// Horizontal padding sits on the button so an icon and the label are inset equally
|
|
23
33
|
var sizeClasses = {
|
|
24
34
|
large: 'text-body1 py-2 px-3 gap-1',
|
|
@@ -76,23 +86,48 @@ export default function Button(_a) {
|
|
|
76
86
|
: 'cursor-not-allowed text-fg-disabled bg-actionBackground-disabled',
|
|
77
87
|
selected: 'cursor-pointer bg-primary-dark text-primary-contrast',
|
|
78
88
|
};
|
|
89
|
+
// A lone label is centered, which shows once the button is wider than its content (`w-full`).
|
|
90
|
+
// With an action icon the label stays at the start and the icon at the far edge.
|
|
91
|
+
var justify = actionIcon ? 'justify-between' : 'justify-center';
|
|
92
|
+
// A <button> shrinks to its content and `enabled:` matches it. An <a> does neither, so a link
|
|
93
|
+
// gets the press feedback for non-buttons and a zero-specificity fit width that `w-full` overrides.
|
|
94
|
+
var linkClasses = state === 'disabled' || loading ? '[:where(&)]:w-fit' : "[:where(&)]:w-fit ".concat(pressFeedbackAny);
|
|
79
95
|
// Hover is pure CSS; `state="hovered"` and `state="focused"` only exist to show those states in docs
|
|
80
|
-
var buttonClasses = "\n flex flex-row items-center rounded-control justify
|
|
81
|
-
|
|
96
|
+
var buttonClasses = "\n flex flex-row items-center rounded-control ".concat(justify, " ").concat(stateTransition, " ").concat(isLink ? linkClasses : pressFeedback, "\n ").concat(color === 'danger' ? focusRingDanger : focusRing, "\n ").concat(sizeClasses, "\n ").concat(state === 'selected' ? stateClasses.selected : '', "\n ").concat(state === 'enabled' || state === 'hovered' ? "".concat(baseTypeClasses, " ").concat(loading ? 'cursor-wait' : "".concat(stateClasses.enabled, " ").concat(hoverTypeClasses)) : '', "\n ").concat(state === 'focused' ? "".concat(baseTypeClasses, " ").concat(hoverTypeClasses, " ").concat(stateClasses.focused) : '', "\n ").concat(state === 'disabled' ? stateClasses.disabled : '', "\n ").concat(className, "\n ");
|
|
97
|
+
var content = (<>
|
|
82
98
|
{/* Group IconLeft and label in a flex container for left alignment */}
|
|
83
99
|
<div className={"flex items-center ".concat(size === 'tiny' ? 'gap-0.5' : 'gap-1')}>
|
|
84
|
-
{loading ? (<LoadingSmall size={spinnerSize}/>) : (
|
|
100
|
+
{loading ? (<LoadingSmall size={spinnerSize}/>) : (<IconSlot icon={decoIcon} className={"".concat(sizeIcon, " flex-shrink-0")}/>)}
|
|
85
101
|
<div className={"flex flex-col text-center px-1"}>
|
|
86
102
|
<span className="whitespace-nowrap overflow-hidden truncate">{label}</span>
|
|
87
103
|
{secondLabel && (<span className={"whitespace-nowrap overflow-hidden truncate ".concat(size === 'tiny' ? 'text-caption' : 'text-body2', " opacity-70")}>{secondLabel}</span>)}
|
|
88
104
|
</div>
|
|
89
105
|
</div>
|
|
90
|
-
{
|
|
91
|
-
// Don't also trigger the button's own click
|
|
106
|
+
{actionIcon && (<span onClick={function (e) {
|
|
107
|
+
// Don't also trigger the button's own click, or follow the link
|
|
92
108
|
e.stopPropagation();
|
|
109
|
+
if (isLink && onClickActionIcon)
|
|
110
|
+
e.preventDefault();
|
|
93
111
|
onClickActionIcon === null || onClickActionIcon === void 0 ? void 0 : onClickActionIcon();
|
|
94
112
|
}} className="cursor-pointer">
|
|
95
|
-
<
|
|
113
|
+
<IconSlot icon={actionIcon} className={"".concat(sizeIcon, " flex-shrink-0")}/>
|
|
96
114
|
</span>)}
|
|
115
|
+
</>);
|
|
116
|
+
if (isLink) {
|
|
117
|
+
// A link cannot be disabled: without an href it is not focusable and does nothing
|
|
118
|
+
if (state === 'disabled' || loading) {
|
|
119
|
+
return (<a {...rest} role="link" aria-disabled="true" aria-busy={loading || undefined} className={buttonClasses}>
|
|
120
|
+
{content}
|
|
121
|
+
</a>);
|
|
122
|
+
}
|
|
123
|
+
var linkProps = __assign(__assign(__assign({}, rest), { className: buttonClasses, onClick: onClickButton }), (openInNewTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
124
|
+
// Same rule as Link: next/link for paths, a plain <a> for another site
|
|
125
|
+
if (href.startsWith('http://') || href.startsWith('https://')) {
|
|
126
|
+
return <a href={href} {...linkProps}>{content}</a>;
|
|
127
|
+
}
|
|
128
|
+
return <NextLink href={href} replace={replace} {...linkProps}>{content}</NextLink>;
|
|
129
|
+
}
|
|
130
|
+
return (<button {...rest} type={htmlType} className={buttonClasses} disabled={state === 'disabled' || loading} aria-busy={loading || undefined} onClick={onClickButton}>
|
|
131
|
+
{content}
|
|
97
132
|
</button>);
|
|
98
133
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { icons } from 'lucide-react';
|
|
2
|
+
import type { icons } from 'lucide-react';
|
|
3
|
+
import { type IconComponent } from './iconSlot';
|
|
3
4
|
type IconName = keyof typeof icons;
|
|
4
5
|
interface IconProps {
|
|
5
|
-
name
|
|
6
|
+
/** A Lucide icon name. Give this or `icon`. */
|
|
7
|
+
name?: IconName;
|
|
8
|
+
/** An icon component, e.g. `Plus` from `lucide-react`, or an element (`<Plus />`, the form a Server Component can pass): only that icon is bundled. Wins over `name`. */
|
|
9
|
+
icon?: IconComponent | React.ReactElement;
|
|
6
10
|
size?: 'tiny' | 'small' | 'medium' | 'large' | number;
|
|
7
11
|
color?: 'primary' | 'secondary' | 'disabled' | 'error' | 'warning' | 'success' | 'info' | 'accent' | 'inherit';
|
|
8
12
|
strokeWidth?: number;
|
|
9
13
|
className?: string;
|
|
10
14
|
}
|
|
11
|
-
export default function Icon({ name, size, color, strokeWidth, className, }: IconProps): React.JSX.Element
|
|
15
|
+
export default function Icon({ name, icon, size, color, strokeWidth, className, }: IconProps): React.JSX.Element;
|
|
12
16
|
export {};
|
package/dist/components/icon.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import IconSlot from './iconSlot';
|
|
4
4
|
var sizeMap = {
|
|
5
5
|
tiny: 12,
|
|
6
6
|
small: 16,
|
|
@@ -19,13 +19,8 @@ var colorMap = {
|
|
|
19
19
|
inherit: '',
|
|
20
20
|
};
|
|
21
21
|
export default function Icon(_a) {
|
|
22
|
-
var name = _a.name, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.color, color = _c === void 0 ? 'primary' : _c, _d = _a.strokeWidth, strokeWidth = _d === void 0 ? 2 : _d, _e = _a.className, className = _e === void 0 ? '' : _e;
|
|
23
|
-
var LucideIcon = icons[name];
|
|
24
|
-
if (!LucideIcon) {
|
|
25
|
-
console.warn("Icon \"".concat(name, "\" not found in Lucide icons"));
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
22
|
+
var name = _a.name, icon = _a.icon, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.color, color = _c === void 0 ? 'primary' : _c, _d = _a.strokeWidth, strokeWidth = _d === void 0 ? 2 : _d, _e = _a.className, className = _e === void 0 ? '' : _e;
|
|
28
23
|
var iconSize = typeof size === 'number' ? size : sizeMap[size];
|
|
29
24
|
var colorClass = colorMap[color];
|
|
30
|
-
return (<
|
|
25
|
+
return (<IconSlot icon={icon !== null && icon !== void 0 ? icon : name} size={iconSize} strokeWidth={strokeWidth} className={"".concat(colorClass, " ").concat(className).trim()} warnIfMissing/>);
|
|
31
26
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import * as LucideIcons from 'lucide-react';
|
|
3
|
-
|
|
2
|
+
import type * as LucideIcons from 'lucide-react';
|
|
3
|
+
import { type IconComponent } from './iconSlot';
|
|
4
|
+
/** `aria-*`, `data-*`, `id` and `title` are forwarded to the rendered `<button>` (or `<a>` when `href` is set) */
|
|
4
5
|
interface IconButtonProps extends React.AriaAttributes {
|
|
5
6
|
id?: string;
|
|
6
7
|
title?: string;
|
|
@@ -8,12 +9,21 @@ interface IconButtonProps extends React.AriaAttributes {
|
|
|
8
9
|
color: "primary" | "secondary" | "tertiary" | "iconOnly";
|
|
9
10
|
state: "enabled" | "selected" | "disabled";
|
|
10
11
|
size: "large" | "medium" | "small" | "tiny";
|
|
11
|
-
|
|
12
|
+
/** A Lucide icon name. Give this or `icon`. */
|
|
13
|
+
iconName?: keyof typeof LucideIcons;
|
|
14
|
+
/** An icon component (only that icon is bundled) or an element. Wins over `iconName`. Pass `ariaLabel` with it. */
|
|
15
|
+
icon?: IconComponent | React.ReactElement;
|
|
12
16
|
onClick?: any;
|
|
13
17
|
loading?: boolean;
|
|
14
|
-
/** Screen-reader label. Defaults to the icon name, e.g. "Settings". */
|
|
18
|
+
/** Screen-reader label. Defaults to the icon name, e.g. "Settings"; with `icon` there is no name, so set it. */
|
|
15
19
|
ariaLabel?: string;
|
|
20
|
+
/** Renders a link that looks like the button. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
|
|
21
|
+
href?: string;
|
|
22
|
+
/** With `href`: open the link in a new tab */
|
|
23
|
+
openInNewTab?: boolean;
|
|
24
|
+
/** With `href` to a path: replace the current history entry instead of adding one */
|
|
25
|
+
replace?: boolean;
|
|
16
26
|
}
|
|
17
|
-
export default function IconButton({ color, state, size, iconName, onClick, loading, // Default to false
|
|
18
|
-
ariaLabel, ...rest }: IconButtonProps): React.JSX.Element;
|
|
27
|
+
export default function IconButton({ color, state, size, iconName, icon, onClick, loading, // Default to false
|
|
28
|
+
ariaLabel, href, openInNewTab, replace, ...rest }: IconButtonProps): React.JSX.Element;
|
|
19
29
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
14
|
var t = {};
|
|
4
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -11,15 +22,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
22
|
return t;
|
|
12
23
|
};
|
|
13
24
|
import React from 'react';
|
|
14
|
-
import
|
|
25
|
+
import NextLink from 'next/link';
|
|
26
|
+
import IconSlot from './iconSlot';
|
|
15
27
|
import { LoadingSmall } from './loadingScreen';
|
|
16
|
-
import { focusRing, pressFeedback, stateTransition } from './sharedStyles';
|
|
28
|
+
import { focusRing, pressFeedback, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
17
29
|
export default function IconButton(_a) {
|
|
18
|
-
var color = _a.color, state = _a.state, size = _a.size, iconName = _a.iconName, onClick = _a.onClick, _b = _a.loading, loading = _b === void 0 ? false : _b, // Default to false
|
|
19
|
-
ariaLabel = _a.ariaLabel, rest = __rest(_a, ["color", "state", "size", "iconName", "onClick", "loading", "ariaLabel"]);
|
|
20
|
-
var
|
|
30
|
+
var color = _a.color, state = _a.state, size = _a.size, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _b = _a.loading, loading = _b === void 0 ? false : _b, // Default to false
|
|
31
|
+
ariaLabel = _a.ariaLabel, href = _a.href, _c = _a.openInNewTab, openInNewTab = _c === void 0 ? false : _c, replace = _a.replace, rest = __rest(_a, ["color", "state", "size", "iconName", "icon", "onClick", "loading", "ariaLabel", "href", "openInNewTab", "replace"]);
|
|
32
|
+
var isLink = href !== undefined;
|
|
21
33
|
// "ChevronDown" -> "Chevron Down"
|
|
22
|
-
var label = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : String(iconName).replace(/([a-z])([A-Z0-9])/g, '$1 $2');
|
|
34
|
+
var label = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : (iconName ? String(iconName).replace(/([a-z])([A-Z0-9])/g, '$1 $2') : undefined);
|
|
23
35
|
var isDisabled = state === 'disabled';
|
|
24
36
|
// Size-based classes
|
|
25
37
|
var sizeClasses = {
|
|
@@ -48,16 +60,26 @@ export default function IconButton(_a) {
|
|
|
48
60
|
: color === 'tertiary'
|
|
49
61
|
? 'bg-background-accent100' // Tertiary
|
|
50
62
|
: ' '; // iconOnly: none
|
|
51
|
-
//
|
|
52
|
-
var
|
|
53
|
-
? ''
|
|
63
|
+
// `enabled:` never matches an <a>, so a link has its own hover classes
|
|
64
|
+
var bgColorHoverLink = state === 'selected' || isDisabled || loading
|
|
65
|
+
? ''
|
|
54
66
|
: color === 'primary'
|
|
55
|
-
? '
|
|
67
|
+
? 'hover:bg-accent-dark/75' // Primary
|
|
56
68
|
: color === 'secondary'
|
|
57
|
-
? '
|
|
58
|
-
:
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
? 'hover:bg-secondary-dark/75' // Secondary
|
|
70
|
+
: 'hover:bg-background-accent200/75'; // Tertiary and iconOnly
|
|
71
|
+
// Background hover color; `enabled:` skips it while disabled or loading
|
|
72
|
+
var bgColorHover = isLink
|
|
73
|
+
? bgColorHoverLink
|
|
74
|
+
: state === 'selected'
|
|
75
|
+
? '' // No hover effect when selected
|
|
76
|
+
: color === 'primary'
|
|
77
|
+
? 'enabled:hover:bg-accent-dark/75' // Primary
|
|
78
|
+
: color === 'secondary'
|
|
79
|
+
? 'enabled:hover:bg-secondary-dark/75' // Secondary
|
|
80
|
+
: color === 'tertiary'
|
|
81
|
+
? 'enabled:hover:bg-background-accent200/75' // Tertiary
|
|
82
|
+
: 'enabled:hover:bg-background-accent200/75'; // iconOnly
|
|
61
83
|
// Icon color
|
|
62
84
|
var iconColor = isDisabled
|
|
63
85
|
? 'text-fg-disabled'
|
|
@@ -78,8 +100,27 @@ export default function IconButton(_a) {
|
|
|
78
100
|
: state === 'selected'
|
|
79
101
|
? 'cursor-pointer'
|
|
80
102
|
: 'cursor-pointer';
|
|
81
|
-
|
|
103
|
+
// A <button> shrinks to its content and `enabled:` matches it. An <a> does neither, so a link
|
|
104
|
+
// gets the press feedback for non-buttons and a zero-specificity fit width a width class overrides.
|
|
105
|
+
var press = isLink ? "[:where(&)]:w-fit ".concat(isDisabled || loading ? '' : pressFeedbackAny) : pressFeedback;
|
|
106
|
+
var className = "".concat(baseClasses, " ").concat(bgColor, " ").concat(iconColor, " ").concat(bgColorHover, " ").concat(stateClasses, " ").concat(stateTransition, " ").concat(press, " ").concat(focusRing, " flex items-center justify-center");
|
|
107
|
+
var content = loading ? (<LoadingSmall size={size}/>) : (<IconSlot icon={icon !== null && icon !== void 0 ? icon : iconName} className={iconSizeClasses[size]}/>);
|
|
108
|
+
if (isLink) {
|
|
109
|
+
// A link cannot be disabled: without an href it is not focusable and does nothing
|
|
110
|
+
if (isDisabled || loading) {
|
|
111
|
+
return (<a {...rest} role="link" aria-disabled="true" className={className} aria-label={loading ? 'Loading' : label}>
|
|
112
|
+
{content}
|
|
113
|
+
</a>);
|
|
114
|
+
}
|
|
115
|
+
var linkProps = __assign(__assign(__assign({}, rest), { className: className, onClick: onClick, 'aria-label': label }), (openInNewTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
116
|
+
// Same rule as Link: next/link for paths, a plain <a> for another site
|
|
117
|
+
if (href.startsWith('http://') || href.startsWith('https://')) {
|
|
118
|
+
return <a href={href} {...linkProps}>{content}</a>;
|
|
119
|
+
}
|
|
120
|
+
return <NextLink href={href} replace={replace} {...linkProps}>{content}</NextLink>;
|
|
121
|
+
}
|
|
122
|
+
return (<button {...rest} type="button" className={className} disabled={isDisabled || loading} // Disable button during loading
|
|
82
123
|
onClick={onClick} aria-label={loading ? 'Loading' : label}>
|
|
83
|
-
{
|
|
124
|
+
{content}
|
|
84
125
|
</button>);
|
|
85
126
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that draws an icon, such as one imported from `lucide-react`. It is given
|
|
4
|
+
* `className` and `strokeWidth` (and `size` by Icon). The props are `any` so that Lucide icons
|
|
5
|
+
* and plain SVG components both fit under React 18 and 19 types.
|
|
6
|
+
*/
|
|
7
|
+
export type IconComponent = React.ComponentType<any>;
|
|
8
|
+
/**
|
|
9
|
+
* What a component's icon prop accepts:
|
|
10
|
+
* - a Lucide icon name (`"Plus"`). The icon set loads in its own chunk the first time a name is used.
|
|
11
|
+
* - an icon component (`Plus` from `lucide-react`). Sized and stroked like a named icon, and only
|
|
12
|
+
* that icon is bundled.
|
|
13
|
+
* - an element (`<Plus />`, `<Logo />`). The only form a Server Component can pass. An element
|
|
14
|
+
* without a `className` is sized and stroked like a named icon; one with a `className` is
|
|
15
|
+
* rendered as given, so the caller's own size wins.
|
|
16
|
+
*/
|
|
17
|
+
export type IconSource = string | IconComponent | React.ReactElement;
|
|
18
|
+
interface IconSlotProps {
|
|
19
|
+
icon: IconSource | null | undefined;
|
|
20
|
+
className?: string;
|
|
21
|
+
strokeWidth?: number;
|
|
22
|
+
/** Pixel size, for icons sized by a number instead of a class */
|
|
23
|
+
size?: number;
|
|
24
|
+
warnIfMissing?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export default function IconSlot({ icon, className, strokeWidth, size, warnIfMissing }: IconSlotProps): React.JSX.Element | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import React, { Suspense, lazy } from 'react';
|
|
14
|
+
var NamedIcon = lazy(function () { return import('./namedIcon'); });
|
|
15
|
+
export default function IconSlot(_a) {
|
|
16
|
+
var _b;
|
|
17
|
+
var icon = _a.icon, className = _a.className, _c = _a.strokeWidth, strokeWidth = _c === void 0 ? 2 : _c, size = _a.size, warnIfMissing = _a.warnIfMissing;
|
|
18
|
+
if (!icon)
|
|
19
|
+
return null;
|
|
20
|
+
if (React.isValidElement(icon)) {
|
|
21
|
+
var own = icon.props;
|
|
22
|
+
// The caller's own classes win: merging two size classes would leave the result to CSS order
|
|
23
|
+
if (own.className !== undefined)
|
|
24
|
+
return icon;
|
|
25
|
+
// `strokeWidth` and `size` are props of an icon component, not attributes of a plain tag
|
|
26
|
+
var iconProps = typeof icon.type === 'string' ? {} : __assign({ strokeWidth: (_b = own.strokeWidth) !== null && _b !== void 0 ? _b : strokeWidth }, (size !== undefined && own.size === undefined ? { size: size } : {}));
|
|
27
|
+
return React.cloneElement(icon, __assign({ className: className }, iconProps));
|
|
28
|
+
}
|
|
29
|
+
if (typeof icon === 'string') {
|
|
30
|
+
return (
|
|
31
|
+
// The empty box holds the icon's place until the icon set has loaded
|
|
32
|
+
<Suspense fallback={<span aria-hidden="true" className={"inline-block ".concat(className !== null && className !== void 0 ? className : '')} style={size !== undefined ? { width: size, height: size } : undefined}/>}>
|
|
33
|
+
<NamedIcon name={icon} className={className} strokeWidth={strokeWidth} size={size} warnIfMissing={warnIfMissing}/>
|
|
34
|
+
</Suspense>);
|
|
35
|
+
}
|
|
36
|
+
var Component = icon;
|
|
37
|
+
return <Component className={className} strokeWidth={strokeWidth} {...(size !== undefined ? { size: size } : {})}/>;
|
|
38
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface MenuItemProps {
|
|
3
3
|
href?: string;
|
|
4
4
|
iconName?: string;
|
|
@@ -27,5 +27,5 @@ interface MenuItemProps {
|
|
|
27
27
|
/** Select keeps focus on its trigger and passes -1 */
|
|
28
28
|
tabIndex?: number;
|
|
29
29
|
}
|
|
30
|
-
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, tabIndex, }: MenuItemProps): JSX.Element;
|
|
30
|
+
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, tabIndex, }: MenuItemProps): React.JSX.Element;
|
|
31
31
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import IconSlot from './iconSlot';
|
|
4
4
|
import NextLink from 'next/link';
|
|
5
5
|
import UserImage from './userImage';
|
|
6
6
|
import Tag from './tag';
|
|
@@ -8,9 +8,6 @@ import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
|
8
8
|
export default function MenuItem(_a) {
|
|
9
9
|
var _b;
|
|
10
10
|
var href = _a.href, iconName = _a.iconName, icon = _a.icon, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, secondLabel = _a.secondLabel, isSelected = _a.isSelected, onClick = _a.onClick, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'medium' : _d, tag = _a.tag, iconRight = _a.iconRight, rightAction = _a.rightAction, _e = _a.role, role = _e === void 0 ? 'menuitem' : _e, id = _a.id, _f = _a.isActive, isActive = _f === void 0 ? false : _f, _g = _a.tabIndex, tabIndex = _g === void 0 ? 0 : _g;
|
|
11
|
-
// Synchronous lookup so icons render on the first paint
|
|
12
|
-
var IconLeft = iconName ? LucideIcons[iconName] : null;
|
|
13
|
-
var IconRight = iconRight ? LucideIcons[iconRight] : null;
|
|
14
11
|
// Size-based icon and text classes
|
|
15
12
|
var iconSize = { tiny: 'w-4 h-4', small: 'w-5 h-5', medium: 'w-6 h-6' }[size];
|
|
16
13
|
var labelClass = { tiny: 'text-caption', small: 'text-body2', medium: 'text-body1' }[size];
|
|
@@ -30,7 +27,7 @@ export default function MenuItem(_a) {
|
|
|
30
27
|
}}>
|
|
31
28
|
{/* Left group: icon/userImg + label with 8px gap */}
|
|
32
29
|
<div className="flex items-center gap-2 min-w-0">
|
|
33
|
-
{userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : icon ? (<span className={"".concat(iconSize, " flex-shrink-0 flex items-center justify-center")}>{icon}</span>) : (
|
|
30
|
+
{userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : icon ? (<span className={"".concat(iconSize, " flex-shrink-0 flex items-center justify-center")}>{icon}</span>) : (<IconSlot icon={iconName} className={"".concat(iconSize, " flex-shrink-0 ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-secondary')}/>)}
|
|
34
31
|
<div className="flex flex-col min-w-0">
|
|
35
32
|
<span className={"truncate ".concat(labelClass, " ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-primary')}>
|
|
36
33
|
{label}
|
|
@@ -46,7 +43,7 @@ export default function MenuItem(_a) {
|
|
|
46
43
|
{tag && (<Tag variant={tag.variant || 'contained'} size={tagSize} label={tag.label} iconName={tag.iconName}
|
|
47
44
|
// 'default' has a fill that stays visible on the menu background
|
|
48
45
|
color={(_b = tag.color) !== null && _b !== void 0 ? _b : 'default'}/>)}
|
|
49
|
-
{
|
|
46
|
+
<IconSlot icon={iconRight} className={"".concat(iconSize, " ").concat(isSelected ? 'text-primary-contrast' : 'text-fg-secondary', " flex-shrink-0")}/>
|
|
50
47
|
{rightAction && (<div onClick={function (e) { return e.stopPropagation(); }}>
|
|
51
48
|
{rightAction}
|
|
52
49
|
</div>)}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface NamedIconProps {
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
strokeWidth?: number;
|
|
6
|
+
size?: number;
|
|
7
|
+
warnIfMissing?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default function NamedIcon({ name, className, strokeWidth, size, warnIfMissing }: NamedIconProps): React.JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// The whole icon set, so an icon can be found by name. Only `iconSlot` loads this file, and
|
|
4
|
+
// only with a dynamic import, so the set stays out of an app's main bundle.
|
|
5
|
+
import * as LucideIcons from 'lucide-react';
|
|
6
|
+
export default function NamedIcon(_a) {
|
|
7
|
+
var name = _a.name, className = _a.className, strokeWidth = _a.strokeWidth, size = _a.size, warnIfMissing = _a.warnIfMissing;
|
|
8
|
+
var Icon = LucideIcons[name];
|
|
9
|
+
if (!Icon) {
|
|
10
|
+
if (warnIfMissing)
|
|
11
|
+
console.warn("Icon \"".concat(name, "\" not found in Lucide icons"));
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return <Icon className={className} strokeWidth={strokeWidth} {...(size !== undefined ? { size: size } : {})}/>;
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface SelectOption {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
@@ -15,5 +15,5 @@ interface SelectProps {
|
|
|
15
15
|
multiple?: boolean;
|
|
16
16
|
className?: string;
|
|
17
17
|
}
|
|
18
|
-
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, }: SelectProps): JSX.Element;
|
|
18
|
+
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, }: SelectProps): React.JSX.Element;
|
|
19
19
|
export { Select };
|
|
@@ -11,7 +11,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
11
11
|
import React, { useState, useEffect, useRef, useId, useCallback } from 'react';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
import { usePopper } from 'react-popper';
|
|
14
|
-
import
|
|
14
|
+
import IconSlot from './iconSlot';
|
|
15
15
|
import { ChevronDown } from 'lucide-react';
|
|
16
16
|
import Menu from './menu';
|
|
17
17
|
import MenuItem from './menuItem';
|
|
@@ -60,7 +60,6 @@ export default function Select(_a) {
|
|
|
60
60
|
var listboxId = useId();
|
|
61
61
|
var optionId = function (index) { return "".concat(listboxId, "-option-").concat(index); };
|
|
62
62
|
// Synchronous lookup so the icon renders on the first paint
|
|
63
|
-
var DecoIcon = decoIconName ? LucideIcons[decoIconName] : null;
|
|
64
63
|
// Close menu when clicking outside
|
|
65
64
|
useEffect(function () {
|
|
66
65
|
var handleClickOutside = function (event) {
|
|
@@ -215,7 +214,7 @@ export default function Select(_a) {
|
|
|
215
214
|
{/* Content Container */}
|
|
216
215
|
<div className="flex items-center gap-2 flex-1 overflow-hidden">
|
|
217
216
|
{/* Optional Decoration Icon */}
|
|
218
|
-
{
|
|
217
|
+
<IconSlot icon={decoIconName} className={"w-6 h-6 flex-shrink-0 ".concat(getIconColor())}/>
|
|
219
218
|
|
|
220
219
|
{/* Display Text */}
|
|
221
220
|
<span className="text-body1 truncate">
|
package/dist/components/tab.jsx
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import IconSlot from './iconSlot';
|
|
4
4
|
import { TabsContainerContext } from './tabsContainer';
|
|
5
5
|
import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
6
6
|
export default function Tab(_a) {
|
|
7
7
|
var label = _a.label, secondLabel = _a.secondLabel, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, router = _a.router, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
8
8
|
var inContainer = useContext(TabsContainerContext);
|
|
9
|
-
// Synchronous lookup so icons render on the first paint
|
|
10
|
-
var IconLeft = decoIcon ? LucideIcons[decoIcon] : null;
|
|
11
|
-
var IconRight = actionIcon ? LucideIcons[actionIcon] : null;
|
|
12
9
|
var handleClick = function () {
|
|
13
10
|
onClickTab();
|
|
14
11
|
if (href && router) {
|
|
@@ -34,7 +31,7 @@ export default function Tab(_a) {
|
|
|
34
31
|
}} className={"\n relative flex items-center space-x-1 rounded-control cursor-pointer justify-start ".concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(sizeClasses.tab, "\n ").concat(isSelected
|
|
35
32
|
? selectedClasses
|
|
36
33
|
: 'text-fg-primary hover:bg-background-accent200', "\n ")} onClick={handleClick}>
|
|
37
|
-
{
|
|
34
|
+
<IconSlot icon={decoIcon} className={sizeClasses.icon}/>
|
|
38
35
|
<div className={"flex flex-col text-center ".concat(sizeClasses.label)}>
|
|
39
36
|
<span className="whitespace-nowrap">
|
|
40
37
|
{label}
|
|
@@ -43,12 +40,12 @@ export default function Tab(_a) {
|
|
|
43
40
|
{secondLabel}
|
|
44
41
|
</span>)}
|
|
45
42
|
</div>
|
|
46
|
-
{
|
|
43
|
+
{actionIcon && (<span onClick={function (e) {
|
|
47
44
|
// Don't also select the tab
|
|
48
45
|
e.stopPropagation();
|
|
49
46
|
onClickActionIcon === null || onClickActionIcon === void 0 ? void 0 : onClickActionIcon(e);
|
|
50
47
|
}} className="cursor-pointer">
|
|
51
|
-
<
|
|
48
|
+
<IconSlot icon={actionIcon} className={sizeClasses.icon}/>
|
|
52
49
|
</span>)}
|
|
53
50
|
</div>);
|
|
54
51
|
}
|
package/dist/components/tag.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { icons } from 'lucide-react';
|
|
2
|
+
import type { icons } from 'lucide-react';
|
|
3
|
+
import { type IconComponent } from './iconSlot';
|
|
3
4
|
type IconName = keyof typeof icons;
|
|
4
5
|
interface TagProps {
|
|
5
6
|
variant: 'contained' | 'textOnly' | 'dot';
|
|
@@ -9,9 +10,11 @@ interface TagProps {
|
|
|
9
10
|
label: React.ReactNode;
|
|
10
11
|
secondLabel?: string;
|
|
11
12
|
iconName?: IconName;
|
|
13
|
+
/** An icon component (only that icon is bundled) or an element. Wins over `iconName`. */
|
|
14
|
+
icon?: IconComponent | React.ReactElement;
|
|
12
15
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
16
|
/** Only applies to a clickable tag: dims it, drops it from the tab order and ignores clicks */
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
}
|
|
16
|
-
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, onClick, disabled, }: TagProps): JSX.Element;
|
|
19
|
+
export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, }: TagProps): JSX.Element;
|
|
17
20
|
export {};
|
package/dist/components/tag.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import IconSlot from './iconSlot';
|
|
4
4
|
import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
5
5
|
// Filled tags use the status `fill` with `onFill` text (the default tag: `secondary.main` with
|
|
6
6
|
// `secondary.contrast`); text-only tags use the status `text` token.
|
|
@@ -48,9 +48,7 @@ var colorConfig = {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
export default function Tag(_a) {
|
|
51
|
-
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
|
|
52
|
-
// Get icon directly from icons map
|
|
53
|
-
var Icon = iconName ? icons[iconName] : null;
|
|
51
|
+
var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
|
|
54
52
|
// Size and padding
|
|
55
53
|
var sizeClasses = {
|
|
56
54
|
medium: 'text-body2 px-2 py-1',
|
|
@@ -141,7 +139,7 @@ export default function Tag(_a) {
|
|
|
141
139
|
: {};
|
|
142
140
|
return (<div className={"".concat(baseClasses, " ").concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(borderClasses, " ").concat(hoverClasses, " ").concat(cursorClass, " ").concat(onClick ? focusRing : '', " ").concat(onClick && !isDisabled ? pressFeedbackAny : '')} {...interactiveProps}>
|
|
143
141
|
{variant === 'dot' && (<span className={"w-3 h-3 rounded-full flex-shrink-0 ".concat(dotColor)}/>)}
|
|
144
|
-
{
|
|
142
|
+
{variant !== 'dot' && <IconSlot icon={icon !== null && icon !== void 0 ? icon : iconName} className={"".concat(size === 'tiny' ? 'w-3 h-3' : 'w-4 h-4', " flex-shrink-0")}/>}
|
|
145
143
|
<div className="flex flex-col text-center">
|
|
146
144
|
<span>{label}</span>
|
|
147
145
|
{secondLabel && (<span className="text-caption opacity-70">{secondLabel}</span>)}
|
|
@@ -23,6 +23,12 @@ interface TextFieldProps {
|
|
|
23
23
|
/** Browser autofill hint, e.g. "username" or "current-password". Defaults to "off". */
|
|
24
24
|
autoComplete?: string;
|
|
25
25
|
tabIndex?: number;
|
|
26
|
+
/** Passed to the `<input>` or `<textarea>`: the browser stops typing at this many characters */
|
|
27
|
+
maxLength?: number;
|
|
28
|
+
/** Passed to the `<input>` or `<textarea>`: the browser blocks a form submit below this many characters */
|
|
29
|
+
minLength?: number;
|
|
30
|
+
/** Passed to the `<input>` or `<textarea>`. Left to the browser's default when not set. */
|
|
31
|
+
spellCheck?: boolean;
|
|
26
32
|
}
|
|
27
|
-
export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, error, errorText, required, size, placeholder, name, autoComplete, tabIndex, }: TextFieldProps): React.JSX.Element;
|
|
33
|
+
export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, error, errorText, required, size, placeholder, name, autoComplete, tabIndex, maxLength, minLength, spellCheck, }: TextFieldProps): React.JSX.Element;
|
|
28
34
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { stateTransition } from './sharedStyles';
|
|
4
4
|
export default function TextField(_a) {
|
|
5
|
-
var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.error, error = _g === void 0 ? false : _g, _h = _a.errorText, errorText = _h === void 0 ? 'This field is required' : _h, _j = _a.required, required = _j === void 0 ? false : _j, _k = _a.size, size = _k === void 0 ? 'medium' : _k, placeholder = _a.placeholder, name = _a.name, _l = _a.autoComplete, autoComplete = _l === void 0 ? 'off' : _l, tabIndex = _a.tabIndex;
|
|
5
|
+
var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.error, error = _g === void 0 ? false : _g, _h = _a.errorText, errorText = _h === void 0 ? 'This field is required' : _h, _j = _a.required, required = _j === void 0 ? false : _j, _k = _a.size, size = _k === void 0 ? 'medium' : _k, placeholder = _a.placeholder, name = _a.name, _l = _a.autoComplete, autoComplete = _l === void 0 ? 'off' : _l, tabIndex = _a.tabIndex, maxLength = _a.maxLength, minLength = _a.minLength, spellCheck = _a.spellCheck;
|
|
6
6
|
var handleKeyDown = function (e) {
|
|
7
7
|
// Ctrl+Enter or Cmd+Enter to submit
|
|
8
8
|
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter' && onSubmit) {
|
|
@@ -62,7 +62,7 @@ export default function TextField(_a) {
|
|
|
62
62
|
{label}{required && <span className="text-error-text ml-0.5">*</span>}
|
|
63
63
|
</label>)}
|
|
64
64
|
<div className="relative">
|
|
65
|
-
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} {...errorProps}/>)}
|
|
65
|
+
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
|
|
66
66
|
</div>
|
|
67
67
|
{error && (<p id={errorId} className="mt-1 text-error-text text-body2">
|
|
68
68
|
{errorText}
|
|
@@ -22,6 +22,10 @@ interface TextareaProps {
|
|
|
22
22
|
/** Browser autofill hint. Defaults to "off". */
|
|
23
23
|
autoComplete?: string;
|
|
24
24
|
tabIndex?: number;
|
|
25
|
+
/** Passed to the `<textarea>`: the browser stops typing at this many characters */
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
/** Passed to the `<textarea>`. Left to the browser's default when not set. */
|
|
28
|
+
spellCheck?: boolean;
|
|
25
29
|
}
|
|
26
|
-
export default function Textarea({ id, label, value, onChange, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, onSubmit, autoFocus, maxRows, disabled, error, errorText, size, placeholder, name, autoComplete, tabIndex, }: TextareaProps): React.JSX.Element;
|
|
30
|
+
export default function Textarea({ id, label, value, onChange, onBlur, onFocus, onKeyDown, onCompositionStart, onCompositionEnd, onSubmit, autoFocus, maxRows, disabled, error, errorText, size, placeholder, name, autoComplete, tabIndex, maxLength, spellCheck, }: TextareaProps): React.JSX.Element;
|
|
27
31
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
3
3
|
import { stateTransition } from './sharedStyles';
|
|
4
4
|
export default function Textarea(_a) {
|
|
5
|
-
var id = _a.id, label = _a.label, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onCompositionStart = _a.onCompositionStart, onCompositionEnd = _a.onCompositionEnd, onSubmit = _a.onSubmit, _b = _a.autoFocus, autoFocus = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, error = _e === void 0 ? false : _e, _f = _a.errorText, errorText = _f === void 0 ? 'This field is required' : _f, _g = _a.size, size = _g === void 0 ? 'medium' : _g, placeholder = _a.placeholder, name = _a.name, _h = _a.autoComplete, autoComplete = _h === void 0 ? 'off' : _h, tabIndex = _a.tabIndex;
|
|
5
|
+
var id = _a.id, label = _a.label, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onCompositionStart = _a.onCompositionStart, onCompositionEnd = _a.onCompositionEnd, onSubmit = _a.onSubmit, _b = _a.autoFocus, autoFocus = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, error = _e === void 0 ? false : _e, _f = _a.errorText, errorText = _f === void 0 ? 'This field is required' : _f, _g = _a.size, size = _g === void 0 ? 'medium' : _g, placeholder = _a.placeholder, name = _a.name, _h = _a.autoComplete, autoComplete = _h === void 0 ? 'off' : _h, tabIndex = _a.tabIndex, maxLength = _a.maxLength, spellCheck = _a.spellCheck;
|
|
6
6
|
var textareaRef = useRef(null);
|
|
7
7
|
var handleKeyDown = function (e) {
|
|
8
8
|
// Ctrl+Enter or Cmd+Enter to submit
|
|
@@ -65,7 +65,7 @@ export default function Textarea(_a) {
|
|
|
65
65
|
{label}
|
|
66
66
|
</label>)}
|
|
67
67
|
<div className="relative">
|
|
68
|
-
<textarea ref={textareaRef} id={id} rows={1} className={containerClasses} value={value} onChange={onChange} onInput={adjustHeight} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} onCompositionStart={onCompositionStart} onCompositionEnd={onCompositionEnd} autoFocus={autoFocus} disabled={disabled} name={name} autoComplete={autoComplete} tabIndex={tabIndex} aria-invalid={error || undefined} aria-describedby={error ? errorId : undefined}/>
|
|
68
|
+
<textarea ref={textareaRef} id={id} rows={1} className={containerClasses} value={value} onChange={onChange} onInput={adjustHeight} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} onCompositionStart={onCompositionStart} onCompositionEnd={onCompositionEnd} autoFocus={autoFocus} disabled={disabled} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} spellCheck={spellCheck} aria-invalid={error || undefined} aria-describedby={error ? errorId : undefined}/>
|
|
69
69
|
</div>
|
|
70
70
|
{error && (<p id={errorId} className="mt-1 text-error-text text-body2">
|
|
71
71
|
{errorText}
|
|
@@ -3,6 +3,10 @@ interface UserImageProps {
|
|
|
3
3
|
userHandle: string;
|
|
4
4
|
userImgUrl?: string;
|
|
5
5
|
grayscale?: boolean;
|
|
6
|
+
/** Diameter in pixels. Defaults to 24. The initial scales with it. */
|
|
7
|
+
size?: number;
|
|
8
|
+
/** Passed to the `<img>`, e.g. `no-referrer` for hosts that refuse requests carrying a referrer */
|
|
9
|
+
referrerPolicy?: React.HTMLAttributeReferrerPolicy;
|
|
6
10
|
}
|
|
7
|
-
export default function UserImage({ userHandle, userImgUrl, grayscale, }: UserImageProps): React.JSX.Element;
|
|
11
|
+
export default function UserImage({ userHandle, userImgUrl, grayscale, size, referrerPolicy, }: UserImageProps): React.JSX.Element;
|
|
8
12
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
import React from 'react';
|
|
3
14
|
function getColorSeed(userHandle) {
|
|
4
15
|
var words = userHandle.trim().split(/\s+/);
|
|
@@ -22,7 +33,7 @@ function getHash(str) {
|
|
|
22
33
|
return hash;
|
|
23
34
|
}
|
|
24
35
|
export default function UserImage(_a) {
|
|
25
|
-
var userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, _b = _a.grayscale, grayscale = _b === void 0 ? false : _b;
|
|
36
|
+
var userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, _b = _a.grayscale, grayscale = _b === void 0 ? false : _b, size = _a.size, referrerPolicy = _a.referrerPolicy;
|
|
26
37
|
var displayInitial = userHandle.charAt(0).toUpperCase() || 'A';
|
|
27
38
|
var seed = getColorSeed(userHandle);
|
|
28
39
|
var hue = Math.abs(getHash(seed)) % 360;
|
|
@@ -36,11 +47,8 @@ export default function UserImage(_a) {
|
|
|
36
47
|
return (
|
|
37
48
|
// Per-user hue computed in JS, not a theme token, so the dark: variant stays here (one of the two documented
|
|
38
49
|
// `dark:` exemptions, see the overlay rings in Menu/Popover/Modal). The dark: variant follows whatever dark variant the app's preset/@theme defines (class-only or OS-aware).
|
|
39
|
-
<div style={{
|
|
40
|
-
|
|
41
|
-
'--dark-bg': darkBg,
|
|
42
|
-
}} className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-fg-primary">
|
|
43
|
-
{userImgUrl ? (<img src={userImgUrl} alt={userHandle} className="w-full h-full object-cover rounded-full"/>) : (<span className="text-body1 text-fg-primary">
|
|
50
|
+
<div style={__assign({ '--light-bg': lightBg, '--dark-bg': darkBg }, (size !== undefined && { width: size, height: size, fontSize: (size * 2) / 3 }))} className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-fg-primary">
|
|
51
|
+
{userImgUrl ? (<img src={userImgUrl} alt={userHandle} referrerPolicy={referrerPolicy} className="w-full h-full object-cover rounded-full"/>) : (<span className={"".concat(size === undefined ? 'text-body1' : 'leading-none', " text-fg-primary")}>
|
|
44
52
|
{displayInitial}
|
|
45
53
|
</span>)}
|
|
46
54
|
</div>);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,3 +18,7 @@ export declare const DangerTextOnly: Story;
|
|
|
18
18
|
export declare const DangerVariants: Story;
|
|
19
19
|
export declare const Loading: Story;
|
|
20
20
|
export declare const AriaExpanded: Story;
|
|
21
|
+
export declare const IconComponents: Story;
|
|
22
|
+
export declare const AsLink: Story;
|
|
23
|
+
export declare const Submit: Story;
|
|
24
|
+
export declare const FullWidth: Story;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { ChevronDown, ChevronRight, ExternalLink, Plus, Star } from "lucide-react";
|
|
2
3
|
import Button from "../components/button";
|
|
3
4
|
var meta = {
|
|
4
5
|
title: "Components/Button",
|
|
@@ -161,3 +162,40 @@ export var AriaExpanded = {
|
|
|
161
162
|
"data-testid": "filters-trigger",
|
|
162
163
|
},
|
|
163
164
|
};
|
|
165
|
+
// An icon can be a component or an element instead of a name. A component is sized like a
|
|
166
|
+
// named icon and only that icon is bundled. So is an element without a className (what a
|
|
167
|
+
// Server Component passes); an element with a className is rendered as given.
|
|
168
|
+
export var IconComponents = {
|
|
169
|
+
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
170
|
+
<Button size="medium" type="primary" state="enabled" label="Component" decoIcon={Star} actionIcon={ChevronRight}/>
|
|
171
|
+
<Button size="medium" type="secondary" state="enabled" label="By name" decoIcon="Star" actionIcon="ChevronRight"/>
|
|
172
|
+
<Button size="medium" type="tertiary" state="enabled" label="Element" decoIcon={<span className="w-5 h-5 rounded-full bg-accent-main flex-shrink-0"/>}/>
|
|
173
|
+
<Button size="medium" type="tertiary" state="enabled" label="Icon element" decoIcon={<Star />} actionIcon={<ChevronRight />}/>
|
|
174
|
+
</div>); },
|
|
175
|
+
};
|
|
176
|
+
// `href` renders a link with the button's look: next/link for a path, a plain <a> for another site
|
|
177
|
+
export var AsLink = {
|
|
178
|
+
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
179
|
+
<Button size="medium" type="primary" state="enabled" label="Internal link" href="/gallery"/>
|
|
180
|
+
<Button size="medium" type="secondary" state="enabled" label="New tab" href="https://example.com" openInNewTab actionIcon={ExternalLink}/>
|
|
181
|
+
<Button size="medium" type="tertiary" state="disabled" label="Disabled link" href="/gallery"/>
|
|
182
|
+
</div>); },
|
|
183
|
+
};
|
|
184
|
+
// `htmlType="submit"` makes the button submit its form, so Enter in a field submits too
|
|
185
|
+
export var Submit = {
|
|
186
|
+
render: function () { return (<form onSubmit={function (e) { return e.preventDefault(); }} style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
187
|
+
<Button size="medium" type="primary" state="enabled" label="Save" htmlType="submit"/>
|
|
188
|
+
<Button size="medium" type="tertiary" state="enabled" label="Reset" htmlType="reset"/>
|
|
189
|
+
</form>); },
|
|
190
|
+
};
|
|
191
|
+
// Stretched, a lone label (with or without a deco icon) is centered. With an action icon the
|
|
192
|
+
// label stays at the start and the icon sits at the far edge.
|
|
193
|
+
export var FullWidth = {
|
|
194
|
+
render: function () { return (<div style={{ display: "flex", flexDirection: "column", gap: "16px", width: "320px" }}>
|
|
195
|
+
<Button size="medium" type="primary" state="enabled" label="Continue" className="w-full"/>
|
|
196
|
+
<Button size="medium" type="secondary" state="enabled" label="Add item" decoIcon={Plus} className="w-full"/>
|
|
197
|
+
<Button size="medium" type="tertiary" state="enabled" label="Filters" actionIcon={ChevronDown} className="w-full"/>
|
|
198
|
+
<Button size="medium" type="primary" state="enabled" label="Link, full width" href="/gallery" className="w-full"/>
|
|
199
|
+
<Button size="medium" type="primary" state="enabled" label="Link, fits content" href="/gallery"/>
|
|
200
|
+
</div>); },
|
|
201
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Star } from "lucide-react";
|
|
2
3
|
import Icon from "../components/icon";
|
|
3
4
|
var meta = {
|
|
4
5
|
title: "Components/Icon",
|
|
@@ -128,3 +129,12 @@ export var StrokeWidths = {
|
|
|
128
129
|
color: "primary",
|
|
129
130
|
},
|
|
130
131
|
};
|
|
132
|
+
// `icon` takes a component instead of a name: only that icon is bundled
|
|
133
|
+
export var FromComponent = {
|
|
134
|
+
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
135
|
+
<Icon icon={Star} size="small"/>
|
|
136
|
+
<Icon icon={Star}/>
|
|
137
|
+
<Icon icon={Star} size="large" color="accent"/>
|
|
138
|
+
<Icon name="Star" size="large" color="accent"/>
|
|
139
|
+
</div>); },
|
|
140
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Plus, Settings } from "lucide-react";
|
|
2
3
|
import IconButton from "../components/iconButton";
|
|
3
4
|
var meta = {
|
|
4
5
|
title: "Components/IconButton",
|
|
@@ -101,3 +102,20 @@ export var AriaExpanded = {
|
|
|
101
102
|
"data-testid": "details-trigger",
|
|
102
103
|
},
|
|
103
104
|
};
|
|
105
|
+
// `icon` takes a component or an element instead of a name: only that icon is bundled.
|
|
106
|
+
// There is no name to read out, so pass `ariaLabel`.
|
|
107
|
+
export var IconComponent = {
|
|
108
|
+
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
109
|
+
<IconButton color="primary" state="enabled" size="medium" icon={Plus} ariaLabel="Add"/>
|
|
110
|
+
<IconButton color="tertiary" state="enabled" size="medium" icon={Settings} ariaLabel="Settings"/>
|
|
111
|
+
<IconButton color="iconOnly" state="enabled" size="medium" icon={<span className="size-6 rounded-full bg-accent-main"/>} ariaLabel="Account"/>
|
|
112
|
+
</div>); },
|
|
113
|
+
};
|
|
114
|
+
// `href` renders a link with the icon button's look
|
|
115
|
+
export var AsLink = {
|
|
116
|
+
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
117
|
+
<IconButton color="tertiary" state="enabled" size="small" icon={Settings} ariaLabel="Settings" href="/settings"/>
|
|
118
|
+
<IconButton color="primary" state="enabled" size="medium" iconName="ExternalLink" ariaLabel="Open example.com" href="https://example.com" openInNewTab/>
|
|
119
|
+
<IconButton color="secondary" state="disabled" size="medium" iconName="Settings" href="/settings"/>
|
|
120
|
+
</div>); },
|
|
121
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Check } from "lucide-react";
|
|
2
3
|
import Tag from "../components/tag";
|
|
3
4
|
var meta = {
|
|
4
5
|
title: "Components/Tag",
|
|
@@ -177,3 +178,10 @@ export var DotColors = {
|
|
|
177
178
|
<Tag variant="dot" size="medium" color="info" label="Busy"/>
|
|
178
179
|
</div>); },
|
|
179
180
|
};
|
|
181
|
+
// `icon` takes a component instead of a name: only that icon is bundled
|
|
182
|
+
export var IconComponent = {
|
|
183
|
+
render: function () { return (<div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
|
|
184
|
+
<Tag variant="contained" size="medium" label="Component" icon={Check}/>
|
|
185
|
+
<Tag variant="contained" size="medium" label="By name" iconName="Check"/>
|
|
186
|
+
</div>); },
|
|
187
|
+
};
|
|
@@ -156,3 +156,16 @@ export var Autofill = {
|
|
|
156
156
|
size: "medium",
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
|
+
// `maxLength`, `minLength` and `spellCheck` reach the <input>: the browser enforces them
|
|
160
|
+
export var LengthLimits = {
|
|
161
|
+
render: function (args) { return <TextFieldWrapper {...args}/>; },
|
|
162
|
+
args: {
|
|
163
|
+
id: "length-textfield",
|
|
164
|
+
label: "Display name (3 to 20 characters)",
|
|
165
|
+
value: "Viskit",
|
|
166
|
+
minLength: 3,
|
|
167
|
+
maxLength: 20,
|
|
168
|
+
spellCheck: false,
|
|
169
|
+
size: "medium",
|
|
170
|
+
},
|
|
171
|
+
};
|
|
@@ -95,3 +95,15 @@ export var Named = {
|
|
|
95
95
|
size: "medium",
|
|
96
96
|
},
|
|
97
97
|
};
|
|
98
|
+
// `maxLength` and `spellCheck` reach the <textarea>
|
|
99
|
+
export var MaxLength = {
|
|
100
|
+
render: function (args) { return <TextareaWrapper {...args}/>; },
|
|
101
|
+
args: {
|
|
102
|
+
id: "maxlength-textarea",
|
|
103
|
+
label: "Comment (up to 280 characters)",
|
|
104
|
+
value: "",
|
|
105
|
+
maxLength: 280,
|
|
106
|
+
spellCheck: false,
|
|
107
|
+
size: "medium",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -44,3 +44,13 @@ export var MixedWithImages = {
|
|
|
44
44
|
<UserImage userHandle="Carol Davis" userImgUrl="https://i.pravatar.cc/150?img=9"/>
|
|
45
45
|
</div>); },
|
|
46
46
|
};
|
|
47
|
+
// `size` is the diameter in pixels; the initial scales with it. `referrerPolicy` reaches the <img>.
|
|
48
|
+
export var Sizes = {
|
|
49
|
+
render: function () { return (<div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
|
|
50
|
+
<UserImage userHandle="Alice Brown" size={16}/>
|
|
51
|
+
<UserImage userHandle="Alice Brown"/>
|
|
52
|
+
<UserImage userHandle="Alice Brown" size={32}/>
|
|
53
|
+
<UserImage userHandle="Alice Brown" size={48}/>
|
|
54
|
+
<UserImage userHandle="Jane Smith" userImgUrl="https://i.pravatar.cc/150?img=5" size={48} referrerPolicy="no-referrer"/>
|
|
55
|
+
</div>); },
|
|
56
|
+
};
|