Skip to content

Commit 1e19867

Browse files
committed
chore(storybook): add custom styling and upgrade static color
1 parent 700489f commit 1e19867

27 files changed

+487
-240
lines changed

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"devDependencies": {
100100
"@changesets/changelog-github": "^0.5.0",
101101
"@changesets/cli": "^2.27.5",
102+
"@chromatic-com/storybook": "^3.2.6",
102103
"@commitlint/cli": "^19.8.0",
103104
"@commitlint/config-conventional": "^19.8.0",
104105
"@custom-elements-manifest/analyzer": "^0.9.0",
@@ -112,16 +113,19 @@
112113
"@rollup/plugin-json": "^6.0.1",
113114
"@rollup/plugin-node-resolve": "^15.2.3",
114115
"@sindresorhus/slugify": "^2.1.1",
116+
"@spectrum-css/preview": "^12.0.4",
115117
"@spectrum-web-components/eslint-plugin": "file:./linters/eslint",
116118
"@storybook/addon-a11y": "^8.6.12",
117119
"@storybook/addon-designs": "^8.2.1",
118120
"@storybook/addon-essentials": "^8.6.12",
119121
"@storybook/addon-interactions": "^8.6.12",
120122
"@storybook/addon-links": "^8.6.12",
123+
"@storybook/addon-webpack5-compiler-babel": "^3.0.6",
121124
"@storybook/blocks": "^8.6.12",
122125
"@storybook/manager-api": "^8.6.12",
123126
"@storybook/theming": "^8.6.12",
124127
"@storybook/types": "^8.6.12",
128+
"@storybook/web-components": "^8.6.12",
125129
"@storybook/web-components-webpack5": "^8.6.12",
126130
"@types/chai": "^4.1.7",
127131
"@types/command-line-args": "^5.0.0",
@@ -148,7 +152,7 @@
148152
"@yarnpkg/types": "^4.0.1",
149153
"alex": "^11.0.1",
150154
"cem-plugin-module-file-extensions": "^0.0.5",
151-
"chromatic": "^11.20.0",
155+
"chromatic": "^11.28.2",
152156
"chromedriver": "^134.0.5",
153157
"colors": "^1.4.0",
154158
"common-tags": "^1.8.2",

packages/accordion/stories/args.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13+
import { size } from '@spectrum-css/preview/types';
14+
1315
export const argTypes = {
1416
open: {
1517
name: 'open',
@@ -53,6 +55,7 @@ export const argTypes = {
5355
},
5456
},
5557
size: {
58+
...size(),
5659
name: 'size',
5760
type: { name: 'string', required: false },
5861
description: 'The size at which to display accordion items.',

packages/action-button/stories/action-button-black-quiet.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground } from '../../button/stories/index.js';
1413
import type { Properties } from './index.js';
1514
import { renderButtons } from './index.js';
1615

1716
export default {
1817
component: 'sp-action-button',
1918
title: 'Action Button/Static Black Quiet',
20-
decorators: [makeOverBackground('black')],
19+
decorators: [],
2120
};
2221

2322
const staticColor = 'black';

packages/action-button/stories/action-button-black.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground } from '../../button/stories/index.js';
1413
import type { Properties } from './index.js';
1514
import { renderButtons } from './index.js';
1615

1716
export default {
1817
component: 'sp-action-button',
1918
title: 'Action Button/Static Black',
20-
decorators: [makeOverBackground('black')],
19+
decorators: [],
2120
};
2221

2322
const staticColor = 'black';

packages/action-button/stories/action-button-white-quiet.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground } from '../../button/stories/index.js';
1413
import type { Properties } from './index.js';
1514
import { renderButtons } from './index.js';
1615

1716
export default {
1817
component: 'sp-action-button',
1918
title: 'Action Button/Static White Quiet',
20-
decorators: [makeOverBackground()],
19+
decorators: [],
2120
};
2221

2322
const staticColor = 'white';

packages/action-button/stories/action-button-white.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground } from '../../button/stories/index.js';
1413
import type { Properties } from './index.js';
1514
import { renderButtons } from './index.js';
1615

