1
- import { action } from "@storybook/addon-actions" ;
2
- import { ManagerContext } from "@storybook/manager-api" ;
3
- import type { Decorator , Loader , Preview } from "@storybook/react" ;
4
- import { fn } from "@storybook/test" ;
1
+ import { ManagerContext } from 'storybook/manager-api' ;
2
+ import type { Decorator , Loader , Preview } from '@storybook/react-vite' ;
3
+ import { fn } from 'storybook/test' ;
5
4
import {
6
5
Global ,
7
6
ThemeProvider ,
@@ -10,19 +9,20 @@ import {
10
9
styled ,
11
10
themes ,
12
11
useTheme ,
13
- } from "@ storybook/theming" ;
14
- import { HttpResponse , graphql } from " msw" ;
15
- import { initialize , mswLoader } from " msw-storybook-addon" ;
16
- import React from " react" ;
12
+ } from ' storybook/theming' ;
13
+ import { HttpResponse , graphql } from ' msw' ;
14
+ import { initialize , mswLoader } from ' msw-storybook-addon' ;
15
+ import React from ' react' ;
17
16
18
- import { AuthProvider } from "../src/AuthContext" ;
19
- import { baseModes } from "../src/modes" ;
20
- import { UninstallProvider } from "../src/screens/Uninstalled/UninstallContext" ;
21
- import { RunBuildProvider } from "../src/screens/VisualTests/RunBuildContext" ;
22
- import { GraphQLClientProvider } from "../src/utils/graphQLClient" ;
23
- import { storyWrapper } from "../src/utils/storyWrapper" ;
24
- import { TelemetryProvider } from "../src/utils/TelemetryContext" ;
25
- import { useSessionState } from "../src/utils/useSessionState" ;
17
+ import { AuthProvider } from '../src/AuthContext' ;
18
+ import { baseModes } from '../src/modes' ;
19
+ import { UninstallProvider } from '../src/screens/Uninstalled/UninstallContext' ;
20
+ import { RunBuildProvider } from '../src/screens/VisualTests/RunBuildContext' ;
21
+ import { GraphQLClientProvider } from '../src/utils/graphQLClient' ;
22
+ import { storyWrapper } from '../src/utils/storyWrapper' ;
23
+ import { TelemetryProvider } from '../src/utils/TelemetryContext' ;
24
+ import { useSessionState } from '../src/utils/useSessionState' ;
25
+ import { action } from 'storybook/actions' ;
26
26
27
27
// Initialize MSW
28
28
initialize ( {
@@ -38,34 +38,34 @@ initialize({
38
38
} ,
39
39
} ) ;
40
40
41
- const Panels = styled . div < { orientation : " right" | " bottom" } > (
41
+ const Panels = styled . div < { orientation : ' right' | ' bottom' } > (
42
42
( { orientation } ) => ( {
43
- flexDirection : orientation === " right" ? " row" : " column" ,
43
+ flexDirection : orientation === ' right' ? ' row' : ' column' ,
44
44
} ) ,
45
45
{
46
- display : " flex" ,
47
- justifyContent : " center" ,
48
- alignItems : " center" ,
46
+ display : ' flex' ,
47
+ justifyContent : ' center' ,
48
+ alignItems : ' center' ,
49
49
gap : 40 ,
50
50
padding : 40 ,
51
51
}
52
52
) ;
53
53
54
- const Panel = styled . div < { orientation : " right" | " bottom" } > (
54
+ const Panel = styled . div < { orientation : ' right' | ' bottom' } > (
55
55
( { orientation } ) => ( {
56
- width : orientation === " right" ? 420 : 880 ,
57
- height : orientation === " right" ? 640 : 300 ,
58
- overflow : " auto" ,
56
+ width : orientation === ' right' ? 420 : 880 ,
57
+ height : orientation === ' right' ? 640 : 300 ,
58
+ overflow : ' auto' ,
59
59
} ) ,
60
60
( { theme } ) => ( {
61
- containerType : " size" ,
62
- containerName : " storybookRoot" ,
63
- position : " relative" ,
61
+ containerType : ' size' ,
62
+ containerName : ' storybookRoot' ,
63
+ position : ' relative' ,
64
64
outline : `1px solid ${ theme . appBorderColor } ` ,
65
65
// Add a backdrop to the outline because appBorderColor is semi-transparent
66
66
boxShadow : `0 0 0 1px ${ theme . background . content } ` ,
67
67
background : theme . background . content ,
68
- color : theme . base === " light" ? theme . color . dark : theme . color . mediumlight ,
68
+ color : theme . base === ' light' ? theme . color . dark : theme . color . mediumlight ,
69
69
fontSize : theme . typography . size . s2 ,
70
70
} )
71
71
) ;
@@ -83,17 +83,17 @@ const ThemedSetRoot = () => {
83
83
// Render two panels side-by-side or stacked, depending on selected orientation
84
84
// Note this assumes any play functions are equipped to deal with multiple canvases
85
85
const withTheme = ( StoryFn , { globals, parameters } ) => {
86
- const theme = globals . theme || parameters . theme || " right" ;
87
- return theme === " light" || theme === " dark" ? (
86
+ const theme = globals . theme || parameters . theme || ' right' ;
87
+ return theme === ' light' || theme === ' dark' ? (
88
88
< ThemeProvider theme = { convert ( themes [ theme ] ) } >
89
89
< Global styles = { createReset } />
90
90
< Global
91
91
styles = { {
92
- " #storybook-root" : {
93
- height : " 100vh" ,
92
+ ' #storybook-root' : {
93
+ height : ' 100vh' ,
94
94
padding : 0 ,
95
- containerType : " size" ,
96
- containerName : " storybookRoot" ,
95
+ containerType : ' size' ,
96
+ containerName : ' storybookRoot' ,
97
97
} ,
98
98
} }
99
99
> </ Global >
@@ -125,27 +125,27 @@ const withTheme = (StoryFn, { globals, parameters }) => {
125
125
const withGraphQLClient = storyWrapper ( GraphQLClientProvider ) ;
126
126
127
127
const withTelemetry = storyWrapper ( TelemetryProvider , ( ) => ( {
128
- value : action ( " telemetry" ) ,
128
+ value : fn ( ) . mockName ( ' telemetry' ) ,
129
129
} ) ) ;
130
130
131
131
const withAuth = storyWrapper ( AuthProvider , ( ) => ( {
132
132
value : {
133
- accessToken : " token" ,
133
+ accessToken : ' token' ,
134
134
setAccessToken : fn ( ) ,
135
- subdomain : " www" ,
135
+ subdomain : ' www' ,
136
136
setSubdomain : fn ( ) ,
137
137
} ,
138
138
} ) ) ;
139
139
140
140
const withManagerApi = storyWrapper ( ManagerContext . Provider , ( { argsByTarget } ) => ( {
141
141
value : {
142
- api : { ...argsByTarget [ " manager-api" ] } ,
142
+ api : { ...argsByTarget [ ' manager-api' ] } ,
143
143
state : { } ,
144
144
} ,
145
145
} ) ) ;
146
146
147
147
const withUninstall : Decorator = ( Story ) => {
148
- const [ addonUninstalled , setAddonUninstalled ] = useSessionState ( " addonUninstalled" , false ) ;
148
+ const [ addonUninstalled , setAddonUninstalled ] = useSessionState ( ' addonUninstalled' , false ) ;
149
149
return (
150
150
< UninstallProvider
151
151
addonUninstalled = { addonUninstalled }
@@ -160,9 +160,9 @@ const withRunBuild = storyWrapper(RunBuildProvider, ({ args }) => ({
160
160
watchState : {
161
161
isRunning :
162
162
! ! args . localBuildProgress &&
163
- ! [ " aborted" , " complete" , " error" ] . includes ( args . localBuildProgress . currentStep ) ,
164
- startBuild : action ( " startBuild" ) ,
165
- stopBuild : action ( " stopBuild" ) ,
163
+ ! [ ' aborted' , ' complete' , ' error' ] . includes ( args . localBuildProgress . currentStep ) ,
164
+ startBuild : fn ( ) . mockName ( ' startBuild' ) ,
165
+ stopBuild : fn ( ) . mockName ( ' stopBuild' ) ,
166
166
} ,
167
167
} ) ) ;
168
168
@@ -222,14 +222,15 @@ const preview: Preview = {
222
222
loaders : [ graphQLArgLoader ] ,
223
223
parameters : {
224
224
actions : {
225
- argTypesRegex : " ^on[A-Z].*" ,
225
+ argTypesRegex : ' ^on[A-Z].*' ,
226
226
} ,
227
227
backgrounds : {
228
228
disable : true ,
229
229
} ,
230
230
viewport : {
231
+ disable : true ,
231
232
viewports : {
232
- default : { name : " Default" , styles : { width : " 960px" , height : " 720px" } } ,
233
+ default : { name : ' Default' , styles : { width : ' 960px' , height : ' 720px' } } ,
233
234
} ,
234
235
} ,
235
236
chromatic : {
@@ -241,27 +242,27 @@ const preview: Preview = {
241
242
date : / D a t e $ / ,
242
243
} ,
243
244
} ,
244
- layout : " fullscreen" ,
245
+ layout : ' fullscreen' ,
245
246
} ,
246
247
argTypes : {
247
- $graphql : { target : " graphql" } ,
248
- getChannel : { type : " function" , target : " manager-api" } ,
248
+ $graphql : { target : ' graphql' } ,
249
+ getChannel : { type : ' function' , target : ' manager-api' } ,
249
250
} ,
250
251
args : {
251
- getChannel : ( ) => ( { on : fn ( ) , off : fn ( ) , emit : action ( " channel.emit" ) } ) ,
252
+ getChannel : ( ) => ( { on : fn ( ) , off : fn ( ) , emit : fn ( ) . mockName ( ' channel.emit' ) } ) ,
252
253
} ,
253
254
globalTypes : {
254
255
theme : {
255
- name : " Theme" ,
256
- description : " Panel theme" ,
256
+ name : ' Theme' ,
257
+ description : ' Panel theme' ,
257
258
toolbar : {
258
- icon : " sidebaralt" ,
259
- title : " Theme" ,
259
+ icon : ' sidebaralt' ,
260
+ title : ' Theme' ,
260
261
items : [
261
- { value : " light" , icon : " circlehollow" , title : " Light" } ,
262
- { value : " dark" , icon : " circle" , title : " Dark" } ,
263
- { value : " right" , icon : " sidebaralt" , title : " Right 2-up" } ,
264
- { value : " bottom" , icon : " bottombar" , title : " Bottom 2-up" } ,
262
+ { value : ' light' , icon : ' circlehollow' , title : ' Light' } ,
263
+ { value : ' dark' , icon : ' circle' , title : ' Dark' } ,
264
+ { value : ' right' , icon : ' sidebaralt' , title : ' Right 2-up' } ,
265
+ { value : ' bottom' , icon : ' bottombar' , title : ' Bottom 2-up' } ,
265
266
] ,
266
267
} ,
267
268
} ,
0 commit comments