Skip to content

Commit 4e169e2

Browse files
committed
feat: refine mobile menu and select transitions and styles
The changes improve the animation timing, adjust border colors and radius, and add null checks for content binding.
1 parent cff079a commit 4e169e2

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/lib/menu/content.svelte

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { getContext, type Snippet } from 'svelte';
33
import type { HTMLAttributes } from 'svelte/elements';
44
import { fly } from 'svelte/transition';
5+
import { cubicOut } from 'svelte/easing';
56
67
interface Props extends HTMLAttributes<HTMLDivElement> {
78
class?: string;
@@ -29,10 +30,12 @@
2930
3031
let content: HTMLDivElement = $state<any>();
3132
$effect(() => {
32-
if (rootState.getIsActive()) {
33-
content.setAttribute('aria-hidden', 'false');
34-
} else {
35-
content.setAttribute('aria-hidden', 'true');
33+
if (content) {
34+
if (rootState.getIsActive()) {
35+
content.setAttribute('aria-hidden', 'false');
36+
} else {
37+
content.setAttribute('aria-hidden', 'true');
38+
}
3639
}
3740
});
3841
</script>
@@ -41,14 +44,14 @@
4144
{#if rootState.getIsActive()}
4245
<div
4346
bind:this={content}
44-
in:fly|local={{ y: '100vh', duration: 500, opacity: 1 }}
45-
out:fly|local={{ y: '100vh', duration: 500, opacity: 1 }}
46-
class="fixed bottom-0 left-0 w-full rounded-t-[15px] bg-kui-light-bg-secondary dark:bg-kui-dark-bg-secondary lg:bg-transparent z-[1001]"
47+
in:fly|local={{ y: '50vh', duration: 500, opacity: 1 }}
48+
out:fly|local={{ y: '100vh', duration: 600, easing: cubicOut, opacity: 1 }}
49+
class="fixed bottom-0 left-0 w-full rounded-t-[10px] bg-kui-light-bg-secondary dark:bg-kui-dark-bg-secondary lg:bg-transparent z-[1001]"
4750
{...rest}
4851
>
4952
<div
50-
class="hide-scrollbar bg-kui-light-bg dark:bg-kui-dark-bg px-3 rounded-t-[15px] border-t
51-
border-kui-light-gray-200 dark:border-kui-dark-gray-200 scroll-smooth overflow-y-auto"
53+
class="hide-scrollbar bg-kui-light-bg dark:bg-kui-dark-bg px-3 rounded-t-[10px] border-t
54+
border-kui-light-gray-600 dark:border-kui-dark-gray-500 scroll-smooth overflow-y-auto"
5255
>
5356
{@render children()}
5457
</div>

src/lib/select/content.svelte

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import { Button } from '$lib/index.js';
33
import { getContext, type Snippet } from 'svelte';
44
import { fly } from 'svelte/transition';
5+
import { cubicOut } from 'svelte/easing';
56
67
interface Props {
78
class?: string;
89
children: Snippet;
9-
};
10+
}
1011
let { class: klass = '', children }: Props = $props();
1112
1213
// Get the state of the select from the context
@@ -23,13 +24,14 @@
2324
{#snippet mobileSnip()}
2425
{#if rootState.getIsActive()}
2526
<div
26-
in:fly|local={{ y: '100vh', duration: 500, opacity: 1 }}
27-
out:fly|local={{ y: '100vh', duration: 500, opacity: 1 }}
28-
class="fixed bottom-0 left-0 w-full rounded-t-[15px] bg-kui-light-bg-secondary dark:bg-kui-dark-bg-secondary lg:bg-transparent z-[1001]"
27+
in:fly|local={{ y: '50vh', duration: 500, opacity: 1 }}
28+
out:fly|local={{ y: '100vh', duration: 600, easing: cubicOut, opacity: 1 }}
29+
class="fixed bottom-0 left-0 w-full rounded-t-[10px] bg-kui-light-bg-secondary dark:bg-kui-dark-bg-secondary lg:bg-transparent z-[1001]"
2930
>
3031
<div
31-
class="hide-scrollbar bg-kui-light-bg dark:bg-kui-dark-bg px-3 py-3 rounded-t-[15px] border-y
32-
border-kui-light-gray-200 dark:border-kui-dark-gray-200 scroll-smooth overflow-y-auto"
32+
class="hide-scrollbar bg-kui-light-bg dark:bg-kui-dark-bg px-3 py-3 rounded-t-[10px] border-b
33+
border-b-kui-light-gray-200 dark:border-b-kui-dark-gray-200 border-t border-t-kui-light-gray-600
34+
dark:border-t-kui-dark-gray-500 scroll-smooth overflow-y-auto"
3335
>
3436
{@render children()}
3537
</div>

0 commit comments

Comments
 (0)