Skip to content

Commit

Permalink
Angular-cli: Add addon-docs example (#7257)
Browse files Browse the repository at this point in the history
Angular-cli: Add addon-docs example
  • Loading branch information
shilman authored Jul 5, 2019
2 parents 6f733a8 + f16c732 commit 4aa3a71
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 64 deletions.
1 change: 1 addition & 0 deletions addons/docs/angular/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../common/index');
1 change: 1 addition & 0 deletions addons/docs/angular/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../common/preset');
20 changes: 8 additions & 12 deletions examples/angular-cli/.storybook/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable global-require */
import { configure, addParameters, addDecorator } from '@storybook/angular';
import { load, addParameters, addDecorator } from '@storybook/angular';
import { withA11y } from '@storybook/addon-a11y';
import { DocsPage } from '@storybook/addon-docs/blocks';
import addCssWarning from '../src/cssWarning';

addDecorator(withA11y);
Expand All @@ -9,16 +9,12 @@ addCssWarning();
addParameters({
options: {
hierarchyRootSeparator: /\|/,
docs: {
iframeHeight: '60px',
},
},
docs: DocsPage,
});

function loadStories() {
// put welcome screen at the top of the list so it's the first one displayed
require('../src/stories');

// automatically import all story ts files that end with *.stories.ts
const req = require.context('../src/stories', true, /\.stories\.ts$/);
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
load(require.context('../src/stories', true, /\.stories\.ts$/), module);
load(require.context('../src/stories', true, /\.stories\.mdx$/), module);
8 changes: 8 additions & 0 deletions examples/angular-cli/.storybook/presets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = [
{
name: '@storybook/addon-docs/angular/preset',
options: {
configureJSX: true,
},
},
];
2 changes: 2 additions & 0 deletions examples/angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
"@storybook/addon-jest": "5.2.0-alpha.36",
"@storybook/addon-knobs": "5.2.0-alpha.36",
"@storybook/addon-links": "5.2.0-alpha.36",
"@storybook/addon-docs": "5.2.0-alpha.36",
"@storybook/addon-notes": "5.2.0-alpha.36",
"@storybook/addon-options": "5.2.0-alpha.36",
"@storybook/addon-storyshots": "5.2.0-alpha.36",
"@storybook/addon-storysource": "5.2.0-alpha.36",
"@storybook/addons": "5.2.0-alpha.36",
"@storybook/angular": "5.2.0-alpha.36",
"@storybook/source-loader": "5.2.0-alpha.36",
"@types/core-js": "^2.5.0",
"@types/jest": "^24.0.11",
"@types/node": "~12.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ exports[`Storyshots Addon|Actions Action and method 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c4=""
_nghost-a-c1=""
>
<button
_ngcontent-a-c4=""
_ngcontent-a-c1=""
>
Action and Method
</button>
Expand All @@ -25,10 +25,10 @@ exports[`Storyshots Addon|Actions Action only 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c3=""
_nghost-a-c0=""
>
<button
_ngcontent-a-c3=""
_ngcontent-a-c0=""
>
Action only
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ exports[`Storyshots Addon|Background background template 1`] = `
>
<ng-component>
<storybook-button-component
_nghost-a-c5=""
_nghost-a-c2=""
ng-reflect-text="Hello Button"
>
<button
_ngcontent-a-c5=""
_ngcontent-a-c2=""
>
Hello Button
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ exports[`Storyshots Addon|Centered centered template 1`] = `
style="margin: auto; max-height: 100%;"
>
<storybook-button-component
_nghost-a-c6=""
_nghost-a-c3=""
ng-reflect-text="Hello Button"
>
<button
_ngcontent-a-c6=""
_ngcontent-a-c3=""
>
Hello Button
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ exports[`Storyshots Addon|Links button with link to another story 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c7=""
_nghost-a-c4=""
>
<button
_ngcontent-a-c7=""
_ngcontent-a-c4=""
>
Go to Welcome Story
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ exports[`Storyshots Addon|Notes Note with HTML 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c9=""
_nghost-a-c6=""
>
<button
_ngcontent-a-c9=""
_ngcontent-a-c6=""
>
Notes with HTML
</button>
Expand All @@ -25,10 +25,10 @@ exports[`Storyshots Addon|Notes Simple note 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c8=""
_nghost-a-c5=""
>
<button
_ngcontent-a-c8=""
_ngcontent-a-c5=""
>
Notes on some Button
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports[`Storyshots Core|Parameters passed to story 1`] = `
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-a-c10=""
_nghost-a-c7=""
>
<button
_ngcontent-a-c10=""
_ngcontent-a-c7=""
>
Parameters are {"options":{"hierarchyRootSeparator":{},"hierarchySeparator":{}},"globalParameter":"globalParameter","framework":"angular","chapterParameter":"chapterParameter","storyParameter":"storyParameter"}
Parameters are {"options":{"hierarchyRootSeparator":{},"hierarchySeparator":{},"docs":{"iframeHeight":"60px"}},"globalParameter":"globalParameter","framework":"angular","chapterParameter":"chapterParameter","storyParameter":"storyParameter"}
</button>
</storybook-button-component>
</storybook-dynamic-app-root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ exports[`Storyshots Custom|Style Default 1`] = `
>
<ng-component>
<storybook-button-component
_nghost-a-c11=""
_nghost-a-c8=""
ng-reflect-text="Button with custom styles"
>
<button
_ngcontent-a-c11=""
_ngcontent-a-c8=""
>
Button with custom styles
</button>
Expand All @@ -29,11 +29,11 @@ exports[`Storyshots Custom|Style With Knobs 1`] = `
>
<ng-component>
<storybook-button-component
_nghost-a-c12=""
_nghost-a-c9=""
ng-reflect-text="Button with custom styles"
>
<button
_ngcontent-a-c12=""
_ngcontent-a-c9=""
>
Button with custom styles
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ exports[`Storyshots Button with some emoji 1`] = `
>
<ng-component>
<storybook-button-component
_nghost-a-c2=""
_nghost-a-c12=""
ng-reflect-text="😀 😎 👍 💯"
>
<button
_ngcontent-a-c2=""
_ngcontent-a-c12=""
>
😀 😎 👍 💯
</button>
Expand All @@ -29,11 +29,11 @@ exports[`Storyshots Button with text 1`] = `
>
<ng-component>
<storybook-button-component
_nghost-a-c1=""
_nghost-a-c11=""
ng-reflect-text="Hello Button"
>
<button
_ngcontent-a-c1=""
_ngcontent-a-c11=""
>
Hello Button
</button>
Expand All @@ -50,98 +50,98 @@ exports[`Storyshots Welcome to Storybook 1`] = `
>
<ng-component>
<storybook-welcome-component
_nghost-a-c0=""
_nghost-a-c10=""
>
<main
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
<h1
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
Welcome to storybook
</h1>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
This is a UI component dev environment for your app.
</p>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
We've added some basic stories inside the
<span
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="inline-code"
>
src/stories
</span>
directory.
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
A story is a single state of one or more UI components. You can have as many stories as you want.
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
(Basically a story is like a visual test case.)
</p>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
See these sample
<a
_ngcontent-a-c0=""
_ngcontent-a-c10=""
role="button"
tabindex="0"
>
stories
</a>
for a component called
<span
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="inline-code"
>
Button
</span>
.
</p>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
Just like that, you can add your own components as stories.
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
You can also edit those components and see changes right away.
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
(Try editing the
<span
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="inline-code"
>
Button
</span>
stories located at
<span
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="inline-code"
>
src/stories/index.js
</span>
.)
</p>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
Usually we create stories with smaller UI components in the app.
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
Have a look at the
<a
_ngcontent-a-c0=""
_ngcontent-a-c10=""
href="https://storybook.js.org/basics/writing-stories"
rel="noopener noreferrer"
target="_blank"
Expand All @@ -151,20 +151,20 @@ exports[`Storyshots Welcome to Storybook 1`] = `
section in our documentation.
</p>
<p
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="note"
>
<b
_ngcontent-a-c0=""
_ngcontent-a-c10=""
>
NOTE:
</b>
<br
_ngcontent-a-c0=""
_ngcontent-a-c10=""
/>
Have a look at the
<span
_ngcontent-a-c0=""
_ngcontent-a-c10=""
class="inline-code"
>
.storybook/webpack.config.js
Expand Down
Loading

1 comment on commit 4aa3a71

@vercel
Copy link

@vercel vercel bot commented on 4aa3a71 Jul 5, 2019

Choose a reason for hiding this comment

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

Please sign in to comment.