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

Server: Upgrade to CSF3 #15698

Merged
merged 5 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 7 additions & 6 deletions app/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {

Notice that the JSON does not specify a rendering function -- `@storybook/server` will instead call your `parameters.server.url` with the story's server id appended.

For example the JSON story above is requivalent to the CSF definition:
For example the JSON story above is requivalent to the CSF3 definition:

```javascript
export default {
Expand All @@ -74,11 +74,12 @@ export default {
},
};

export const Default = (args) => {};
Default.storyName = 'Default';
Default.parameters = {
server: {
id: 'path/of/your/story"',
export const Default = {
name: 'Default',
parameters: {
server: {
id: 'path/of/your/story"',
},
},
};
```
Expand Down
5 changes: 4 additions & 1 deletion app/server/src/client/preview/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { start } from '@storybook/core/client';
import { ClientStoryApi, Loadable } from '@storybook/addons';
import { ClientStoryApi, Loadable, StoryFn, Args } from '@storybook/addons';

import './globals';
import { renderMain as render } from './render';
Expand All @@ -16,7 +16,10 @@ interface ClientApi extends ClientStoryApi<StoryFnServerReturnType> {
raw: () => any; // todo add type
}

const globalRender: StoryFn = (args: Args) => {};

const api = start(render);
api.clientApi.globalRender = globalRender;

export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({
Expand Down
11 changes: 6 additions & 5 deletions app/server/src/lib/compiler/__testfixtures__/a11y.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export default {
}
};

export const Label = (args) => {};
Label.storyName = 'Label';
Label.parameters = {
server: {
id: \\"addons/a11y/label\\"
export const Label = {
name: \\"Label\\",
parameters: {
server: {
id: \\"addons/a11y/label\\"
}
}
};
"
Expand Down
23 changes: 12 additions & 11 deletions app/server/src/lib/compiler/__testfixtures__/actions.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ export default {
}
};

export const Multiple_actions_config = (args) => {};
Multiple_actions_config.storyName = 'Multiple actions + config';
Multiple_actions_config.parameters = {
actions: [
\\"click\\",
\\"contextmenu\\",
{
clearOnStoryChange: false
export const Multiple_actions_config = {
name: \\"Multiple actions + config\\",
parameters: {
actions: [
\\"click\\",
\\"contextmenu\\",
{
clearOnStoryChange: false
}
],
server: {
id: \\"addons/actions/story3\\"
}
],
server: {
id: \\"addons/actions/story3\\"
}
};
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ export default {
}
};

export const Story_1 = (args) => {};
Story_1.storyName = 'Story 1';
Story_1.parameters = {
server: {
id: \\"addons/backgrounds/story1\\"
export const Story_1 = {
name: \\"Story 1\\",
parameters: {
server: {
id: \\"addons/backgrounds/story1\\"
}
}
};
"
Expand Down
77 changes: 39 additions & 38 deletions app/server/src/lib/compiler/__testfixtures__/controls.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,49 @@ export default {
}
};

export const Simple = (args) => {};
Simple.storyName = 'Simple';
Simple.parameters = {
server: {
id: \\"addons/controls/simple\\"
}
};
Simple.args = {
name: \\"John Doe\\",
birthday: \\"1960-12-25T00:42:03.600Z\\",
favorite_color: \\"red\\",
active: true,
pets: 2,
sports: [
\\"football\\",
\\"baseball\\"
],
favorite_food: \\"Ice Cream\\",
other_things: {
hair: \\"Brown\\",
eyes: \\"Blue\\"
}
};
Simple.argTypes = {
birthday: {
control: {
type: \\"date\\"
export const Simple = {
name: \\"Simple\\",
parameters: {
server: {
id: \\"addons/controls/simple\\"
}
},
favorite_color: {
control: {
type: \\"color\\"
args: {
name: \\"John Doe\\",
birthday: \\"1960-12-25T00:42:03.600Z\\",
favorite_color: \\"red\\",
active: true,
pets: 2,
sports: [
\\"football\\",
\\"baseball\\"
],
favorite_food: \\"Ice Cream\\",
other_things: {
hair: \\"Brown\\",
eyes: \\"Blue\\"
}
},
favorite_food: {
control: {
type: \\"select\\",
options: {
hot_dog: \\"Hot Dog\\",
pizza: \\"Pizza\\",
burgers: \\"Burgers\\",
ice_cream: \\"Ice Cream\\"
argTypes: {
birthday: {
control: {
type: \\"date\\"
}
},
favorite_color: {
control: {
type: \\"color\\"
}
},
favorite_food: {
control: {
type: \\"select\\",
options: {
hot_dog: \\"Hot Dog\\",
pizza: \\"Pizza\\",
burgers: \\"Burgers\\",
ice_cream: \\"Ice Cream\\"
}
}
}
}
Expand Down
48 changes: 25 additions & 23 deletions app/server/src/lib/compiler/__testfixtures__/kitchen_sink.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,35 @@ export default {
}
};

export const Heading = (args) => {};
Heading.storyName = 'Heading';
Heading.parameters = {
actions: [
\\"click\\",
\\"contextmenu\\",
{
clearOnStoryChange: false
}
],
server: {
id: \\"demo/heading\\",
params: {
color: \\"orange\\"
export const Heading = {
name: \\"Heading\\",
parameters: {
actions: [
\\"click\\",
\\"contextmenu\\",
{
clearOnStoryChange: false
}
],
server: {
id: \\"demo/heading\\",
params: {
color: \\"orange\\"
}
}
},
args: {
name: \\"John Doe\\",
age: 44
}
};
Heading.args = {
name: \\"John Doe\\",
age: 44
};

export const Button = (args) => {};
Button.storyName = 'Button';
Button.parameters = {
server: {
id: \\"demo/button\\"
export const Button = {
name: \\"Button\\",
parameters: {
server: {
id: \\"demo/button\\"
}
}
};
"
Expand Down
11 changes: 6 additions & 5 deletions app/server/src/lib/compiler/__testfixtures__/links.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ export default {
title: \\"Welcome\\",
};

export const Welcome = (args) => {};
Welcome.storyName = 'Welcome';
Welcome.parameters = {
server: {
id: \\"welcome/welcome\\"
export const Welcome = {
name: \\"Welcome\\",
parameters: {
server: {
id: \\"welcome/welcome\\"
}
}
};
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ export default {
title: \\"Demo\\",
};

export const Heading = (args) => {};
Heading.storyName = 'Heading';
Heading.parameters = {
server: {
id: \\"demo/heading\\"
export const Heading = {
name: \\"Heading\\",
parameters: {
server: {
id: \\"demo/heading\\"
}
}
};

export const Headings = (args) => {};
Headings.storyName = 'Headings';
Headings.parameters = {
server: {
id: \\"demo/headings\\"
export const Headings = {
name: \\"Headings\\",
parameters: {
server: {
id: \\"demo/headings\\"
}
}
};

export const Button = (args) => {};
Button.storyName = 'Button';
Button.parameters = {
server: {
id: \\"demo/button\\"
export const Button = {
name: \\"Button\\",
parameters: {
server: {
id: \\"demo/button\\"
}
}
};
"
Expand Down
15 changes: 8 additions & 7 deletions app/server/src/lib/compiler/__testfixtures__/params.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ export default {
}
};

export const Story = (args) => {};
Story.storyName = 'Story';
Story.parameters = {
server: {
id: \\"params/story\\",
params: {
message: \\"Hello World\\"
export const Story = {
name: \\"Story\\",
parameters: {
server: {
id: \\"params/story\\",
params: {
message: \\"Hello World\\"
}
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ export default {
}
};

export const Override = (args) => {};
Override.storyName = 'Override';
Override.parameters = {
server: {
id: \\"params/override\\",
params: {
message: \\"Hello World\\",
color: \\"green\\"
export const Override = {
name: \\"Override\\",
parameters: {
server: {
id: \\"params/override\\",
params: {
message: \\"Hello World\\",
color: \\"green\\"
}
}
}
};
Expand Down
Loading