@homebound/beam 2.372.1 → 2.373.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
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
|
|
@@ -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),
|