Skip to content

Commit

Permalink
Support more options for CSF autoTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
jonspalmer committed Jul 28, 2021
1 parent 360c6e2 commit 11e078d
Show file tree
Hide file tree
Showing 26 changed files with 27 additions and 38 deletions.
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
2 changes: 1 addition & 1 deletion app/server/src/lib/compiler/__testfixtures__/a11y.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
};

export const Label = {
storyName: \\"Label\\",
name: \\"Label\\",
parameters: {
server: {
id: \\"addons/a11y/label\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
};

export const Multiple_actions_config = {
storyName: \\"Multiple actions + config\\",
name: \\"Multiple actions + config\\",
parameters: {
actions: [
\\"click\\",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
};

export const Story_1 = {
storyName: \\"Story 1\\",
name: \\"Story 1\\",
parameters: {
server: {
id: \\"addons/backgrounds/story1\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
};

export const Simple = {
storyName: \\"Simple\\",
name: \\"Simple\\",
parameters: {
server: {
id: \\"addons/controls/simple\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
};

export const Heading = {
storyName: \\"Heading\\",
name: \\"Heading\\",
parameters: {
actions: [
\\"click\\",
Expand All @@ -51,7 +51,7 @@ export const Heading = {
};

export const Button = {
storyName: \\"Button\\",
name: \\"Button\\",
parameters: {
server: {
id: \\"demo/button\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
};

export const Welcome = {
storyName: \\"Welcome\\",
name: \\"Welcome\\",
parameters: {
server: {
id: \\"welcome/welcome\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
};

export const Heading = {
storyName: \\"Heading\\",
name: \\"Heading\\",
parameters: {
server: {
id: \\"demo/heading\\"
Expand All @@ -16,7 +16,7 @@ export const Heading = {
};

export const Headings = {
storyName: \\"Headings\\",
name: \\"Headings\\",
parameters: {
server: {
id: \\"demo/headings\\"
Expand All @@ -25,7 +25,7 @@ export const Headings = {
};

export const Button = {
storyName: \\"Button\\",
name: \\"Button\\",
parameters: {
server: {
id: \\"demo/button\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
};

export const Story = {
storyName: \\"Story\\",
name: \\"Story\\",
parameters: {
server: {
id: \\"params/story\\",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
};

export const Override = {
storyName: \\"Override\\",
name: \\"Override\\",
parameters: {
server: {
id: \\"params/override\\",
Expand Down
6 changes: 3 additions & 3 deletions app/server/src/lib/compiler/__testfixtures__/yaml.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
};

export const Heading = {
storyName: \\"Heading\\",
name: \\"Heading\\",
parameters: {
server: {
id: \\"yaml/heading\\"
Expand All @@ -16,7 +16,7 @@ export const Heading = {
};

export const Headings = {
storyName: \\"Headings\\",
name: \\"Headings\\",
parameters: {
server: {
id: \\"yaml/headings\\"
Expand All @@ -25,7 +25,7 @@ export const Headings = {
};

export const Button = {
storyName: \\"Button\\",
name: \\"Button\\",
parameters: {
server: {
id: \\"yaml/button\\"
Expand Down
6 changes: 3 additions & 3 deletions app/server/src/lib/compiler/__testfixtures__/yml.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
};

export const Heading = {
storyName: \\"Heading\\",
name: \\"Heading\\",
parameters: {
server: {
id: \\"yaml/heading\\"
Expand All @@ -16,7 +16,7 @@ export const Heading = {
};

export const Headings = {
storyName: \\"Headings\\",
name: \\"Headings\\",
parameters: {
server: {
id: \\"yaml/headings\\"
Expand All @@ -25,7 +25,7 @@ export const Headings = {
};

export const Button = {
storyName: \\"Button\\",
name: \\"Button\\",
parameters: {
server: {
id: \\"yaml/button\\"
Expand Down
2 changes: 1 addition & 1 deletion app/server/src/lib/compiler/stringifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function stringifyStory(story: StorybookStory): string {
const { name, ...options } = story;
const storyId = identifier(name);

const exportedStory = { storyName: name, ...options };
const exportedStory = { name, ...options };

const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ''];

Expand Down
2 changes: 1 addition & 1 deletion examples/server-kitchen-sink/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
stories: ['../stories/**/*.stories.@(json|yaml)'],
stories: ['../stories/**/*.stories.@(json|yaml|yml)'],
logLevel: 'debug',
addons: [
'@storybook/addon-docs',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Addons/a11y",
"parameters": {
"options": {
"selectedPanel": "storybook/a11y/panel"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Addons/Actions",
"parameters": {
"options": { "selectedPanel": "storybook/actions/panel" }
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Addons/Backgrounds",
"parameters": {
"backgrounds": {
"default": "dark",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Addons/Controls",
"parameters": {
"options": { "selectedPanel": "storybook/controls/panel" }
},
Expand Down
1 change: 0 additions & 1 deletion examples/server-kitchen-sink/stories/demo.stories.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Demo",
"stories": [
{
"name": "Heading",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Html Content/Scripts",
"stories": [
{
"name": "Head Inline",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Html Content/Styles",
"stories": [
{
"name": "Head Inline",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Kitchen Sink",
"addons": ["knobs"],
"parameters": {
"backgrounds": {
Expand Down
1 change: 0 additions & 1 deletion examples/server-kitchen-sink/stories/params.stories.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Params",
"parameters": {
"server": {
"params": { "color": "red" }
Expand Down
1 change: 0 additions & 1 deletion examples/server-kitchen-sink/stories/welcome.stories.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Welcome",
"stories": [
{
"name": "Welcome",
Expand Down
1 change: 0 additions & 1 deletion examples/server-kitchen-sink/stories/yaml.stories.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
title: Demo YAML
stories:
- name: Heading
parameters:
Expand Down
1 change: 0 additions & 1 deletion examples/server-kitchen-sink/stories/yml.stories.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
title: Demo YML
stories:
- name: Heading
parameters:
Expand Down

0 comments on commit 11e078d

Please sign in to comment.