File tree 5 files changed +48
-8
lines changed
story-starter/starters/nuxt
5 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ const {
21
21
goToPage,
22
22
} = await useStories ({ perPage: 10 });
23
23
24
+ const config = useConfig ({
25
+ selectedStories ,
26
+ });
27
+
28
+ console .log (' 💡 config' , config );
29
+
24
30
// Show top progress bar on page change.
25
31
watch (isLoading , () => {
26
32
if (! data .value ) {
Original file line number Diff line number Diff line change
1
+ import type { Story } from '~/types/story' ;
2
+ import config from '../stories.config' ;
3
+ import type { StoryConfig } from '~/types/config' ;
4
+
5
+ type UseConfig = ( props : { selectedStories : Ref < Story [ ] > } ) => Ref < StoryConfig > ;
6
+
7
+ export const useConfig : UseConfig = ( { selectedStories } ) => {
8
+ const resolvedConfig = ref < StoryConfig > (
9
+ typeof config === 'function' ? config ( selectedStories . value ) : config
10
+ ) ;
11
+
12
+ if ( typeof config === 'function' ) {
13
+ watch ( selectedStories , ( ) => {
14
+ resolvedConfig . value =
15
+ typeof config === 'function' ? config ( selectedStories . value ) : config ;
16
+ } ) ;
17
+ }
18
+
19
+ return resolvedConfig ;
20
+ } ;
Original file line number Diff line number Diff line change 1
- //draft for future actions implementations
2
- type StoryConfig = {
3
- actions : {
4
- label : string ;
5
- handler : ( selectedStories : any ) => void ;
6
- } [ ] ;
7
- } ;
1
+ import type { StoryConfig } from '~/types/config' ;
2
+ import type { Story } from '~/types/story' ;
8
3
9
- export const defineStoryConfig = ( config : StoryConfig ) : StoryConfig => config ;
4
+ type StoryConfigGetter = ( selectedStories : Story [ ] ) => StoryConfig ;
5
+
6
+ export const defineStoryConfig = ( config : StoryConfig | StoryConfigGetter ) =>
7
+ config ;
Original file line number Diff line number Diff line change 1
1
import { defineStoryConfig } from '~/shared/defineStoryConfig' ;
2
2
3
+ // export default defineStoryConfig((selecte) => ({
4
+ // actions: [
5
+ // {
6
+ // label: 'Translate',
7
+ // handler: (selectedStories) => {},
8
+ // },
9
+ // ],
10
+ // }));
11
+
3
12
export default defineStoryConfig ( {
4
13
actions : [
5
14
{
Original file line number Diff line number Diff line change
1
+ //draft for future actions implementations
2
+ export type StoryConfig = {
3
+ actions : {
4
+ label : string ;
5
+ handler : ( selectedStories : any ) => void ;
6
+ } [ ] ;
7
+ } ;
You can’t perform that action at this time.
0 commit comments