1- import { storiesOf , html } from '@open-wc/demoing-storybook' ;
1+ import { storiesOf , html , withKnobs , object , text } from '@open-wc/demoing-storybook' ;
22import { css } from '@lion/core' ;
33
44import '@lion/icon/lion-icon.js' ;
@@ -11,11 +11,11 @@ const popupDemoStyle = css`
1111 background-color: white;
1212 border-radius: 2px;
1313 border: 1px solid grey;
14- margin: 250px;
14+ margin: 250px 0 0 250px ;
1515 padding: 8px;
1616 }
1717
18- .demo-box_positions {
18+ .demo-box_placements {
1919 display: flex;
2020 flex-direction: column;
2121 width: 173px;
@@ -40,6 +40,8 @@ const popupDemoStyle = css`
4040 background-color: black;
4141 border-radius: 4px;
4242 padding: 8px;
43+ /* To display on top of elements with no z-index that are appear later in the DOM */
44+ z-index: 1;
4345 }
4446
4547 @media (max-width: 480px) {
@@ -50,43 +52,81 @@ const popupDemoStyle = css`
5052` ;
5153
5254storiesOf ( 'Local Overlay System|Popup' , module )
55+ . addDecorator ( withKnobs )
5356 . add (
5457 'Button popup' ,
5558 ( ) => html `
5659 < style >
5760 ${ popupDemoStyle }
5861 </ style >
5962 < div class ="demo-box ">
60- < lion-popup position =" right ">
61- < div slot ="content " class ="popup "> hey there</ div >
63+ < lion-popup .placementConfig =" ${ { placement : 'top' } } ">
64+ < div slot ="content " class ="popup "> Hello there! </ div >
6265 < lion-button slot ="invoker "> Popup</ lion-button >
6366 </ lion-popup >
6467 </ div >
6568 ` ,
6669 )
6770 . add (
68- 'positions ' ,
71+ 'placements ' ,
6972 ( ) => html `
7073 < style >
7174 ${ popupDemoStyle }
7275 </ style >
73- < div class ="demo-box_positions ">
74- < lion-popup position =" top ">
75- < div slot ="content " class ="popup "> Its top position </ div >
76+ < div class ="demo-box_placements ">
77+ < lion-popup .placementConfig =" ${ { placement : ' top' } } ">
78+ < div slot ="content " class ="popup "> Its top placement </ div >
7679 < lion-button slot ="invoker "> Top</ lion-button >
7780 </ lion-popup >
78- < lion-popup position =" right ">
79- < div slot ="content " class ="popup "> Its right position </ div >
81+ < lion-popup .placementConfig =" ${ { placement : ' right' } } ">
82+ < div slot ="content " class ="popup "> Its right placement </ div >
8083 < lion-button slot ="invoker "> Right</ lion-button >
8184 </ lion-popup >
82- < lion-popup position =" bottom ">
83- < div slot ="content " class ="popup "> Its bottom position </ div >
85+ < lion-popup .placementConfig =" ${ { placement : ' bottom' } } ">
86+ < div slot ="content " class ="popup "> Its bottom placement </ div >
8487 < lion-button slot ="invoker "> Bottom</ lion-button >
8588 </ lion-popup >
86- < lion-popup position =" left ">
87- < div slot ="content " class ="popup "> Its left position </ div >
89+ < lion-popup .placementConfig =" ${ { placement : ' left' } } ">
90+ < div slot ="content " class ="popup "> Its left placement </ div >
8891 < lion-button slot ="invoker "> Left</ lion-button >
8992 </ lion-popup >
9093 </ div >
9194 ` ,
95+ )
96+ . add (
97+ 'Override placement configuration' ,
98+ ( ) => html `
99+ < style >
100+ ${ popupDemoStyle }
101+ </ style >
102+ < p > Use the Storybook Knobs to dynamically change the placement configuration!</ p >
103+ < div class ="demo-box ">
104+ < lion-popup
105+ .placementConfig ="${ object ( 'Placement Configuration' , {
106+ placement : 'bottom-start' ,
107+ positionFixed : true ,
108+ modifiers : {
109+ keepTogether : {
110+ enabled : true /* Prevents detachment of content element from reference element */ ,
111+ } ,
112+ preventOverflow : {
113+ enabled : true /* disables shifting/sliding behavior on secondary axis */ ,
114+ padding : 16 /* when enabled, this is the viewport-margin for shifting/sliding */ ,
115+ } ,
116+ flip : {
117+ boundariesElement : 'viewport' ,
118+ padding : 4 /* viewport-margin for flipping on primary axis */ ,
119+ } ,
120+ offset : {
121+ enabled : true ,
122+ offset : `0, 4px` /* horizontal and vertical margin (distance between popper and referenceElement) */ ,
123+ } ,
124+ } ,
125+ } ) } "
126+ >
127+ < div slot ="content " class ="popup "> ${ text ( 'Content text' , 'Hello, World!' ) } </ div >
128+ < lion-button slot ="invoker "> ${ text ( 'Invoker text' , 'Click me!' ) } </ lion-button >
129+ </ lion-popup >
130+ </ div >
131+ ` ,
92132 ) ;
0 commit comments