1716
export default {
1817
component: 'sp-action-button',
1918
title: 'Action Button/Static White',
20-
decorators: [makeOverBackground()],
19+
decorators: [],
2120
};
2221

2322
const staticColor = 'white';

packages/action-menu/stories/action-menu.stories.ts

-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import '@spectrum-web-components/menu/sp-menu-item.js';
1919
import '@spectrum-web-components/menu/sp-menu.js';
2020
import { slottableRequest } from '@spectrum-web-components/overlay/src/slottable-request-directive.js';
2121
import '@spectrum-web-components/tooltip/sp-tooltip.js';
22-
import { makeOverBackground } from '../../button/stories/index.js';
2322
import { isOverlayOpen } from '../../overlay/stories/index.js';
2423
import { ActionMenuMarkup } from './';
2524

@@ -194,13 +193,11 @@ export const staticWhite = (args: StoryArgs = {}): TemplateResult =>
194193
staticWhite.args = {
195194
staticValue: 'white',
196195
};
197-
staticWhite.decorators = [makeOverBackground()];
198196
export const staticBlack = (args: StoryArgs = {}): TemplateResult =>
199197
Template(args);
200198
staticBlack.args = {
201199
staticValue: 'black',
202200
};
203-
staticBlack.decorators = [makeOverBackground()];
204201
export const quiet = (args: StoryArgs = {}): TemplateResult => Template(args);
205202
quiet.args = {
206203
quiet: true,

packages/button/stories/button-black-fill-sizes.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground, Properties, renderButtonSet } from './index.js';
13+
import { Properties, renderButtonSet } from './index.js';
1414
import { args, argTypes } from './index.js';
1515

