Skip to content

Commit

Permalink
feat: move controls to main story props
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 16, 2020
1 parent a1e72aa commit 5aeea92
Show file tree
Hide file tree
Showing 18 changed files with 391 additions and 427 deletions.
2 changes: 2 additions & 0 deletions core/loader/src/story-store-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const loadStoryStore = (): StoriesStore | undefined => {
} catch (e) {
console.error(`unable to load module ${kind.moduleId}`);
}
// clean-up
delete kind.moduleId;
}
globalStore.kinds[kindName] = kind;
Object.keys(store.stories).forEach(storyName => {
Expand Down
12 changes: 12 additions & 0 deletions core/specification/src/stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CodeLocation, Repository } from './utility';
import { StoryComponent } from './components';
import { ComponentControls } from './controls';

/**
* an identifier/variable.argument in the source code
Expand Down Expand Up @@ -106,6 +107,11 @@ export interface Story {
* id for component associated with the story
*/
component?: string;

/**
* object of key/value pairs specifying the controls for the story
*/
controls?: ComponentControls;
}

/**
Expand Down Expand Up @@ -180,6 +186,12 @@ export interface StoriesKind {

includeStories?: string[] | RegExp;

/**
* object of key/value pairs specifying the controls for the stories file
* this will apply to all the stories in the file
*/
controls?: ComponentControls;

[name: string]: any;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ export const docsControlsTable = ({ name, age }: DocsControlsTable) => {
};

docsControlsTable.story = {
parameters: {
controls: {
name: { type: ControlTypes.TEXT, label: 'Name', value: 'Mark' },
age: { type: ControlTypes.NUMBER, label: 'Age', value: 19, min: 10, max: 75 },
clickMe: {
type: ControlTypes.BUTTON,
label: 'button click',
onClick: () => {console.log('log')},
},
controls: {
name: { type: ControlTypes.TEXT, label: 'Name', value: 'Mark' },
age: { type: ControlTypes.NUMBER, label: 'Age', value: 19, min: 10, max: 75 },
clickMe: {
type: ControlTypes.BUTTON,
label: 'button click',
onClick: () => {console.log('log')},
},
}
},
};
Loading

0 comments on commit 5aeea92

Please sign in to comment.