11import { useEffect as useReactEffect } from 'react' ;
22import { configureActions } from '@storybook/addon-actions' ;
33import { css } from '@storybook/theming' ;
4- import {
5- useEffect as useStorybookEffect ,
6- useMemo as useStorybookMemo
7- } from '@storybook/preview-api' ;
4+ import { useEffect as useStorybookEffect , useMemo as useStorybookMemo } from '@storybook/preview-api' ;
85import type { Preview } from '@storybook/react' ;
96import {
107 Configuration ,
@@ -14,7 +11,7 @@ import {
1411 Aries2023Theme ,
1512 Aries2023DarkTheme ,
1613 ThemeMachine ,
17- BaseThemeMachine
14+ BaseThemeMachine ,
1815} from '@pega/cosmos-react-core' ;
1916import type { DefaultSettableTheme , DefaultThemeDefinition } from '@pega/cosmos-react-core' ;
2017import * as MantisTheme from './MantisTheme.json' ;
@@ -23,22 +20,22 @@ import * as HoneyFlowerTheme from './HoneyFlowerTheme.json';
2320
2421configureActions ( {
2522 depth : 5 ,
26- limit : 20
23+ limit : 20 ,
2724} ) ;
2825
2926const themes : Record < string , DefaultSettableTheme | undefined > = {
3027 Default : Aries2023Theme ,
3128 Dark : Aries2023DarkTheme ,
3229 Mantis : MantisTheme ,
3330 Flame : FlameTheme ,
34- HoneyFlower : HoneyFlowerTheme
31+ HoneyFlower : HoneyFlowerTheme ,
3532} ;
3633
3734const themeMachines = Object . fromEntries (
3835 Object . entries ( themes ) . map ( ( [ name , theme ] ) => [
3936 name ,
40- new ThemeMachine < DefaultThemeDefinition > ( { theme, parent : BaseThemeMachine } )
41- ] )
37+ new ThemeMachine < DefaultThemeDefinition > ( { theme, parent : BaseThemeMachine } ) ,
38+ ] ) ,
4239) ;
4340
4441window . addEventListener ( 'error' , console . error ) ;
@@ -48,13 +45,13 @@ const preview: Preview = {
4845 backgrounds : {
4946 disable : true ,
5047 grid : {
51- disable : true
52- }
48+ disable : true ,
49+ } ,
5350 } ,
5451 outline : {
55- disable : true
52+ disable : true ,
5653 } ,
57- controls : { hideNoControlsWarning : true }
54+ controls : { hideNoControlsWarning : true } ,
5855 } ,
5956
6057 decorators : [
@@ -87,8 +84,7 @@ const preview: Preview = {
8784 // Sets up shadow DOM rendering
8885 ( Story , context ) => {
8986 const backgroundStyles = useStorybookMemo ( ( ) => {
90- const selector =
91- context . viewMode === 'docs' ? `#anchor--${ context . id } .docs-story` : '.sb-show-main' ;
87+ const selector = context . viewMode === 'docs' ? `#anchor--${ context . id } .docs-story` : '.sb-show-main' ;
9288
9389 const maxWidth = context . globals [ 'fullscreen' ] !== 'On' ? '1000px' : 'none' ;
9490
@@ -126,12 +122,8 @@ const preview: Preview = {
126122 }
127123
128124 : root {
129- --addon-backgrounds-gradient-primary : ${ themeMachine . theme . base . palette [
130- 'app-background'
131- ] } ;
132- --addon-backgrounds-gradient-secondary : ${ themeMachine . theme . base . palette [
133- 'primary-background'
134- ] } ;
125+ --addon-backgrounds-gradient-primary : ${ themeMachine . theme . base . palette [ 'app-background' ] } ;
126+ --addon-backgrounds-gradient-secondary : ${ themeMachine . theme . base . palette [ 'primary-background' ] } ;
135127 background : repeating-conic-gradient (
136128 var (--addon-backgrounds-gradient-primary ) 0% 25% ,
137129 var (--addon-backgrounds-gradient-secondary ) 0% 50%
@@ -152,18 +144,10 @@ const preview: Preview = {
152144 max-width : ${ maxWidth } !important ;
153145 }
154146 ` . styles ;
155- } , [
156- context . viewMode ,
157- context . globals [ 'theme' ] ,
158- context . globals [ 'backgrounds' ] ,
159- context . globals [ 'fullscreen' ]
160- ] ) ;
147+ } , [ context . viewMode , context . globals [ 'theme' ] , context . globals [ 'backgrounds' ] , context . globals [ 'fullscreen' ] ] ) ;
161148
162149 useStorybookEffect ( ( ) => {
163- const id =
164- context . viewMode === 'docs'
165- ? `addon-backgrounds-docs-${ context . id } `
166- : 'addon-backgrounds-color' ;
150+ const id = context . viewMode === 'docs' ? `addon-backgrounds-docs-${ context . id } ` : 'addon-backgrounds-color' ;
167151
168152 const existingStyleEl = document . getElementById ( id ) ;
169153 if ( existingStyleEl ) {
@@ -181,7 +165,7 @@ const preview: Preview = {
181165 } , [ backgroundStyles , context . viewMode , context . id ] ) ;
182166
183167 return < Story { ...context } /> ;
184- }
168+ } ,
185169 ] ,
186170
187171 globalTypes : {
@@ -191,26 +175,26 @@ const preview: Preview = {
191175 defaultValue : 'Default' ,
192176 toolbar : {
193177 icon : 'paintbrush' ,
194- items : Object . keys ( themes )
195- }
178+ items : Object . keys ( themes ) ,
179+ } ,
196180 } ,
197181 backgrounds : {
198182 name : 'Backgrounds' ,
199183 description : 'Change the background of the preview' ,
200184 defaultValue : 'Clear' ,
201185 toolbar : {
202186 icon : 'photo' ,
203- items : [ 'Clear' , 'App Background' , 'Primary Background' , 'Secondary Background' ]
204- }
187+ items : [ 'Clear' , 'App Background' , 'Primary Background' , 'Secondary Background' ] ,
188+ } ,
205189 } ,
206190 fullscreen : {
207191 name : 'Fullscreen' ,
208192 description : 'Use all space' ,
209193 defaultValue : 'Off' ,
210194 toolbar : {
211195 icon : 'grow' ,
212- items : [ 'Off' , 'On' ]
213- }
196+ items : [ 'Off' , 'On' ] ,
197+ } ,
214198 } ,
215199 locale : {
216200 name : 'Locale' ,
@@ -222,9 +206,9 @@ const preview: Preview = {
222206 { value : 'en-US' , right : '🇺🇸' , title : 'English (US)' } ,
223207 { value : 'pl' , right : '🇵🇱' , title : 'Polish' } ,
224208 { value : 'fr' , right : '🇫🇷' , title : 'Français' } ,
225- { value : 'ar' , right : '🇦🇪' , title : 'عربي' }
226- ]
227- }
209+ { value : 'ar' , right : '🇦🇪' , title : 'عربي' } ,
210+ ] ,
211+ } ,
228212 } ,
229213 direction : {
230214 name : 'Directionality' ,
@@ -233,11 +217,11 @@ const preview: Preview = {
233217 toolbar : {
234218 items : [
235219 { value : 'ltr' , icon : 'arrowrightalt' , title : 'Left to Right' } ,
236- { value : 'rtl' , icon : 'arrowleftalt' , title : 'Right to Left' }
237- ]
238- }
239- }
240- }
220+ { value : 'rtl' , icon : 'arrowleftalt' , title : 'Right to Left' } ,
221+ ] ,
222+ } ,
223+ } ,
224+ } ,
241225} ;
242226
243227export default preview ;
0 commit comments