Skip to content

Commit fce04d3

Browse files
jawinnpfulton
authored andcommitted
docs: additional splitbutton and button storybook options
Some additional args were needed for SplitButton to support the "Button style" example for Pagination, allowing another icon next to the SplitButton label. And Button allowing the icon to appear after the label text. SplitButton also had a disabled arg control with the "cta" option that was actually "accent".
1 parent f29a74d commit fce04d3

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

components/button/stories/template.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { classMap } from "lit/directives/class-map.js";
33
import { ifDefined } from "lit/directives/if-defined.js";
44
import { when } from "lit/directives/when.js";
55

6-
import { lowerCase, capitalize } from "lodash-es";
6+
import { capitalize, lowerCase } from "lodash-es";
77

88
import { Template as Icon } from "@spectrum-css/icon/stories/template.js";
99

@@ -17,6 +17,7 @@ export const Template = ({
1717
label,
1818
hideLabel = false,
1919
iconName,
20+
iconAfterLabel = false,
2021
variant,
2122
staticColor,
2223
treatment,
@@ -52,10 +53,11 @@ export const Template = ({
5253
aria-expanded=${ifDefined(ariaExpanded?.toString())}
5354
aria-controls=${ifDefined(ariaControls)}
5455
>
55-
${when(iconName, () => Icon({ ...globals, iconName, size }))}
56+
${when(iconName && !iconAfterLabel, () => Icon({ ...globals, iconName, size }))}
5657
${when(label && !hideLabel,
5758
() => html`<span class=${`${rootClass}-label`}>${label}</span>`
5859
)}
60+
${when(iconName && iconAfterLabel, () => Icon({ ...globals, iconName, size }))}
5961
</button>
6062
`;
6163
};

components/splitbutton/stories/splitbutton.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
name: "Variant",
1919
type: { name: "string" },
2020
table: { disable: true },
21-
options: ["cta", "primary", "secondary"],
21+
options: ["accent", "primary", "secondary"],
2222
control: "select",
2323
},
2424
position: {

components/splitbutton/stories/template.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import "../index.css";
88
export const Template = ({
99
rootClass = "spectrum-SplitButton",
1010
customClasses = [],
11+
customFirstButtonClasses = [],
12+
customLastButtonClasses = [],
1113
size = "m",
1214
variant = "cta",
1315
iconName = "ChevronDown100",
16+
labelIconName = undefined,
1417
position = "right",
1518
label = "Split Button",
1619
...globals
@@ -28,25 +31,34 @@ export const Template = ({
2831
...globals,
2932
variant,
3033
size,
31-
iconName: position === "right" ? undefined : iconName,
34+
iconName: position === "right"
35+
? typeof labelIconName != "undefined" ? labelIconName : undefined
36+
: iconName,
3237
label: position === "right" ? label : undefined,
3338
hideLabel: position === "right" ? false : true,
34-
customClasses:
39+
customClasses: [
3540
position === "right"
36-
? ["spectrum-SplitButton-action"]
37-
: ["spectrum-SplitButton-trigger"],
41+
? "spectrum-SplitButton-action"
42+
: "spectrum-SplitButton-trigger",
43+
...customFirstButtonClasses
44+
]
3845
})}
3946
${Button({
4047
...globals,
4148
variant,
4249
size,
43-
iconName: position === "right" ? iconName : undefined,
50+
iconName: position === "right"
51+
? iconName
52+
: typeof labelIconName != "undefined" ? labelIconName : undefined,
53+
iconAfterLabel: true,
4454
label: position === "right" ? undefined : label,
4555
hideLabel: position === "right" ? true : false,
46-
customClasses:
56+
customClasses: [
4757
position === "right"
48-
? ["spectrum-SplitButton-trigger"]
49-
: ["spectrum-SplitButton-action"],
58+
? "spectrum-SplitButton-trigger"
59+
: "spectrum-SplitButton-action",
60+
...customLastButtonClasses
61+
]
5062
})}
5163
</div>
5264
`;

0 commit comments

Comments
 (0)