|
9 | 9 | <script type="module" src="./common.js"></script> |
10 | 10 |
|
11 | 11 | <script type="module"> |
12 | | - import '@vaadin/button'; |
13 | | - import '@vaadin/horizontal-layout'; |
| 12 | + import '@vaadin/checkbox-group'; |
14 | 13 | import '@vaadin/popover'; |
15 | 14 | import '@vaadin/radio-group'; |
16 | | - import '@vaadin/text-field'; |
17 | 15 | </script> |
18 | 16 | </head> |
19 | 17 |
|
20 | 18 | <body> |
21 | 19 | <style> |
22 | 20 | #wrapper { |
23 | 21 | width: 100%; |
| 22 | + min-width: 350px; |
24 | 23 | height: 350px; |
25 | 24 | display: flex; |
26 | 25 | justify-content: center; |
27 | 26 | align-items: center; |
28 | 27 | margin: 1rem; |
29 | | - } |
30 | | - |
31 | | - #target { |
32 | | - width: 150px; |
33 | | - height: 150px; |
34 | | - display: flex; |
35 | | - justify-content: center; |
36 | | - align-items: center; |
37 | | - border: solid 1px #e2e2e2; |
| 28 | + gap: 1rem; |
38 | 29 | } |
39 | 30 | </style> |
40 | 31 |
|
|
53 | 44 | <vaadin-radio-button value="end-bottom" label="End Bottom"></vaadin-radio-button> |
54 | 45 | </vaadin-radio-group> |
55 | 46 |
|
| 47 | + <vaadin-checkbox-group id="triggerGroup" label="Trigger" theme="horizontal"> |
| 48 | + <vaadin-checkbox value="click" label="Click"></vaadin-checkbox> |
| 49 | + <vaadin-checkbox value="focus" label="Focus"></vaadin-checkbox> |
| 50 | + <vaadin-checkbox value="hover" label="Hover"></vaadin-checkbox> |
| 51 | + </vaadin-checkbox-group> |
| 52 | + |
56 | 53 | <div id="wrapper"> |
57 | | - <div id="target">Save</div> |
58 | | - <vaadin-popover for="target" theme="arrow"></vaadin-popover> |
| 54 | + <input placeholder="Before" /> |
| 55 | + |
| 56 | + <input id="target" placeholder="Target" /> |
| 57 | + <vaadin-popover for="target" theme="arrow" id="popover"></vaadin-popover> |
| 58 | + |
| 59 | + <input placeholder="After" /> |
59 | 60 | </div> |
60 | 61 |
|
61 | 62 | <script type="module"> |
|
66 | 67 | popover.position = e.target.value; |
67 | 68 | }); |
68 | 69 |
|
| 70 | + const checkboxGroup = document.querySelector('#triggerGroup'); |
| 71 | + checkboxGroup.value = ['click']; |
| 72 | + |
| 73 | + checkboxGroup.addEventListener('change', (e) => { |
| 74 | + popover.trigger = checkboxGroup.value; |
| 75 | + }); |
| 76 | + |
69 | 77 | popover.renderer = (root) => { |
70 | 78 | if (root.firstChild) { |
71 | 79 | return; |
72 | 80 | } |
73 | 81 |
|
74 | | - const layout = document.createElement('vaadin-horizontal-layout'); |
75 | | - layout.setAttribute('theme', 'spacing'); |
76 | | - layout.style.alignItems = 'end'; |
77 | | - |
78 | | - const field = document.createElement('vaadin-text-field'); |
79 | | - field.label = 'Discount code'; |
| 82 | + const input = document.createElement('input'); |
80 | 83 |
|
81 | | - const button = document.createElement('vaadin-button'); |
82 | | - button.textContent = 'Apply'; |
| 84 | + const nested = document.createElement('vaadin-popover'); |
| 85 | + nested.setAttribute('theme', 'arrow'); |
| 86 | + nested.trigger = ['click']; |
| 87 | + nested.target = input; |
83 | 88 |
|
84 | | - layout.append(field, button); |
| 89 | + nested.renderer = (root2) => { |
| 90 | + root2.innerHTML = '<input placeholder="Popover 2" />'; |
| 91 | + }; |
85 | 92 |
|
86 | | - root.append(layout); |
| 93 | + root.append(input, nested); |
87 | 94 | }; |
88 | 95 | </script> |
89 | 96 | </body> |
|
0 commit comments