1
1
import { isFunction , isNumber , SupportedLanguage } from '@showroomjs/core' ;
2
- import { css , styled , tw , useConstant , useQueryParams } from '@showroomjs/ui' ;
3
- import { Enable as ResizeEnable , Resizable } from 're-resizable' ;
2
+ import { tw , useConstant , useQueryParams } from '@showroomjs/ui' ;
3
+ import { Resizable , Enable as ResizeEnable } from 're-resizable' ;
4
4
import * as React from 'react' ;
5
5
import { useCodeFrameContext } from '../lib/code-frame-context' ;
6
6
import { safeCompress , safeDecompress } from '../lib/compress' ;
@@ -166,18 +166,25 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
166
166
onResultChange = { ( result ) => setResult ( dimension . name , result ) }
167
167
key = { dimension . name }
168
168
>
169
- < ScreenWrapper isCommenting = { props . isCommenting } >
169
+ < div
170
+ className = { tw ( [
171
+ 'group/wrapper mb-6' ,
172
+ props . isCommenting && 'pointer-events-none' ,
173
+ ] ) }
174
+ >
170
175
< DeviceFrame dimension = { dimension } showFrame = { props . showFrame } >
171
- < Screen
172
- css = {
176
+ < div
177
+ className = { tw ( [
178
+ 'h-full overflow-hidden transition-shadow bg-white shadow-sm' ,
179
+ 'group-hover/wrapper:shadow-lg' ,
180
+ ] ) }
181
+ style = {
173
182
props . showFrame
174
183
? {
175
184
width : '100%' ,
176
- height : '100%' ,
177
185
}
178
186
: {
179
187
width : `${ dimension . width } px` ,
180
- height : '100%' ,
181
188
}
182
189
}
183
190
>
@@ -259,11 +266,15 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
259
266
} }
260
267
data-frame-id = { getFrameId ( dimension ) }
261
268
/>
262
- </ Screen >
269
+ </ div >
263
270
</ DeviceFrame >
264
- < ScreenSize >
265
- < ScreenSizeText
266
- css = {
271
+ < div className = { tw ( [ 'px-2 py-1' ] ) } >
272
+ < span
273
+ className = { tw ( [
274
+ 'inline-flex flex-col items-start text-sm' ,
275
+ 'text-zinc-500 group-hover/wrapper:text-black' ,
276
+ ] ) }
277
+ style = {
267
278
shouldAdjustZoom
268
279
? {
269
280
transform : `scale(${ 100 / zoomValue } )` ,
@@ -276,17 +287,31 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
276
287
< A11ySummary
277
288
onClick = { ( ) => props . onA11ySummaryClick ( dimension . name ) }
278
289
/>
279
- </ ScreenSizeText >
280
- </ ScreenSize >
281
- </ ScreenWrapper >
290
+ </ span >
291
+ </ div >
292
+ </ div >
282
293
</ A11yResultContextProvider >
283
294
) ;
284
295
} ) ;
285
296
286
297
const rootProps = {
287
- className : resizeStyle ( {
288
- isCommenting : props . isCommenting ,
289
- } ) ,
298
+ className : tw ( [
299
+ 'relative pt-3 pb-6 px-3 bg-zinc-200 overflow-x-auto overflow-y-hidden' ,
300
+ props . isCommenting && 'text-zinc-300' ,
301
+ screenListSize ? 'flex-none' : 'flex-1' ,
302
+ ] ) ,
303
+ style : {
304
+ ...( props . isCommenting
305
+ ? {
306
+ cursor : `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z' /%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 11a3 3 0 11-6 0 3 3 0 016 0z' /%3E%3C/svg%3E"), auto` ,
307
+ }
308
+ : { } ) ,
309
+ ...( screenListSize
310
+ ? {
311
+ height : screenListSize . height + 36 ,
312
+ }
313
+ : { } ) ,
314
+ } ,
290
315
onClick : props . isCommenting
291
316
? ( ev : React . MouseEvent < HTMLElement , MouseEvent > ) => {
292
317
props . onClickCommentPoint ( {
@@ -298,20 +323,9 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
298
323
} ;
299
324
300
325
return props . fitHeight ? (
301
- < Root
302
- { ...rootProps }
303
- css = {
304
- screenListSize
305
- ? {
306
- height : screenListSize . height + 36 ,
307
- flex : 'none' ,
308
- }
309
- : { }
310
- }
311
- ref = { forwardedRef }
312
- >
326
+ < div { ...rootProps } ref = { forwardedRef } >
313
327
< ScreenList
314
- css = {
328
+ style = {
315
329
shouldAdjustZoom
316
330
? {
317
331
transform : `scale(${ zoomValue / 100 } )` ,
@@ -330,7 +344,7 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
330
344
{ content }
331
345
</ ScreenList >
332
346
{ props . children }
333
- </ Root >
347
+ </ div >
334
348
) : (
335
349
< Resizable
336
350
enable = { resizeEnable }
@@ -353,7 +367,7 @@ export const StandaloneCodeLiveEditorPreviewList = React.forwardRef<
353
367
{ ...rootProps }
354
368
>
355
369
< ScreenList
356
- css = {
370
+ style = {
357
371
shouldAdjustZoom
358
372
? {
359
373
transform : `scale(${ zoomValue / 100 } )` ,
@@ -387,79 +401,17 @@ const resizeEnable: ResizeEnable = {
387
401
topLeft : false ,
388
402
} ;
389
403
390
- const Root = styled ( 'div' , {
391
- flex : 1 ,
392
- } ) ;
393
-
394
- const ScreenList = styled ( 'div' , {
395
- display : 'flex' ,
396
- gap : '$6' ,
397
- variants : {
398
- wrap : {
399
- true : {
400
- flexWrap : 'wrap' ,
401
- } ,
402
- } ,
403
- } ,
404
- } ) ;
405
-
406
- const resizeStyle = css ( {
407
- overflowX : 'auto' ,
408
- overflowY : 'hidden' ,
409
- paddingTop : '$3' ,
410
- paddingBottom : '$6' ,
411
- px : '$3' ,
412
- backgroundColor : '$gray-200' ,
413
- position : 'relative' ,
414
- variants : {
415
- isCommenting : {
416
- true : {
417
- color : '$gray-300' ,
418
- cursor : `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z' /%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 11a3 3 0 11-6 0 3 3 0 016 0z' /%3E%3C/svg%3E"), auto` ,
419
- } ,
420
- } ,
421
- } ,
422
- } ) ;
423
-
424
- const ScreenSize = styled ( 'div' , {
425
- gap : '$1' ,
426
- px : '$2' ,
427
- py : '$1' ,
428
- } ) ;
429
-
430
- const ScreenSizeText = styled ( 'span' , {
431
- display : 'inline-flex' ,
432
- flexDirection : 'column' ,
433
- alignItems : 'flex-start' ,
434
- fontSize : '$sm' ,
435
- lineHeight : '$sm' ,
436
- color : '$gray-500' ,
437
- } ) ;
438
-
439
- const Screen = styled ( 'div' , {
440
- shadow : 'sm' ,
441
- backgroundColor : 'White' ,
442
- transition : 'box-shadow 100ms ease-in-out' ,
443
- height : '100%' ,
444
- overflow : 'hidden' ,
445
- } ) ;
446
-
447
- const ScreenWrapper = styled ( 'div' , {
448
- [ `&:hover ${ ScreenSize } ` ] : {
449
- color : 'Black' ,
450
- fontWeight : '500' ,
451
- } ,
452
- [ `&:hover ${ Screen } ` ] : {
453
- shadow : 'lg' ,
454
- } ,
455
- marginBottom : '$6' ,
456
- variants : {
457
- isCommenting : {
458
- true : {
459
- pointerEvents : 'none' ,
460
- } ,
461
- } ,
462
- } ,
404
+ const ScreenList = React . forwardRef <
405
+ HTMLDivElement ,
406
+ React . ComponentPropsWithoutRef < 'div' > & { wrap ?: boolean }
407
+ > ( function ScreenList ( { wrap, className, ...props } , forwardedRef ) {
408
+ return (
409
+ < div
410
+ { ...props }
411
+ ref = { forwardedRef }
412
+ className = { tw ( [ 'flex gap-6' , wrap && 'flex-wrap' ] , [ className ] ) }
413
+ />
414
+ ) ;
463
415
} ) ;
464
416
465
417
const serializeStateMaps = ( stateMaps : StateMaps ) : string => {
0 commit comments