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

cli: colocate stories and components, centralize main.js #10913

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
dae9d40
rename generator
tooppaaa May 25, 2020
5597f5a
CLI: react stories
tooppaaa May 25, 2020
b2d5744
fix build
tooppaaa May 25, 2020
fb1a124
fixes
tooppaaa May 25, 2020
8434dcc
fix tests
tooppaaa May 25, 2020
8673294
fix unit test
tooppaaa May 25, 2020
2b5372e
fix lint
tooppaaa May 25, 2020
93eaae0
fix tests
tooppaaa May 25, 2020
665163d
fix unit test
tooppaaa May 25, 2020
7cf2595
Feedbacks
tooppaaa May 26, 2020
f535af4
Move ember
tooppaaa May 26, 2020
2783b12
Move Meteor
tooppaaa May 26, 2020
79d6b00
Move mithril
tooppaaa May 26, 2020
06e3c14
Move preact
tooppaaa May 26, 2020
fb3845d
Move rax
tooppaaa May 26, 2020
5ba3eef
Move riot
tooppaaa May 26, 2020
ba37d85
Move svelte
tooppaaa May 26, 2020
4722220
Move marko and cleanup
tooppaaa May 26, 2020
0e2f5f6
Move marionette
tooppaaa May 26, 2020
cdea7b9
Move vue
tooppaaa May 26, 2020
6d3eec2
Move html
tooppaaa May 26, 2020
6aad11e
no tabs
ndelangen May 28, 2020
c40b550
Merge remote-tracking branch 'origin/next' into tech/colocateReactSto…
tooppaaa May 28, 2020
858ff9f
Merge branch 'tech/colocateReactStories' into tech/colocateSomeStories
tooppaaa May 28, 2020
62d58b2
Merge pull request #10935 from storybookjs/tech/colocateSomeStories
tooppaaa May 28, 2020
10dbb81
Move WebComponents
tooppaaa May 28, 2020
6a29fb0
Move react-native
tooppaaa May 28, 2020
15f14a3
Move & clean aurelia
tooppaaa May 28, 2020
5931abc
Move and clean Angular
tooppaaa May 28, 2020
29f0473
Oops
tooppaaa May 28, 2020
b3a46d8
fix tests
tooppaaa May 29, 2020
61f6968
Merge remote-tracking branch 'origin/next' into tech/colocateReactSto…
tooppaaa Jun 5, 2020
e052b64
Merge branch 'tech/colocateReactStories' into tech/colocateMoreStories
tooppaaa Jun 5, 2020
2ce9d3e
Merge pull request #10972 from storybookjs/tech/colocateMoreStories
tooppaaa Jun 5, 2020
dde7de4
add angular stories back
tooppaaa Jun 5, 2020
4ef5c55
fix aurelia
tooppaaa Jun 5, 2020
68d6644
fix welcome story
tooppaaa Jun 5, 2020
fde26b3
remove plugin-external-helpers from fixtures
tooppaaa Jun 6, 2020
6802976
Merge remote-tracking branch 'origin/next' into tech/colocateReactSto…
tooppaaa Jun 7, 2020
6dc8533
merge
tooppaaa Jun 7, 2020
0002cd9
fix copy template when needed
tooppaaa Jun 7, 2020
5fda409
fix build
tooppaaa Jun 7, 2020
eb0cd84
switch to docs over essentials
tooppaaa Jun 8, 2020
5cb9011
fix build
tooppaaa Jun 8, 2020
c928b20
make it green
tooppaaa Jun 8, 2020
fbb5d89
Fix yarn 2
tooppaaa Jun 9, 2020
2570a66
fix(cli): use the same list of addons to build `main.js` as the one a…
gaetanmaisse Jun 9, 2020
0e8ae86
fix(cli): add peer deps of storybook addons when init a project
gaetanmaisse Jun 9, 2020
6e68926
PR Feedbacks
tooppaaa Jun 9, 2020
aca5302
Use docs & actions for now
tooppaaa Jun 9, 2020
d7113b5
Merge branch 'next' into tech/colocateReactStories
ndelangen Jun 10, 2020
afffa12
Revert "remove plugin-external-helpers from fixtures"
tooppaaa Jun 11, 2020
bf7616d
move vue
tooppaaa Jun 11, 2020
638b51e
Merge remote-tracking branch 'origin/next' into tech/colocateReactSto…
tooppaaa Jun 11, 2020
669fdb8
finish merge
tooppaaa Jun 11, 2020
6fc491c
fix merge
tooppaaa Jun 11, 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
2 changes: 1 addition & 1 deletion addons/essentials/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export function addons(options: PresetOptions = {}) {
const main = requireMain(options.configDir);
return ['actions', 'docs', 'backgrounds', 'viewport']
.filter((key) => (options as any)[key] !== false)
.map((key) => `@storybook/addon-${key}`)
.map((key) => require.resolve(`@storybook/addon-${key}`))
.filter((addon) => !checkInstalled(addon, main));
}
3 changes: 0 additions & 3 deletions app/angular/src/demo/welcome.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ import { Component, Output, EventEmitter } from '@angular/core';
font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;
background-color: #ffffff;
}

