@homebound/beam 2.372.1 → 2.374.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/README.md +3 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +7 -0
- package/dist/components/Icon.d.ts +1 -0
- package/dist/components/Icon.js +2 -2
- package/dist/components/IconButton.d.ts +1 -0
- package/dist/components/IconButton.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ _To see the latest designs, check out the [Figma](https://www.figma.com/file/aWU
|
|
|
25
25
|
|
|
26
26
|
## Beam's API Design Approach
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
tldr: **Consistency & Brevity** over **Power & Flexibility**.
|
|
29
|
+
|
|
30
|
+
Beam is "_Homebound's_ Design System". Given this extremely narrow purpose, we can lean into the simplicity of:
|
|
29
31
|
|
|
30
32
|
- We don't need to support everything for everyone
|
|
31
33
|
- We can prefer API/UX consistency & simplicity over configuration & complexity
|
|
@@ -22,4 +22,4 @@ export interface ButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
22
22
|
}
|
|
23
23
|
export declare function Button(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
24
|
export type ButtonSize = "sm" | "md" | "lg";
|
|
25
|
-
export type ButtonVariant = "primary" | "secondary" | "tertiary" | "tertiaryDanger" | "danger" | "text" | "textSecondary";
|
|
25
|
+
export type ButtonVariant = "primary" | "secondary" | "tertiary" | "tertiaryDanger" | "caution" | "danger" | "text" | "textSecondary";
|
|
@@ -113,6 +113,13 @@ const variantStyles = (contrast) => ({
|
|
|
113
113
|
disabledStyles: Css_1.Css.bgRed200.if(contrast).bgRed900.gray600.$,
|
|
114
114
|
focusStyles: Css_1.Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
|
|
115
115
|
},
|
|
116
|
+
caution: {
|
|
117
|
+
baseStyles: Css_1.Css.bgYellow200.gray900.$,
|
|
118
|
+
hoverStyles: Css_1.Css.bgYellow300.$,
|
|
119
|
+
pressedStyles: Css_1.Css.bgYellow400.$,
|
|
120
|
+
disabledStyles: Css_1.Css.bgYellow200.if(contrast).bgYellow900.white.$,
|
|
121
|
+
focusStyles: Css_1.Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
|
|
122
|
+
},
|
|
116
123
|
text: {
|
|
117
124
|
baseStyles: Css_1.Css.blue700.add("fontSize", "inherit").if(contrast).blue400.$,
|
|
118
125
|
hoverStyles: Css_1.Css.blue600.if(contrast).blue300.$,
|
|
@@ -6,6 +6,7 @@ export interface IconProps extends AriaAttributes, DOMProps {
|
|
|
6
6
|
icon: IconKey;
|
|
7
7
|
/** Defaults to currentColor */
|
|
8
8
|
color?: Palette | "inherit" | "currentColor";
|
|
9
|
+
bgColor?: Palette;
|
|
9
10
|
/** The size of the icon in increments, i.e. 1 == 8px, default is 3 == 24px. */
|
|
10
11
|
inc?: number;
|
|
11
12
|
/** Styles overrides */
|
package/dist/components/Icon.js
CHANGED
|
@@ -9,12 +9,12 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const Tooltip_1 = require("./Tooltip");
|
|
10
10
|
const Css_1 = require("../Css");
|
|
11
11
|
exports.Icon = react_1.default.memo((props) => {
|
|
12
|
-
const { icon, inc = 3, color = "currentColor", xss, tooltip, ...other } = props;
|
|
12
|
+
const { icon, inc = 3, color = "currentColor", bgColor, xss, tooltip, ...other } = props;
|
|
13
13
|
const size = (0, Css_1.increment)(inc);
|
|
14
14
|
return (0, Tooltip_1.maybeTooltip)({
|
|
15
15
|
title: tooltip,
|
|
16
16
|
placement: "top",
|
|
17
|
-
children: ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": true, width: size, height: size, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", css: { "path, rect": Css_1.Css.fill(color).$, ...xss }, "data-icon": icon, ...other, children: exports.Icons[icon] })),
|
|
17
|
+
children: ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": true, width: size, height: size, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", css: { "path, rect": Css_1.Css.fill(color).$, ...(bgColor && Css_1.Css.bgColor(bgColor).$), ...xss }, "data-icon": icon, ...other, children: exports.Icons[icon] })),
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
/**
|
|
@@ -7,6 +7,7 @@ export interface IconButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
7
7
|
/** The icon to use within the button. */
|
|
8
8
|
icon: IconProps["icon"];
|
|
9
9
|
color?: Palette;
|
|
10
|
+
bgColor?: Palette;
|
|
10
11
|
/** The size of the icon, in increments, defaults to 3 which is 24px. */
|
|
11
12
|
inc?: number;
|
|
12
13
|
/** HTML attributes to apply to the button element when it is being used to trigger a menu. */
|
|
@@ -12,7 +12,7 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
const getInteractiveElement_1 = require("../utils/getInteractiveElement");
|
|
13
13
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
14
14
|
function IconButton(props) {
|
|
15
|
-
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, download = false, forceFocusStyles = false, label, } = props;
|
|
15
|
+
const { onClick: onPress, disabled, color, bgColor, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, download = false, forceFocusStyles = false, label, } = props;
|
|
16
16
|
const isDisabled = !!disabled;
|
|
17
17
|
const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
|
|
18
18
|
const ref = (0, useGetRef_1.useGetRef)(buttonRef);
|
|
@@ -30,6 +30,7 @@ function IconButton(props) {
|
|
|
30
30
|
...(isHovered && (contrast ? exports.iconButtonContrastStylesHover : exports.iconButtonStylesHover)),
|
|
31
31
|
...(isFocusVisible || forceFocusStyles ? iconButtonStylesFocus : {}),
|
|
32
32
|
...(isDisabled && iconButtonStylesDisabled),
|
|
33
|
+
...(bgColor && Css_1.Css.bgColor(bgColor).$),
|
|
33
34
|
}),
|
|
34
35
|
// TODO: validate this eslint-disable. It was automatically ignored as part of https://app.shortcut.com/homebound-team/story/40033/enable-react-hooks-exhaustive-deps-for-react-projects
|
|
35
36
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -45,7 +46,7 @@ function IconButton(props) {
|
|
|
45
46
|
css: styles,
|
|
46
47
|
"aria-label": label,
|
|
47
48
|
};
|
|
48
|
-
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : iconColor), inc: compact ? 2 : inc }));
|
|
49
|
+
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : iconColor), bgColor: bgColor, inc: compact ? 2 : inc }));
|
|
49
50
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
50
51
|
return (0, components_1.maybeTooltip)({
|
|
51
52
|
title: (0, components_1.resolveTooltip)(disabled, tooltip),
|