Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Storybook setup #2

Merged
merged 7 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 1 addition & 0 deletions packages/structure-core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# compiled output
/dist/
/tmp/
/.storybook/preview-head.html

# dependencies
/bower_components/
Expand Down
14 changes: 14 additions & 0 deletions packages/structure-core/.storybook/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
shippedProposals: true,
useBuiltIns: 'usage',
corejs: '3',
targets: ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'],
},
],
],
};

6 changes: 6 additions & 0 deletions packages/structure-core/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
addons: [
'@storybook/addon-docs',
],
stories: ['../stories/**/*.stories.(js|mdx)'],
};
4 changes: 4 additions & 0 deletions packages/structure-core/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { setJSONDoc } from '@storybook/addon-docs/ember';
import json from '../dist/storybook-docgen/index.json';

setJSONDoc(json);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import hbs from 'htmlbars-inline-precompile';

export default {
title: 'Structure | <%= angleBracketInvocation %>',
component: '<%= classifiedModuleName %>',
};

// add stories by adding more exported functions
export let <%= classifiedModuleName %> = () => ({
template: hbs`<<%= angleBracketInvocation %> />`,
context: {
// add items to the component rendering context here
}
});
3 changes: 3 additions & 0 deletions packages/structure-core/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
'ember-cli-storybook': {
enableAddonDocsIntegration: true,
}
// Add options here
});

Expand Down
23 changes: 23 additions & 0 deletions packages/structure-core/node-tests/blueprints/st-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ let expectedTestBlockRenderInvocation = `
</St::Foo>
\`)`;

let expectedStoryDefaultExport =`export default {
title: 'Structure | St::Foo',
component: 'StFoo',
};`

let expectedStoryExport = `export let StFoo = () => ({
template: hbs\`<St::Foo />\`,`;

let td = require('testdouble');
td.config({ promiseConstructor: require('rsvp').Promise });

Expand Down Expand Up @@ -124,4 +132,19 @@ describe('Acceptance: ember generate and destroy st-component', function() {
});
});

it(`generates a story file for 'foo'`, function() {
return test('foo', file => {
expect(file('stories/st/foo.stories.js'))
.to.contain(expectedStoryDefaultExport)
.to.contain(expectedStoryExport);
});
});

it(`generates a story file for 'st/foo'`, function() {
return test('st/foo', file => {
expect(file('stories/st/foo.stories.js'))
.to.contain(expectedStoryDefaultExport)
.to.contain(expectedStoryExport);
});
});
});
10 changes: 9 additions & 1 deletion packages/structure-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@
"start": "ember serve",
"test": "ember test",
"test:all": "ember try:each",
"nodetest": "mocha node-tests --recursive"
"nodetest": "mocha node-tests --recursive",
"storybook": "start-storybook -p 6006 -s dist",
"storybook:build": "build-storybook",
"storybook:docs-deploy": "yarn build -prod && build-storybook --docs"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should do a build w/o the canvas tab - I think that's what we want but if not we can change it later

},
"dependencies": {
"ember-cli-babel": "^7.11.1",
"ember-cli-htmlbars": "^4.0.5"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@ember/optional-features": "^1.0.0",
"@storybook/addon-docs": "^5.3.0-rc.7",
"@storybook/ember": "^5.3.0-rc.7",
"@storybook/ember-cli-storybook": "^0.2.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.0-beta.6",
"broccoli-asset-rev": "^3.0.0",
"chalk": "^3.0.0",
"ember-auto-import": "^1.5.2",
Expand Down
6 changes: 6 additions & 0 deletions packages/structure-core/stories/1-welcome.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Meta } from '@storybook/addon-docs/blocks';

<Meta title="Welcome" />

# HashiCorp Structure
[Code home](https://github.com/hashicorp/structure)
Loading