1616
const variant = 'black';
@@ -19,7 +19,6 @@ const treatment = 'fill';
1919
export default {
2020
component: 'sp-button',
2121
title: 'Button/Black/Fill/Sizes',
22-
decorators: [makeOverBackground(variant)],
2322
args: {
2423
...args,
2524
variant,

packages/button/stories/button-black-fill.stories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
1313
import {
14-
makeOverBackground,
1514
renderButtonSet,
1615
renderLink,
1716
renderLinkWithTarget,
@@ -29,7 +28,6 @@ const treatment = 'fill';
2928
export default {
3029
component: 'sp-button',
3130
title: 'Button/Black/Fill',
32-
decorators: [makeOverBackground(staticColor)],
3331
args: {
3432
...args,
3533
staticColor,

packages/button/stories/button-black-outline-sizes.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground, Properties, renderButtonSet } from './index.js';
13+
import { Properties, renderButtonSet } from './index.js';
1414
import { args, argTypes } from './index.js';
1515

1616
const variant = 'black';
@@ -19,7 +19,6 @@ const treatment = 'outline';
1919
export default {
2020
component: 'sp-button',
2121
title: 'Button/Black/Outline/Sizes',
22-
decorators: [makeOverBackground(variant)],
2322
args: {
2423
...args,
2524
variant,

packages/button/stories/button-black-outline.stories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
1313
import {
14-
makeOverBackground,
1514
renderButtonSet,
1615
renderLink,
1716
renderLinkWithTarget,
@@ -29,7 +28,6 @@ const treatment = 'outline';
2928
export default {
3029
component: 'sp-button',
3130
title: 'Button/Black/Outline',
32-
decorators: [makeOverBackground(staticColor)],
3331
args: {
3432
...args,
3533
staticColor,

packages/button/stories/button-white-fill-sizes.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground, Properties, renderButtonSet } from './index.js';
13+
import { Properties, renderButtonSet } from './index.js';
1414
import { args, argTypes } from './index.js';
1515

1616
const variant = 'white';
@@ -19,7 +19,6 @@ const treatment = 'fill';
1919
export default {
2020
component: 'sp-button',
2121
title: 'Button/White/Fill/Sizes',
22-
decorators: [makeOverBackground()],
2322
args: {
2423
...args,
2524
variant,

packages/button/stories/button-white-fill.stories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
1313
import {
14-
makeOverBackground,
1514
renderButtonSet,
1615
renderLink,
1716
renderLinkWithTarget,
@@ -29,7 +28,6 @@ const treatment = 'fill';
2928
export default {
3029
component: 'sp-button',
3130
title: 'Button/White/Fill',
32-
decorators: [makeOverBackground(staticColor)],
3331
args: {
3432
...args,
3533
staticColor,

packages/button/stories/button-white-outline-sizes.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
13-
import { makeOverBackground, Properties, renderButtonSet } from './index.js';
13+
import { Properties, renderButtonSet } from './index.js';
1414
import { args, argTypes } from './index.js';
1515

1616
const variant = 'white';
@@ -19,7 +19,6 @@ const treatment = 'outline';
1919
export default {
2020
component: 'sp-button',
2121
title: 'Button/White/Outline/Sizes',
22-
decorators: [makeOverBackground()],
2322
args: {
2423
...args,
2524
variant,

packages/button/stories/button-white-outline.stories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ governing permissions and limitations under the License.
1111
*/
1212
import { TemplateResult } from '@spectrum-web-components/base';
1313
import {
14-
makeOverBackground,
1514
renderButtonSet,
1615
renderLink,
1716
renderLinkWithTarget,
@@ -29,7 +28,6 @@ const treatment = 'outline';
2928
export default {
3029
component: 'sp-button',
3130
title: 'Button/White/Outline',
32-
decorators: [makeOverBackground(staticColor)],
3331
args: {
3432
...args,
3533
staticColor,

packages/button/stories/index.ts

-20
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,6 @@ export const argTypes = {
8888
},
8989
};
9090

91-
export const makeOverBackground =
92-
(staticColor?: 'white' | 'black') =>
93-
(story: () => TemplateResult): TemplateResult => {
94-
const color =
95-
staticColor === 'black'
96-
? 'var(--spectrum-docs-static-black-background-color)'
97-
: 'var(--spectrum-docs-static-white-background-color)';
98-
return html`
99-
<div
100-
style="
101-
background-color: ${color};
102-
padding: calc(var(--swc-scale-factor) * 14px) calc(var(--swc-scale-factor) * 20px);
103-
display: inline-block;
104-
"
105-
>
106-
${story()}
107-
</div>
108-
`;
109-
};
110-
11191
export function renderButton(properties: Properties): TemplateResult {
11292
return html`
11393
<sp-button

packages/coachmark/stories/coach-indicator-static.stories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
import { html, TemplateResult } from '@spectrum-web-components/base';
14-
import { makeOverBackground } from '../../button/stories/index.js';
1514
import '@spectrum-web-components/coachmark/sp-coach-indicator.js';
1615

1716
export default {
1817
title: 'CoachIndicator',
1918
component: 'sp-coach-indicator',
20-
decorators: [makeOverBackground()],
2119
};
2220

2321
export const staticWhite = (): TemplateResult => {

packages/meter/stories/meter.stories.ts

+3-30
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,6 @@ export default {
1919
component: 'sp-meter',
2020
};
2121

22-
const makeOverBackground =
23-
(variant?: 'white' | 'black') =>
24-
(story: () => TemplateResult): TemplateResult => {
25-
const color =
26-
variant === 'black'
27-
? 'rgb(181, 209, 211)'
28-
: 'var(--spectrum-seafoam-900)';
29-
return html`
30-
<div
31-
style="
32-
--mod-actionbutton-static-content-color: ${color};
33-
--mod-button-static-content-color: ${color};
34-
background-color: ${color};
35-
color: ${color};
36-
padding: var(--spectrum-font-size-100) var(--spectrum-font-size-400);
37-
display: inline-block;
38-
"
39-
>
40-
${story()}
41-
</div>
42-
`;
43-
};
44-
4522
export const sideLabel = (): TemplateResult => {
4623
return html`
4724
<sp-meter side-label progress="50">Storage Space</sp-meter>
@@ -67,11 +44,7 @@ export const positive = (): TemplateResult => {
6744
};
6845

6946
export const staticWhite = (): TemplateResult => {
70-
return makeOverBackground('white')(
71-
(): TemplateResult => html`
72-
<sp-meter static-color="white" progress="50">
73-
Storage Space
74-
</sp-meter>
75-
`
76-
);
47+
return html`
48+
<sp-meter static-color="white" progress="50">Storage Space</sp-meter>
49+
`;
7750
};

0 commit comments

Comments
 (0)