File tree 2 files changed +57
-0
lines changed
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,35 @@ storiesOf('Portals', module)
260
260
261
261
return < ChangeLayoutWithoutUnmounting /> ;
262
262
} )
263
+ . add ( 'can pass attributes option to createHtmlPortalNode' , ( ) => {
264
+ return React . createElement ( ( ) => {
265
+ const [ hasAttrOption , setHasAttrOption ] = React . useState ( false ) ;
266
+
267
+ const portalNode = createHtmlPortalNode ( hasAttrOption ? {
268
+ attributes : { id : "div-id-1" , style : "background-color: #aaf; width: 204px;" }
269
+ } : null ) ;
270
+
271
+ return < div >
272
+ < button onClick = { ( ) => setHasAttrOption ( ! hasAttrOption ) } >
273
+ Click to pass attributes option to the intermediary div
274
+ </ button >
275
+
276
+ < hr />
277
+
278
+ < InPortal node = { portalNode } >
279
+ < div style = { { width : '200px' , height : '50px' , border : '2px solid purple' } } />
280
+ </ InPortal >
281
+
282
+ < OutPortal node = { portalNode } />
283
+
284
+ < br />
285
+ < br />
286
+ < br />
287
+
288
+ < text > { ! hasAttrOption ? `const portalNode = createHtmlPortalNode();` : `const portalNode = createHtmlPortalNode({ attributes: { id: "div-id-1", style: "background-color: #aaf; width: 204px;" } });` } </ text >
289
+ </ div >
290
+ } ) ;
291
+ } )
263
292
. add ( 'Example from README' , ( ) => {
264
293
const MyExpensiveComponent = ( ) => 'expensive!' ;
265
294
Original file line number Diff line number Diff line change @@ -92,4 +92,32 @@ storiesOf('SVG Portals', module)
92
92
</ svg >
93
93
</ div >
94
94
} )
95
+ } )
96
+ . add ( 'can pass attributes option to createSvgPortalNode' , ( ) => {
97
+ return React . createElement ( ( ) => {
98
+ const [ hasAttrOption , setHasAttrOption ] = React . useState ( false ) ;
99
+
100
+ const portalNode = createSvgPortalNode ( hasAttrOption ? { attributes : { stroke : 'blue' } } : null ) ;
101
+ return < div >
102
+ < button onClick = { ( ) => setHasAttrOption ( ! hasAttrOption ) } >
103
+ Click to pass attributes option to the intermediary svg
104
+ </ button >
105
+
106
+ < hr />
107
+
108
+ < svg >
109
+ < InPortal node = { portalNode } >
110
+ < circle cx = "50" cy = "50" r = "40" fill = "lightblue" />
111
+ </ InPortal >
112
+
113
+ < svg x = { 30 } y = { 10 } >
114
+ < OutPortal node = { portalNode } />
115
+ </ svg >
116
+ </ svg >
117
+
118
+ < br />
119
+
120
+ < text > { ! hasAttrOption ? `const portalNode = createSvgPortalNode();` : `const portalNode = createSvgPortalNode({ attributes: { stroke: "blue" } });` } </ text >
121
+ </ div >
122
+ } ) ;
95
123
} ) ;
You can’t perform that action at this time.
0 commit comments