File tree Expand file tree Collapse file tree 3 files changed +73
-2
lines changed
Expand file tree Collapse file tree 3 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 1818 box-shadow : 0 0 20px 0 rgba (0 , 0 , 0 , 0.6 );
1919
2020 & --large {
21+ width : 480px ;
2122 }
2223
2324 & -small {
25+ width : 320px ;
26+ }
27+
28+ & --hidden {
29+ visibility : none ;
2430 }
2531}
2632
2733.preview-popUp__preview {
34+ grid-area : ' preview' ;
2835}
2936
3037.preview-popUp__controls {
38+ grid-area : ' controls' ;
3139}
3240
3341.preview-popUp__content-info {
42+ grid-area : ' content-info' ;
3443}
3544
3645.preview-popUp__warnings {
46+ grid-area : ' warnings' ;
47+ display : grid ;
48+ grid-template-columns : 1fr ;
49+ grid-auto-rows : auto ;
3750}
3851
3952.preview-popUp__warning-row {
4053 display : grid ;
41- grid-template-columns : 1 fr ;
54+ grid-template-columns : 2 em auto ;
4255 grid-auto-rows : auto ;
4356}
Original file line number Diff line number Diff line change @@ -7,16 +7,18 @@ export function PreviewPopUp({
77 anchor,
88 padding,
99 placement,
10+ hidden,
1011 size,
1112 preview,
1213 controls,
1314 contentInfo,
1415 warnings,
1516} : {
16- anchor : HTMLElement | VirtualElement
17+ anchor : HTMLElement | VirtualElement | null
1718 padding : Padding
1819 placement : Placement
1920 size : 'small' | 'large'
21+ hidden ?: boolean
2022 preview ?: React . ReactNode
2123 controls ?: React . ReactNode
2224 contentInfo ?: React . ReactNode
@@ -68,6 +70,7 @@ export function PreviewPopUp({
6870 className = { classNames ( 'preview-popUp' , {
6971 'preview-popUp--large' : size === 'large' ,
7072 'preview-popUp--small' : size === 'small' ,
73+ 'preview-popUp--hidden' : hidden ,
7174 } ) }
7275 style = { styles . popper }
7376 { ...attributes . popper }
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+
3+ type VirtualElement = {
4+ getBoundingClientRect : ( ) => DOMRect
5+ contextElement ?: Element
6+ }
7+
8+ export type PreviewContent =
9+ | {
10+ type : 'iframe'
11+ href : string
12+ awaitMessage ?: any
13+ postMessage ?: any
14+ }
15+ | {
16+ type : 'image'
17+ src : string
18+ }
19+ | {
20+ type : 'video'
21+ src : string
22+ currentTime : number
23+ }
24+ | {
25+ type : 'text'
26+ content : string
27+ }
28+
29+ interface IPreviewPopUpContext {
30+ display : (
31+ anchor : HTMLElement | VirtualElement ,
32+ content : PreviewContent ,
33+ opts ?: {
34+ size ?: 'small' | 'large'
35+ controls ?: React . ReactNode
36+ contentInfo ?: React . ReactNode
37+ warnings ?: React . ReactNode
38+ }
39+ ) => void
40+ hide : ( ) => void
41+ }
42+
43+ const PreviewPopUpContext = React . createContext < IPreviewPopUpContext > ( {
44+ display : ( ) => void { } ,
45+ hide : ( ) => void { } ,
46+ } )
47+
48+ export function PreviewPopUpContextProvider ( { children } : React . PropsWithChildren < { } > ) : React . ReactNode {
49+ const context : IPreviewPopUpContext = {
50+ display : ( ) => void { } ,
51+ hide : ( ) => void { } ,
52+ }
53+
54+ return < PreviewPopUpContext . Provider value = { context } > { children } </ PreviewPopUpContext . Provider >
55+ }
You can’t perform that action at this time.
0 commit comments