diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-01-09 11:05:32 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-01-09 11:05:32 +0100 |
commit | 2c514e58eabd71af280b727514dccb7c8db4e6cf (patch) | |
tree | b9677f450fe300c6ff16d1ea1e2af7ea35a7bc02 /uidev/src/stores | |
parent | Make packages work in electron, node and web (diff) | |
download | ferdium-app-2c514e58eabd71af280b727514dccb7c8db4e6cf.tar.gz ferdium-app-2c514e58eabd71af280b727514dccb7c8db4e6cf.tar.zst ferdium-app-2c514e58eabd71af280b727514dccb7c8db4e6cf.zip |
Finalize packages & replace storybook with homegrown `uidev`
Diffstat (limited to 'uidev/src/stores')
-rw-r--r-- | uidev/src/stores/index.ts | 5 | ||||
-rw-r--r-- | uidev/src/stores/stories.ts | 43 |
2 files changed, 48 insertions, 0 deletions
diff --git a/uidev/src/stores/index.ts b/uidev/src/stores/index.ts new file mode 100644 index 000000000..276058ec4 --- /dev/null +++ b/uidev/src/stores/index.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { storyStore } from './stories'; | ||
2 | |||
3 | export const store = { | ||
4 | stories: storyStore, | ||
5 | }; | ||
diff --git a/uidev/src/stores/stories.ts b/uidev/src/stores/stories.ts new file mode 100644 index 000000000..064bf275f --- /dev/null +++ b/uidev/src/stores/stories.ts | |||
@@ -0,0 +1,43 @@ | |||
1 | import { store } from './index'; | ||
2 | |||
3 | export type StorySectionName = string; | ||
4 | export type StoryName = string; | ||
5 | export type StoryComponent = Function; | ||
6 | |||
7 | export interface IStories { | ||
8 | name: string; | ||
9 | component: StoryComponent; | ||
10 | } | ||
11 | |||
12 | export interface ISections { | ||
13 | name: StorySectionName; | ||
14 | stories: IStories[]; | ||
15 | } | ||
16 | |||
17 | export interface IStoryStore { | ||
18 | sections: ISections[]; | ||
19 | } | ||
20 | |||
21 | export const storyStore: IStoryStore = { | ||
22 | sections: [], | ||
23 | }; | ||
24 | |||
25 | export const storiesOf = (name: StorySectionName) => { | ||
26 | const length = storyStore.sections.push({ | ||
27 | name, | ||
28 | stories: [], | ||
29 | }); | ||
30 | |||
31 | const actions = { | ||
32 | add: (name: StoryName, component: StoryComponent) => { | ||
33 | storyStore.sections[length - 1].stories.push({ | ||
34 | name, | ||
35 | component, | ||
36 | }); | ||
37 | |||
38 | return actions; | ||
39 | }, | ||
40 | }; | ||
41 | |||
42 | return actions; | ||
43 | }; | ||