Skip to content

Commit 3c6194e

Browse files
authored
feat(preview): add figma support to storybook [CSS-284] (#1680)
* feat(preview): add figma support to storybook [CSS-284] * chore(actionbar): add Figma URL to Storybook
1 parent fc13513 commit 3c6194e

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

.storybook/main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { resolve } = require("path");
22
const { readdirSync } = require("fs");
3+
34
const componentsPath = resolve(__dirname, "../components");
45
const componentPkgs = readdirSync(componentsPath, {
56
withFileTypes: true,
@@ -36,16 +37,20 @@ module.exports = {
3637
"@storybook/addon-interactions",
3738
// https://www.chromatic.com/docs/visual-testing-addon/
3839
"@chromaui/addon-visual-tests",
40+
// https://storybook.js.org/addons/@storybook/addon-designs/
41+
"@storybook/addon-designs",
3942
],
4043
core: {
4144
disableTelemetry: true,
4245
},
4346
env: {
4447
MIGRATED_PACKAGES: componentPkgs.filter((dir) => {
45-
const pkg = require(resolve(componentsPath, dir, "package.json"));
48+
const {
49+
devDependencies = {},
50+
} = require(resolve(componentsPath, dir, "package.json"));
4651
if (
47-
pkg.devDependencies &&
48-
pkg.devDependencies["@spectrum-css/component-builder-simple"]
52+
devDependencies &&
53+
devDependencies["@spectrum-css/component-builder-simple"]
4954
) {
5055
return true;
5156
}
@@ -56,7 +61,9 @@ module.exports = {
5661
// Removing the global alias as it conflicts with the global npm pkg
5762
const { global, ...alias } = config.resolve.alias;
5863
config.resolve.alias = alias;
59-
let storybookRules =
64+
65+
// Parse out any storybook rules for CSS so we can replace them with our own
66+
const storybookRules =
6067
config && config.module && config.module.rules
6168
? config.module.rules.filter(
6269
(rule) => !(rule.test && rule.test.toString().includes("css"))

components/actionbar/stories/actionbar.stories.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ export default {
7777
? "migrated"
7878
: undefined,
7979
},
80-
},
80+
// Getting the Figma link: https://help.figma.com/hc/en-us/articles/360045003494-Storybook-and-Figma
81+
design: {
82+
type: "figma",
83+
url: "https://www.figma.com/file/MPtRIVRzPp2VHiEplwXL2X/S-%2F-Manual?node-id=465%3A3127&t=xbooxCWItOFgG2xM-1",
84+
},
85+
}
8186
};
8287

8388
export const Default = Template.bind({});

generator/templates/stories/{{ folderName }}.stories.js.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export default {
3131
},
3232
status: {
3333
type: process.env.MIGRATED_PACKAGES.includes('{{ folderName }}') ? 'migrated' : undefined
34-
}
34+
},
35+
// Getting the Figma link: https://help.figma.com/hc/en-us/articles/360045003494-Storybook-and-Figma
36+
// design: {
37+
// type: "figma",
38+
// url: "https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File",
39+
// },
3540
}
3641
};
3742

0 commit comments

Comments
 (0)