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,41 +20,41 @@ 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
4441const preview : Preview = {
4542 parameters : {
4643 options : {
4744 storySort : {
48- order : [ 'Getting Started' , 'Libraries' , 'Support and Contributing' ]
49- }
45+ order : [ 'Getting Started' , 'Libraries' , 'Support and Contributing' ] ,
46+ } ,
5047 } ,
5148 backgrounds : {
5249 disable : true ,
5350 grid : {
54- disable : true
55- }
51+ disable : true ,
52+ } ,
5653 } ,
5754 outline : {
58- disable : true
55+ disable : true ,
5956 } ,
60- controls : { hideNoControlsWarning : true }
57+ controls : { hideNoControlsWarning : true } ,
6158 } ,
6259
6360 decorators : [
@@ -90,8 +87,7 @@ const preview: Preview = {
9087 // Sets up shadow DOM rendering
9188 ( Story , context ) => {
9289 const backgroundStyles = useStorybookMemo ( ( ) => {
93- const selector =
94- context . viewMode === 'docs' ? `#anchor--${ context . id } .docs-story` : '.sb-show-main' ;
90+ const selector = context . viewMode === 'docs' ? `#anchor--${ context . id } .docs-story` : '.sb-show-main' ;
9591
9692 const maxWidth = context . globals . fullscreen !== 'On' ? '1000px' : 'none' ;
9793
@@ -129,12 +125,8 @@ const preview: Preview = {
129125 }
130126
131127 : root {
132- --addon-backgrounds-gradient-primary : ${ themeMachine . theme . base . palette [
133- 'app-background'
134- ] } ;
135- --addon-backgrounds-gradient-secondary : ${ themeMachine . theme . base . palette [
136- 'primary-background'
137- ] } ;
128+ --addon-backgrounds-gradient-primary : ${ themeMachine . theme . base . palette [ 'app-background' ] } ;
129+ --addon-backgrounds-gradient-secondary : ${ themeMachine . theme . base . palette [ 'primary-background' ] } ;
138130 background : repeating-conic-gradient (
139131 var (--addon-backgrounds-gradient-primary ) 0% 25% ,
140132 var (--addon-backgrounds-gradient-secondary ) 0% 50%
@@ -155,18 +147,10 @@ const preview: Preview = {
155147 max-width : ${ maxWidth } !important ;
156148 }
157149 ` . styles ;
158- } , [
159- context . viewMode ,
160- context . globals . theme ,
161- context . globals . backgrounds ,
162- context . globals . fullscreen
163- ] ) ;
150+ } , [ context . viewMode , context . globals . theme , context . globals . backgrounds , context . globals . fullscreen ] ) ;
164151
165152 useStorybookEffect ( ( ) => {
166- const id =
167- context . viewMode === 'docs'
168- ? `addon-backgrounds-docs-${ context . id } `
169- : 'addon-backgrounds-color' ;
153+ const id = context . viewMode === 'docs' ? `addon-backgrounds-docs-${ context . id } ` : 'addon-backgrounds-color' ;
170154
171155 const existingStyleEl = document . getElementById ( id ) ;
172156 if ( existingStyleEl ) {
@@ -184,7 +168,7 @@ const preview: Preview = {
184168 } , [ backgroundStyles , context . viewMode , context . id ] ) ;
185169
186170 return < Story { ...context } /> ;
187- }
171+ } ,
188172 ] ,
189173
190174 globalTypes : {
@@ -194,26 +178,26 @@ const preview: Preview = {
194178 defaultValue : 'Default' ,
195179 toolbar : {
196180 icon : 'paintbrush' ,
197- items : Object . keys ( themes )
198- }
181+ items : Object . keys ( themes ) ,
182+ } ,
199183 } ,
200184 backgrounds : {
201185 name : 'Backgrounds' ,
202186 description : 'Change the background of the preview' ,
203187 defaultValue : 'Clear' ,
204188 toolbar : {
205189 icon : 'photo' ,
206- items : [ 'Clear' , 'App Background' , 'Primary Background' , 'Secondary Background' ]
207- }
190+ items : [ 'Clear' , 'App Background' , 'Primary Background' , 'Secondary Background' ] ,
191+ } ,
208192 } ,
209193 fullscreen : {
210194 name : 'Fullscreen' ,
211195 description : 'Use all space' ,
212196 defaultValue : 'Off' ,
213197 toolbar : {
214198 icon : 'grow' ,
215- items : [ 'Off' , 'On' ]
216- }
199+ items : [ 'Off' , 'On' ] ,
200+ } ,
217201 } ,
218202 locale : {
219203 name : 'Locale' ,
@@ -225,9 +209,9 @@ const preview: Preview = {
225209 { value : 'en-US' , right : '🇺🇸' , title : 'English (US)' } ,
226210 { value : 'pl' , right : '🇵🇱' , title : 'Polish' } ,
227211 { value : 'fr' , right : '🇫🇷' , title : 'Français' } ,
228- { value : 'ar' , right : '🇦🇪' , title : 'عربي' }
229- ]
230- }
212+ { value : 'ar' , right : '🇦🇪' , title : 'عربي' } ,
213+ ] ,
214+ } ,
231215 } ,
232216 direction : {
233217 name : 'Directionality' ,
@@ -236,11 +220,11 @@ const preview: Preview = {
236220 toolbar : {
237221 items : [
238222 { value : 'ltr' , icon : 'arrowrightalt' , title : 'Left to Right' } ,
239- { value : 'rtl' , icon : 'arrowleftalt' , title : 'Right to Left' }
240- ]
241- }
242- }
243- }
223+ { value : 'rtl' , icon : 'arrowleftalt' , title : 'Right to Left' } ,
224+ ] ,
225+ } ,
226+ } ,
227+ } ,
244228} ;
245229
246230export default preview ;
0 commit comments