@homebound/beam 2.306.2 → 2.307.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.
|
@@ -21,6 +21,8 @@ export interface AccordionProps<X = AccordionXss> {
|
|
|
21
21
|
omitPadding?: boolean;
|
|
22
22
|
/** Styles overrides for padding */
|
|
23
23
|
xss?: X;
|
|
24
|
+
/** Modifies the typography, padding, icon size and background color of the accordion header */
|
|
25
|
+
compact?: boolean;
|
|
24
26
|
}
|
|
25
27
|
export declare function Accordion<X extends Only<AccordionXss, X>>(props: AccordionProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
26
28
|
export type AccordionSize = "xs" | "sm" | "md" | "lg";
|
|
@@ -9,7 +9,7 @@ const Icon_1 = require("./Icon");
|
|
|
9
9
|
const Css_1 = require("../Css");
|
|
10
10
|
const utils_2 = require("../utils");
|
|
11
11
|
function Accordion(props) {
|
|
12
|
-
const { title, children, size, disabled = false, defaultExpanded = false, topBorder = true, bottomBorder = false, index, setExpandedIndex, omitPadding = false, xss, } = props;
|
|
12
|
+
const { title, children, size, disabled = false, defaultExpanded = false, compact = false, topBorder = compact ? false : true, bottomBorder = false, index, setExpandedIndex, omitPadding = false, xss, } = props;
|
|
13
13
|
const testIds = (0, utils_2.useTestIds)(props, "accordion");
|
|
14
14
|
const id = (0, utils_1.useId)();
|
|
15
15
|
const [expanded, setExpanded] = (0, react_1.useState)(defaultExpanded && !disabled);
|
|
@@ -40,7 +40,8 @@ function Accordion(props) {
|
|
|
40
40
|
...Css_1.Css.bGray300.if(topBorder).bt.if(bottomBorder).bb.$,
|
|
41
41
|
...(size ? Css_1.Css.wPx(accordionSizes[size]).$ : {}),
|
|
42
42
|
}, children: [(0, jsx_runtime_1.jsxs)("button", { ...testIds.title, ...focusProps, "aria-controls": id, "aria-expanded": expanded, disabled: disabled, css: {
|
|
43
|
-
...Css_1.Css.df.jcsb.
|
|
43
|
+
...Css_1.Css.df.jcsb.gapPx(12).aic.w100.p2.baseMd.outline("none").onHover.bgGray100.$,
|
|
44
|
+
...(compact && Css_1.Css.smMd.pl2.prPx(10).py1.bgGray100.mbPx(4).br8.onHover.bgGray200.$),
|
|
44
45
|
...(disabled && Css_1.Css.gray500.$),
|
|
45
46
|
...(isFocusVisible && Css_1.Css.boxShadow(`inset 0 0 0 2px ${Css_1.Palette.Blue700}`).$),
|
|
46
47
|
...xss,
|
|
@@ -48,7 +49,8 @@ function Accordion(props) {
|
|
|
48
49
|
setExpanded(!expanded);
|
|
49
50
|
if (setExpandedIndex)
|
|
50
51
|
setExpandedIndex(index);
|
|
51
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { children: title }), (0, jsx_runtime_1.jsx)("span", { css: {
|
|
52
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fg1.tl.$, children: title }), (0, jsx_runtime_1.jsx)("span", { css: {
|
|
53
|
+
...Css_1.Css.fs0.$,
|
|
52
54
|
transition: "transform 250ms linear",
|
|
53
55
|
transform: expanded ? "rotate(180deg)" : "rotate(0deg)",
|
|
54
56
|
}, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "chevronDown" }) })] }), (0, jsx_runtime_1.jsx)("div", { ...testIds.details, id: id, "aria-hidden": !expanded, css: Css_1.Css.overflowHidden.h(contentHeight).add("transition", "height 250ms ease-in-out").$, children: expanded && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.px2.pb2.pt1.if(omitPadding).p0.$, ref: contentRef, ...testIds.content, children: children })) })] }));
|
|
@@ -4,6 +4,8 @@ interface AccordionListProps {
|
|
|
4
4
|
/** Allows multiple accordions to be expanded simultaneously (enabled by default) */
|
|
5
5
|
allowMultipleExpanded?: boolean;
|
|
6
6
|
size?: AccordionSize;
|
|
7
|
+
/** Modifies the typography, padding, icon size and background color of the accordion header */
|
|
8
|
+
compact?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare function AccordionList(props: AccordionListProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -7,9 +7,9 @@ const react_2 = require("react");
|
|
|
7
7
|
const __1 = require("..");
|
|
8
8
|
const Accordion_1 = require("./Accordion");
|
|
9
9
|
function AccordionList(props) {
|
|
10
|
-
const { accordions, size, allowMultipleExpanded = true } = props;
|
|
10
|
+
const { accordions, size, allowMultipleExpanded = true, compact = false } = props;
|
|
11
11
|
const [expandedIndex, setExpandedIndex] = (0, react_2.useState)(accordions.findIndex((a) => a.defaultExpanded));
|
|
12
12
|
const tid = (0, __1.useTestIds)(props, "accordionList");
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: accordions.map((accordionProps, index, arr) => ((0, react_1.createElement)(Accordion_1.Accordion, { ...accordionProps, ...tid, key: index, size: size, bottomBorder: index === arr.length - 1, defaultExpanded: !allowMultipleExpanded && expandedIndex === index, index: index, setExpandedIndex: setExpandedIndex }))) }));
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: accordions.map((accordionProps, index, arr) => ((0, react_1.createElement)(Accordion_1.Accordion, { ...accordionProps, ...tid, compact: compact, key: index, size: size, bottomBorder: compact ? false : index === arr.length - 1, defaultExpanded: !allowMultipleExpanded && expandedIndex === index, index: index, setExpandedIndex: setExpandedIndex }))) }));
|
|
14
14
|
}
|
|
15
15
|
exports.AccordionList = AccordionList;
|