Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: upgrade storybook to 5.2.8 and refactor stories to CSF #508

Merged
merged 25 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2d6ebb0
feat: included basic bar chart docs setup
nickofthyme Jan 3, 2020
e0729a0
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 6, 2020
94cdca3
fix: fix knob bug
rshen91 Jan 7, 2020
a85adc6
Merge branch 'master' into rshen-add-docs
rshen91 Jan 8, 2020
5a1c034
fix: fix visual test urls
rshen91 Jan 8, 2020
098956b
test: update vrt snapshots
rshen91 Jan 8, 2020
9432cff
feat: refactor line stories to csf format
rshen91 Jan 10, 2020
1b6a971
refactor: refactor annotion stories to csf
rshen91 Jan 10, 2020
0aab414
refactor: refactor area chart to csf
rshen91 Jan 10, 2020
c822f5d
refactor: refactor axis to csf format
rshen91 Jan 10, 2020
5139d1e
refactor: update to csf other stories besides stylings
rshen91 Jan 10, 2020
d0e56c6
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 10, 2020
e66ac7a
refactor: change stylings to csf format
rshen91 Jan 10, 2020
ea9e5f0
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 13, 2020
a75d477
fix: refactor helpers.ts to register all.test.ts
rshen91 Jan 13, 2020
665c4b9
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 13, 2020
6dfe8e2
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 14, 2020
a60dd89
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 21, 2020
52b2adf
test: add pie and treemap vrts
rshen91 Jan 21, 2020
d64ed56
feat: add really basic static prop table in basic story doc
rshen91 Jan 21, 2020
66242ec
style: add some basic styling for readability
rshen91 Jan 21, 2020
eac67b2
feat: adding code block for source
rshen91 Jan 22, 2020
b4b5378
Merge remote-tracking branch 'upstream/master' into rshen-add-docs
rshen91 Jan 23, 2020
9e66f02
refactor: update naming in bars and update tests for new naming
rshen91 Jan 23, 2020
d3596a5
test: update naming in other stories and update vrt with new urls
rshen91 Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .storybook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,4 @@ addParameters({
addDecorator(withKnobs);
addDecorator(withInfo);

function loadStories() {
require('../stories/bar_chart.tsx');
require('../stories/line_chart.tsx');
require('../stories/area_chart.tsx');
require('../stories/axis.tsx');
require('../stories/mixed.tsx');
require('../stories/legend.tsx');
require('../stories/interactions.tsx');
require('../stories/rotations.tsx');
require('../stories/styling.tsx');
require('../stories/grid.tsx');
require('../stories/annotations.tsx');
require('../stories/scales.tsx');
return [require('../stories/sunburst.tsx'), require('../stories/treemap.tsx')];
}

configure(loadStories, module);
configure(require.context('../stories', true, /\.tsx$/), module);
40 changes: 30 additions & 10 deletions integration/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path';
import { readdirSync } from 'fs';
import { getStorybook } from '@storybook/react';
import { join, resolve } from 'path';
import { lstatSync, readdirSync } from 'fs';
import { getStorybook, configure } from '@storybook/react';

export interface StoryInfo {
title: string;
Expand All @@ -13,12 +13,33 @@ export interface StoryGroupInfo {
stories: StoryInfo[];
}

function requireAllStories() {
const normalizedPath = join(__dirname, '../stories');
function requireAllStories(basedir: string, directory: string) {
function enumerateFiles(basedir: string, dir: string) {
let result: string[] = [];
readdirSync(join(basedir, dir)).forEach(function(file) {
const relativePath = join(dir, file);
const stats = lstatSync(join(basedir, relativePath));
if (stats.isDirectory()) {
result = result.concat(enumerateFiles(basedir, relativePath));
} else if (/\.tsx$/.test(relativePath)) {
result.push(relativePath);
}
});
return result;
}
const absoluteDirectory = resolve(basedir, directory);

const keys = enumerateFiles(absoluteDirectory, '.');
function requireContext(key: string) {
if (!keys.includes(key)) {
throw new Error(`Cannot find module '${key}'`);
}
const fullKey = require('path').resolve(absoluteDirectory, key);
return require(fullKey);
}

readdirSync(normalizedPath).forEach((file) => {
require(join(normalizedPath, file));
});
requireContext.keys = () => keys;
return requireContext;
}

function encodeString(string: string) {
Expand All @@ -34,8 +55,7 @@ function encodeString(string: string) {
}

export function getStorybookInfo(): StoryGroupInfo[] {
requireAllStories();

configure(requireAllStories(__dirname, '../stories'), module);
return getStorybook()
.filter(({ kind }) => kind)
.map(({ kind: group, stories: storiesRaw }) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
2 changes: 1 addition & 1 deletion integration/tests/bar-stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Bar series stories', () => {
describe('[test] switch ordinal/linear x axis', () => {
it('using ordinal x axis', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/bar-chart--test-switch-ordinal-linear-x-axis&knob-scaleType=ordinal',
'http://localhost:9001/?path=/story/bar-chart--test-switch-ordinal-linear-axis&knob-scaleType=ordinal',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/legend-stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Legend stories', () => {
});
it('should 0 legend buffer', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/legend--legend-spacingbuffer&knob-legend buffer value=0',
'http://localhost:9001/?path=/story/legend--legend-spacing-buffer&knob-legend buffer value=0',
);
});
});
Loading