|
1 | | -// 1. Reset positioning for controlled variant. |
2 | | -// 2. Shift Popover so there is space for the arrow between Popover and reference element. |
3 | | -// 3. Add top offset in case it's not defined by external library. |
| 1 | +// 1. Hide the popover by default. This is needed because the popover is |
| 2 | +// controlled via CSS with the help of the helper popover. The popover can't |
| 3 | +// be displayed directly, because relative positioning doesn't work with |
| 4 | +// elements on the top-layer, so this CSS hack is needed. |
| 5 | +// 2. Hide the popover helper element. |
| 6 | +// 3. If the popover helper is open, show the actual popover. |
| 7 | +// 4. Reset positioning for controlled variant. |
| 8 | +// 5. Shift Popover so there is space for the arrow between Popover and reference element. |
| 9 | +// 6. Add top offset in case it's not defined by external library. |
4 | 10 |
|
5 | 11 | @use "theme"; |
6 | 12 |
|
|
49 | 55 | } |
50 | 56 | } |
51 | 57 |
|
52 | | - /** |
53 | | - * Controlled popover |
54 | | - * Hide the popover by default. This is needed because the popover is |
55 | | - * controlled via CSS with the help of the helper popover. The popover can't |
56 | | - * be displayed directly, because relative positioning doesn't work with |
57 | | - * elements on the top-layer, so this CSS hack is needed. |
58 | | - */ |
| 58 | + // Controlled popover |
59 | 59 | .controlledPopover { |
60 | | - display: none; |
| 60 | + display: none; // 1. |
61 | 61 | } |
62 | 62 |
|
63 | | - // Hide the popover helper element |
64 | 63 | .helper { |
65 | | - position: fixed; |
| 64 | + position: fixed; // 2. |
66 | 65 | inset: unset; |
67 | 66 | top: 0; |
68 | 67 | right: 0; |
|
74 | 73 | pointer-events: none; |
75 | 74 | } |
76 | 75 |
|
77 | | - // If the popover helper is open, show the actual popover |
78 | 76 | .helper:popover-open ~ .controlledPopover { |
79 | | - display: block; |
| 77 | + display: block; // 3. |
80 | 78 | } |
81 | 79 |
|
82 | 80 | // Sides |
|
242 | 240 | .isRootControlled.isRootAtBottom, |
243 | 241 | .isRootControlled.isRootAtLeft, |
244 | 242 | .isRootControlled.isRootAtRight { |
245 | | - inset: unset; // 1. |
| 243 | + inset: unset; // 4. |
246 | 244 | } |
247 | 245 |
|
248 | 246 | .isRootControlled.isRootAtTop { |
249 | | - transform: translate(0, calc(-1 * #{theme.$arrow-height})); // 2. |
| 247 | + transform: translate(0, calc(-1 * #{theme.$arrow-height})); // 5. |
250 | 248 | } |
251 | 249 |
|
252 | 250 | .isRootControlled.isRootAtBottom { |
253 | | - transform: translate(0, #{theme.$arrow-height}); // 2. |
| 251 | + transform: translate(0, #{theme.$arrow-height}); // 5. |
254 | 252 | } |
255 | 253 |
|
256 | 254 | .isRootControlled.isRootAtLeft { |
257 | | - transform: translate(calc(-1 * #{theme.$arrow-height}), 0); // 2. |
| 255 | + transform: translate(calc(-1 * #{theme.$arrow-height}), 0); // 5. |
258 | 256 | } |
259 | 257 |
|
260 | 258 | .isRootControlled.isRootAtRight { |
261 | | - transform: translate(#{theme.$arrow-height}, 0); // 2. |
| 259 | + transform: translate(#{theme.$arrow-height}, 0); // 5. |
262 | 260 | } |
263 | 261 |
|
264 | 262 | .isRootControlled.isRootAtLeft.isRootAtStart, |
265 | 263 | .isRootControlled.isRootAtRight.isRootAtStart { |
266 | | - top: 0; // 3. |
| 264 | + top: 0; // 6. |
267 | 265 | } |
268 | 266 | } |
0 commit comments