.note {
opacity: 0.5;
}

.inline-code {
font-size: 15px;
font-weight: 600;
Expand All @@ -65,7 +63,6 @@ import { Component, Output, EventEmitter } from '@angular/core';
background-color: #f3f2f2;
color: #3a3a3a;
}

a {
color: #1474f3;
text-decoration: none;
Expand Down
4 changes: 0 additions & 4 deletions app/aurelia/demo.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions app/aurelia/demo.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/aurelia/src/demo/index.ts

This file was deleted.

12 changes: 5 additions & 7 deletions examples/aurelia-kitchen-sink/src/stories/mdx.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
import { CoolButton } from '../cool-button/cool-button';
import { Button } from '@storybook/aurelia/demo';
import { addComponents } from '@storybook/aurelia';
import { text, withKnobs, } from '@storybook/addon-knobs';
import { text, withKnobs } from '@storybook/addon-knobs';
import Button from './button';

<Meta title="Welcome" component={CoolButton} decorators={[withKnobs]}/>
<Meta title="Welcome" component={CoolButton} decorators={[withKnobs]} />

# Welcome

Expand All @@ -15,10 +15,8 @@ This is a test document written in MDX that defines a `CoolButton` story wrapped
{{
template: `<cool-button text.bind="testText"></cool-button>`,
state: {
testText: text('asfdafds', 'asasfdsa')
}
testText: text('asfdafds', 'asasfdsa'),
},
}}
</Story>
</Preview>


1 change: 1 addition & 0 deletions lib/cli/.babelrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
]
],
"ignore": [
"./src/frameworks",
"./src/generators/**/template",
"./src/generators/**/template-csf",
"./src/generators/**/template-csf-ts",
Expand Down
18 changes: 16 additions & 2 deletions lib/cli/src/generators/.eslintrc.js → lib/cli/src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ const ignore = 0;
module.exports = {
overrides: [
{
files: '*/template[-?]*/**',
files: '**/template[-?]*/**',
env: {
browser: true,
},
rules: {
'react/no-this-in-sfc': ignore,
'import/no-unresolved': ignore,
'react/react-in-jsx-scope': ignore,
'import/no-extraneous-dependencies': ignore,
'global-require': ignore,
'react/react-in-jsx-scope': ignore,
'no-redeclare': ignore,
},
},
{
Expand All @@ -21,5 +22,18 @@ module.exports = {
browser: false,
},
},
{
files: 'frameworks/**/*',
env: {
browser: true,
},
rules: {
'jsx-a11y/anchor-is-valid': ignore,
'import/no-unresolved': ignore,
'react/prop-types': ignore,
'react/react-in-jsx-scope': ignore,
'import/no-extraneous-dependencies': ignore,
},
},
],
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Welcome } from '@storybook/aurelia/demo';
import Welcome from './welcome.component';

export default {
title: 'Welcome',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';

import { Button } from '@storybook/angular/demo';
import Button from './button.component';

export default {
title: 'Button',
Expand Down
26 changes: 26 additions & 0 deletions lib/cli/src/frameworks/angular/button.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'storybook-button-component',
template: ` <button (click)="onClick.emit($event)">{{ text }}</button> `,
styles: [
`
button {
border: 1px solid #eee;
border-radius: 3px;
background-color: #ffffff;
cursor: pointer;
font-size: 15px;
padding: 3px 10px;
margin: 10px;
}
`,
],
})
export default class ButtonComponent {
@Input()
text = '';

@Output()
onClick = new EventEmitter<any>();
}
81 changes: 81 additions & 0 deletions lib/cli/src/frameworks/angular/welcome.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Component, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'storybook-welcome-component',
template: `
<main>
<h1>Welcome to storybook</h1>
<p>This is a UI component dev environment for your app.</p>
<p>
We've added some basic stories inside the
<span class="inline-code">src/stories</span> directory. <br />
A story is a single state of one or more UI components. You can have as many stories as you
want. <br />
(Basically a story is like a visual test case.)
</p>
<p>
See these sample
<a (click)="showApp.emit($event)" role="button" tabIndex="0">stories</a> for a component
called <span class="inline-code">Button</span> .
</p>
<p>
Just like that, you can add your own components as stories. <br />
You can also edit those components and see changes right away. <br />
(Try editing the <span class="inline-code">Button</span> stories located at
<span class="inline-code">src/stories/index.js</span>.)
</p>
<p>
Usually we create stories with smaller UI components in the app.<br />
Have a look at the
<a
href="https://storybook.js.org/basics/writing-stories"
target="_blank"
rel="noopener noreferrer"
>
Writing Stories
</a>
section in our documentation.
</p>
<p class="note">
<b>NOTE:</b> <br />
Have a look at the <span class="inline-code">.storybook/webpack.config.js</span> to add
webpack loaders and plugins you are using in this project.
</p>
</main>
`,
styles: [
`
main {
padding: 15px;
line-height: 1.4;
font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;
background-color: #ffffff;
}

.note {
opacity: 0.5;
}

.inline-code {
font-size: 15px;
font-weight: 600;
padding: 2px 5px;
border: 1px solid #eae9e9;
border-radius: 4px;
background-color: #f3f2f2;
color: #3a3a3a;
}

a {
color: #1474f3;
text-decoration: none;
border-bottom: 1px solid #1474f3;
padding-bottom: 2px;
}
`,
],
})
export default class WelcomeComponent {
@Output()
showApp = new EventEmitter<any>();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Welcome } from '@storybook/angular/demo';
import Welcome from './welcome';

