Skip to content

Commit 8fbd554

Browse files
committed
📚 Rename (#1907)
1 parent 339eb60 commit 8fbd554

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/lib/actions/handle_dropdown.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let resizeTimeout: ReturnType<typeof setTimeout>;
3434
* isOpen: $isMenuOpen,
3535
* closeDropdown: () => isMenuOpen.set(false),
3636
* onStatusChange: (status) => console.log(`Menu is ${status ? 'open' : 'closed'}`)
37-
* updatePosition: (x, y, isLower) => {updateDropdownPosition(x, y, isLower)},
37+
* updatePosition: (x, y, isInBottomHalf) => {updateDropdownPosition(x, y, isInBottomHalf)},
3838
* }}>
3939
* <!-- Dropdown content -->
4040
* </div>
@@ -46,7 +46,7 @@ export function handleDropdownBehavior(
4646
isOpen: boolean;
4747
closeDropdown: () => void;
4848
onStatusChange?: (status: boolean) => void;
49-
updatePosition?: (x: number, y: number, isLower: boolean) => void;
49+
updatePosition?: (x: number, y: number, isInBottomHalf: boolean) => void;
5050
},
5151
) {
5252
if (!browser) {
@@ -107,7 +107,7 @@ export function handleDropdownBehavior(
107107
isOpen: boolean;
108108
closeDropdown: () => void;
109109
onStatusChange?: (status: boolean) => void;
110-
updatePosition?: (x: number, y: number, isLower: boolean) => void;
110+
updatePosition?: (x: number, y: number, isInBottomHalf: boolean) => void;
111111
}) {
112112
Object.assign(options, newOptions);
113113
},
@@ -133,12 +133,12 @@ export function handleDropdownBehavior(
133133
* @returns An object containing:
134134
* - x: The horizontal position (right edge of the element)
135135
* - y: The vertical position (bottom edge of the element)
136-
* - isLower: Boolean indicating whether the element is in the lower half of the viewport
136+
* - isInBottomHalf: Boolean indicating whether the element is in the lower half of the viewport
137137
*/
138138
export function calculateDropdownPosition(event: MouseEvent): {
139139
x: number;
140140
y: number;
141-
isLower: boolean;
141+
isInBottomHalf: boolean;
142142
} {
143143
lastTriggerElement = event.currentTarget as HTMLElement;
144144
const rect = (lastTriggerElement as HTMLElement).getBoundingClientRect();
@@ -147,7 +147,7 @@ export function calculateDropdownPosition(event: MouseEvent): {
147147
return {
148148
x: x,
149149
y: y,
150-
isLower: rect.top > window.innerHeight / 2,
150+
isInBottomHalf: rect.top > window.innerHeight / 2,
151151
};
152152
}
153153

@@ -167,11 +167,11 @@ export function calculateDropdownPosition(event: MouseEvent): {
167167
* and will do nothing if either is undefined or if the dropdown is not open.
168168
*
169169
* The dropdown will be positioned at the bottom-right corner of the trigger element.
170-
* The `isLower` parameter passed to `updatePosition` will be true if the trigger is
170+
* The `isInBottomHalf` parameter passed to `updatePosition` will be true if the trigger is
171171
* in the top half of the screen, suggesting the dropdown should expand downward.
172172
*/
173173
export function recalculateDropdownPosition(options: {
174-
updatePosition: (x: number, y: number, isLower: boolean) => void;
174+
updatePosition: (x: number, y: number, isInBottomHalf: boolean) => void;
175175
dropdownIsOpen: boolean;
176176
}): void {
177177
if (!browser || !lastTriggerElement || !options.dropdownIsOpen) {

src/lib/components/SubmissionStatus/UpdatingDropdown.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
let dropdownStatus = $state(false);
6363
let closeDropdown = dropdown.close;
6464
65-
let dropdownPosition = $state({ x: 0, y: 0, isLower: false });
65+
let dropdownPosition = $state({ x: 0, y: 0, isInBottomHalf: false });
6666
const componentId = Math.random().toString(36).substring(2);
6767
6868
$effect(() => {
@@ -86,23 +86,23 @@
8686
// Required for the dropdown to open at the correct position.
8787
function updateDropdownPosition(event: MouseEvent): void {
8888
const position = calculateDropdownPosition(event);
89-
updatePositionInComponent(position.x, position.y, position.isLower);
89+
updatePositionInComponent(position.x, position.y, position.isInBottomHalf);
9090
}
9191
92-
function updatePositionInComponent(x: number, y: number, isLower: boolean) {
93-
dropdownPosition = { x, y, isLower };
92+
function updatePositionInComponent(x: number, y: number, isInBottomHalf: boolean) {
93+
dropdownPosition = { x, y, isInBottomHalf };
9494
9595
if (browser) {
9696
document.documentElement.style.setProperty('--dropdown-x', `${x}px`);
9797
document.documentElement.style.setProperty('--dropdown-y', `${y}px`);
9898
}
9999
}
100100
101-
function getDropdownClasses(isLower: boolean): string {
101+
function getDropdownClasses(isInBottomHalf: boolean): string {
102102
let classes =
103103
'absolute w-32 z-[999] shadow-lg pointer-events-auto left-[var(--dropdown-x)] transform -translate-x-full ';
104104
105-
if (isLower) {
105+
if (isInBottomHalf) {
106106
classes += 'bottom-[calc(100vh-var(--dropdown-y))] mb-5';
107107
} else {
108108
classes += 'top-[var(--dropdown-y)] mt-1';
@@ -237,7 +237,7 @@
237237
{activeUrl}
238238
{dropdownStatus}
239239
{closeDropdown}
240-
class={getDropdownClasses(dropdownPosition.isLower)}
240+
class={getDropdownClasses(dropdownPosition.isInBottomHalf)}
241241
>
242242
<DropdownUl class="border rounded-lg shadow">
243243
{#if isLoggedIn}

0 commit comments

Comments
 (0)