Skip to content

Commit 40d9e62

Browse files
style(frontend): preserve wide size for centered spotlight popover
1 parent 0124bdc commit 40d9e62

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/frontend/src/lib/components/core/Spotlight.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
<svelte:window onjunoSpotlight={() => (visible = true)} {onkeydown} />
112112

113-
<Popover backdrop="dark" center bind:visible>
113+
<Popover backdrop="dark" center="wide" bind:visible>
114114
<div class="container">
115115
<div class="search" role="search">
116116
<span class="search-title"

src/frontend/src/lib/components/ui/Popover.svelte

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { nonNullish } from '@dfinity/utils';
2+
import { isNullish, nonNullish } from '@dfinity/utils';
33
import type { Snippet } from 'svelte';
44
import { quintOut } from 'svelte/easing';
55
import { stopPropagation } from 'svelte/legacy';
@@ -12,7 +12,7 @@
1212
anchor?: HTMLElement | undefined;
1313
visible?: boolean;
1414
direction?: 'ltr' | 'rtl';
15-
center?: boolean;
15+
center?: boolean | 'wide';
1616
closeButton?: boolean;
1717
backdrop?: 'light' | 'dark';
1818
children: Snippet;
@@ -22,7 +22,7 @@
2222
anchor = undefined,
2323
visible = $bindable(false),
2424
direction = 'ltr',
25-
center = false,
25+
center,
2626
closeButton = false,
2727
backdrop = 'light',
2828
children
@@ -41,7 +41,7 @@
4141
: { bottom: 0, left: 0, right: 0 });
4242
4343
let position = $derived<'top' | 'bottom'>(
44-
bottom > window.innerHeight - 100 && !center ? 'bottom' : 'top'
44+
bottom > window.innerHeight - 100 && isNullish(center) ? 'bottom' : 'top'
4545
);
4646
4747
$effect(() => {
@@ -68,7 +68,8 @@
6868
: `--popover-left: ${left}px;`
6969
}`}
7070
class={`popover ${backdrop}`}
71-
class:center
71+
class:center={nonNullish(center)}
72+
class:wide={center === 'wide'}
7273
aria-orientation="vertical"
7374
role="menu"
7475
tabindex="-1"
@@ -83,7 +84,7 @@
8384
></div>
8485
<div
8586
class={`wrapper ${position}`}
86-
class:center
87+
class:center={nonNullish(center)}
8788
class:rtl={direction === 'rtl'}
8889
transition:scale={{ delay: 25, duration: 150, easing: quintOut }}
8990
>
@@ -114,6 +115,10 @@
114115
115116
&.center {
116117
--popover-min-size: 280px;
118+
119+
&.wide {
120+
--popover-min-size: 540px;
121+
}
117122
}
118123
}
119124
</style>

0 commit comments

Comments
 (0)