Skip to content

Commit b84e78e

Browse files
docs(divider): refactor divider
- enforces orientation for divider test cases - creates new minDimensionValues arg to use as visualization. Because the inline and block sizes of the divider are dependant on content (which doesn't exist on this component), this new arg sets example values for min-inline-size and min-block-size. Any other customStyles passed to the component should still render as before, and we are relying on the CSS now instead of the styleMap in the default template. - refactors the min-inline-size/min-block-size in styleMap to use new minDimensionValues arg - adds extra documentation - corrects the default size of divider to small
1 parent 0be603d commit b84e78e

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

components/divider/stories/divider.stories.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,49 @@ export default {
4141
control: "boolean",
4242
},
4343
tag: { table: { disable: true } },
44+
minDimensionValues: {table: { disable: true }},
4445
},
4546
args: {
4647
rootClass: "spectrum-Divider",
47-
size: "m",
48+
size: "s",
4849
vertical: false,
50+
minDimensionValues: true,
4951
},
5052
parameters: {
5153
componentVersion: version,
5254
},
5355
};
5456

5557
/**
56-
* The default size for divider is medium.
58+
* By default, dividers are horizontal and should be used for separating content vertically. The small divider is the default size.
5759
*/
5860
export const Default = DividerGroup.bind({});
5961
Default.args = {};
6062

6163
// ********* DOCS ONLY ********* //
64+
/**
65+
* To divide similar components such as table rows, action button groups, and components within a panel, use the default, small divider.
66+
*
67+
* The medium divider is used for dividing subsections on a page, or to separate different groupings of components such as panels, rails, etc.
68+
*
69+
* Only use the large divider for page titles or section titles.
70+
*/
6271
export const Sizing = (args, context) => Sizes({
6372
Template,
6473
withHeading: false,
6574
withBorder: false,
6675
...args,
6776
}, context);
77+
Sizing.args = {
78+
minDimensionValues: true,
79+
};
6880
Sizing.tags = ["!dev"];
6981
Sizing.parameters = {
7082
chromatic: { disableSnapshot: true },
7183
};
7284

7385
/**
74-
* When a vertical divider is used inside of a flex container, use `align-self: stretch; block-size: auto;` on the divider.
86+
* The vertical divider is used to separate content horizontally. When a vertical divider is used inside of a flex container, use `align-self: stretch; block-size: 100%;` on the divider.
7587
*/
7688
export const VerticalSizing = (args, context) => Sizes({
7789
Template,
@@ -83,18 +95,13 @@ VerticalSizing.storyName = "Vertical";
8395
VerticalSizing.tags = ["!dev"];
8496
VerticalSizing.args = {
8597
vertical: true,
98+
minDimensionValues: true,
8699
};
87100
VerticalSizing.parameters = {
88101
chromatic: { disableSnapshot: true },
89102
};
90103

91-
export const StaticWhiteGroup = (args, context) => Sizes({
92-
Template,
93-
withHeading: false,
94-
withBorder: false,
95-
...args,
96-
}, context);
97-
104+
export const StaticWhiteGroup = Default.bind({});
98105
StaticWhiteGroup.storyName = "Static white";
99106
StaticWhiteGroup.tags = ["!dev"];
100107
StaticWhiteGroup.args = {
@@ -106,12 +113,7 @@ StaticWhiteGroup.parameters = {
106113
},
107114
};
108115

109-
export const StaticBlackGroup = (args, context) => Sizes({
110-
Template,
111-
withHeading: false,
112-
withBorder: false,
113-
...args,
114-
}, context);
116+
export const StaticBlackGroup = Default.bind({});
115117
StaticBlackGroup.storyName = "Static black";
116118
StaticBlackGroup.tags = ["!dev"];
117119
StaticBlackGroup.args = {

components/divider/stories/divider.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ export const DividerGroup = Variants({
88
{
99
testHeading: "Default",
1010
vertical: false,
11+
minDimensionValues: true,
1112
},
1213
{
1314
testHeading: "Non-HR",
1415
tag: "div",
16+
vertical: false,
17+
minDimensionValues: true,
1518
},
1619
{
1720
testHeading: "Vertical",
1821
vertical: true,
22+
minDimensionValues: true,
1923
}
2024
],
2125
});

components/divider/stories/template.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const Template = ({
1111
tag = "hr",
1212
staticColor,
1313
vertical = false,
14+
minDimensionValues,
1415
customClasses = [],
1516
customStyles = {},
1617
} = {}) => {
@@ -25,11 +26,8 @@ export const Template = ({
2526
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
2627
})}
2728
style=${styleMap({
28-
"min-block-size": vertical == true ? "20px" : undefined,
29-
"block-size": vertical ? "auto" : undefined,
30-
"min-inline-size": !vertical ? "200px" : "var(--spectrum-divider-thickness)",
31-
"inline-size": !vertical ? "auto" : undefined,
32-
"align-self": vertical == true ? "stretch" : undefined,
29+
"min-inline-size": minDimensionValues && !vertical ? "200px": undefined,
30+
"min-block-size": minDimensionValues && vertical ? "20px": undefined,
3331
...customStyles,
3432
})}
3533
role="separator"
@@ -46,11 +44,8 @@ export const Template = ({
4644
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
4745
})}
4846
style=${styleMap({
49-
"min-block-size": vertical == true ? "20px" : undefined,
50-
"block-size": vertical == true ? "auto" : undefined,
51-
"min-inline-size": !vertical ? "200px" : "var(--spectrum-divider-thickness)",
52-
"inline-size": !vertical ? "auto" : undefined,
53-
"align-self": vertical == true ? "stretch" : undefined,
47+
"min-inline-size": minDimensionValues && !vertical ? "200px": undefined,
48+
"min-block-size": minDimensionValues && vertical ? "20px": undefined,
5449
...customStyles,
5550
})}
5651
role="separator"

0 commit comments

Comments
 (0)