Skip to content

Commit 6f53ef1

Browse files
committed
feat(accordion): add no inline padding variant
1 parent 3eb63f2 commit 6f53ef1

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

.storybook/types/variants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ export const isQuiet = {
4949
control: { type: "boolean" },
5050
};
5151

52+
export const hasNoInlinePadding = {
53+
name: "No Inline Padding Styling",
54+
type: { name: "boolean" },
55+
table: {
56+
type: { summary: "boolean" },
57+
category: "Component",
58+
},
59+
control: { type: "boolean" },
60+
};
61+
5262
export const staticColor = {
5363
name: "Static color",
5464
description:

components/accordion/stories/accordion.stories.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Template as Link } from "@spectrum-css/link/stories/template.js";
22
import { Sizes } from "@spectrum-css/preview/decorators";
33
import { disableDefaultModes } from "@spectrum-css/preview/modes";
4-
import { isQuiet, size } from "@spectrum-css/preview/types";
4+
import { hasNoInlinePadding, isQuiet, size } from "@spectrum-css/preview/types";
55
import { Template as Typography } from "@spectrum-css/typography/stories/template.js";
66
import metadata from "../dist/metadata.json";
77
import packageJson from "../package.json";
@@ -48,6 +48,7 @@ export default {
4848
control: "select",
4949
},
5050
isQuiet,
51+
hasNoInlinePadding,
5152
},
5253
args: {
5354
rootClass: "spectrum-Accordion",
@@ -56,6 +57,7 @@ export default {
5657
collapseAll: false,
5758
disableAll: false,
5859
isQuiet: false,
60+
hasNoInlinePadding: false,
5961
},
6062
parameters: {
6163
// Prevent an innacurate depiction of width due to "centered" layout's use of flex on the body.
@@ -216,6 +218,21 @@ Quiet.parameters = {
216218
chromatic: { disableSnapshot: true },
217219
};
218220

221+
/**
222+
* The optional no inline padding style for accordion. This sets no overall horizontal padding on either side of the component
223+
* (but the body text content always keeps its own padding from the edge). This can be applied by adding the `spectrum-Accordion----noInlinePadding` class alongside the
224+
* parent `spectrum-Accordion` class.
225+
*/
226+
export const NoInlinePadding = Template.bind({});
227+
NoInlinePadding.tags = ["!dev"];
228+
NoInlinePadding.args = {
229+
items: content,
230+
hasNoInlinePadding: true,
231+
};
232+
NoInlinePadding.parameters = {
233+
chromatic: { disableSnapshot: true },
234+
};
235+
219236
/**
220237
* Each of the different sizes have varying font sizes, and tighter or looser vertical spacing between the rows. Medium is the default size.
221238
*/

components/accordion/stories/accordion.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export const AccordionGroup = Variants({
139139
maxInlineSize: "500px",
140140
},
141141
},
142+
{
143+
testHeading: "No Inline Padding",
144+
items: testsContent,
145+
hasNoInlinePadding: true,
146+
customStyles: {
147+
maxInlineSize: "500px",
148+
},
149+
},
142150
{
143151
testHeading: "Compact",
144152
items: testsContent,

components/accordion/stories/template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const Template = ({
8585
size = "m",
8686
density = "regular",
8787
isQuiet = false,
88+
hasNoInlinePadding = false,
8889
items = [],
8990
id = getRandomId("accordion"),
9091
disableAll = false,
@@ -103,6 +104,7 @@ export const Template = ({
103104
[`${rootClass}--${density}`]:
104105
typeof density !== "undefined" && density !== "regular",
105106
[`${rootClass}--quiet`]: isQuiet,
107+
[`${rootClass}--noInlinePadding`]: hasNoInlinePadding,
106108
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
107109
})}"
108110
id=${ifDefined(id)}

0 commit comments

Comments
 (0)