export default {
title: 'Welcome',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';

import { Button } from '@storybook/aurelia/demo';
import Button from './button';

export default {
title: 'Button',
Expand Down
28 changes: 28 additions & 0 deletions lib/cli/src/frameworks/aurelia/button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { customElement, bindable } from 'aurelia';

@customElement({
name: 'storybook-button-component',
template: `
<template>
<button click.delegate="onClick($event)">\${text}</button>
<style>
button {
border: 1px solid #eee;
border-radius: 3px;
background-color: #ffffff;
cursor: pointer;
font-size: 15px;
padding: 3px 10px;
margin: 10px;
}
</style>
</template>
`,
})
export default class Button {
@bindable()
text = '';

@bindable()
onClick: MouseEvent;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Marionette from 'backbone.marionette';
import { View } from 'backbone.marionette';

import { storiesOf } from '@storybook/marionette';

storiesOf('Demo', module).add(
'button',
() =>
new Marionette.View({
new View({
template: () => '<button id="my_button">some button</button>',
ui: {
button: '#my_button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Welcome from './components/welcome/index.marko';
import Welcome from './welcome.marko';

export default {
title: 'Welcome',
Expand Down
37 changes: 37 additions & 0 deletions lib/cli/src/frameworks/marko/welcome.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

class {
onCreate() {}
}

style {
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}

h1, h2 {
font-weight: normal;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: inline-block;
margin: 0 10px;
}

a {
color: #42b983;
}
}

<div#app>
<h1>Welcome to storybook</h1>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsx h */
/* eslint-disable react/no-unknown-property, react/prop-types */
/* eslint-disable react/no-unknown-property */
import { h } from 'preact';

const Button = ({ children, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const Main = (props) => (
/>
);

// eslint-disable-next-line react/prop-types
const Title = ({ children, ...props }) => <h1 {...props}>{children}</h1>;

const Note = (props) => (
Expand All @@ -40,7 +39,6 @@ const InlineCode = (props) => (
/>
);

// eslint-disable-next-line react/prop-types
const Link = ({ children, href, ...props }) => (
<a
href={href}
Expand All @@ -56,7 +54,6 @@ const Link = ({ children, href, ...props }) => (
</a>
);

// eslint-disable-next-line react/prop-types
const NavButton = ({ children, ...props }) => (
<button
{...props}
Expand All @@ -79,7 +76,6 @@ const NavButton = ({ children, ...props }) => (
</button>
);

/* eslint-disable-next-line react/prop-types */
const Welcome = ({ showApp }) => (
<Main>
<Title>Welcome to storybook</Title>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types, jsx-a11y/anchor-is-valid */
import { createElement } from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '@storybook/react/demo';
import { Welcome } from './Welcome';

export default {
title: 'Welcome',
Expand Down
Loading