Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frontend/src/lib/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ body {
html {
background-color: var(--color-bg-primary);
-webkit-font-smoothing: antialiased;
color-scheme: light dark;
}

button:not(:disabled),
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/lib/components/ui/Avatar.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";

type Size = "sm" | "md" | "lg" | "xl";
type Size = "xs" | "sm" | "md" | "lg" | "xl";

type Props = HTMLAttributes<HTMLDivElement> & { size?: Size };

Expand All @@ -13,6 +13,7 @@
class={[
"bg-bg-secondary border-border-secondary text-fg-disabled flex shrink-0 items-center justify-center rounded-full border font-semibold",
{
xs: "size-6 text-xs",
sm: "size-8 text-sm",
md: "size-10 text-sm",
lg: "size-12 text-base",
Expand Down
37 changes: 29 additions & 8 deletions src/frontend/src/lib/components/ui/Dialog.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte";
import { scale, fly } from "svelte/transition";
import type { HTMLAttributes } from "svelte/elements";
import type { ClassValue, HTMLAttributes } from "svelte/elements";
import { nonNullish } from "@dfinity/utils";
import { XIcon } from "@lucide/svelte";
import { t } from "$lib/stores/locale.store";
Expand All @@ -11,6 +11,7 @@
closeOnOutsideClick?: boolean;
showCloseButton?: boolean;
backdrop?: boolean;
contentClass?: ClassValue | null;
};

const {
Expand All @@ -20,6 +21,7 @@
closeOnOutsideClick = nonNullish(onClose),
showCloseButton = nonNullish(onClose),
backdrop = true,
contentClass,
...props
}: Props = $props();

Expand Down Expand Up @@ -67,16 +69,30 @@
const preventScroll = (event: TouchEvent) => {
event.preventDefault();
};
const findScrollableParent = (target: HTMLElement): HTMLElement => {
let scrollableParent = target;
while (scrollableParent && scrollableParent !== contentRef) {
if (scrollableParent === contentRef) {
break;
}
if (scrollableParent.scrollHeight > scrollableParent.clientHeight) {
return scrollableParent;
}
scrollableParent = scrollableParent.parentElement as HTMLElement;
}
return contentRef;
};
let lastY = 0;
const touchScrollStart = (event: TouchEvent) => {
lastY = event.touches[0].clientY;
};
const touchScrollMove = (event: TouchEvent) => {
const scrollTarget = findScrollableParent(event.target as HTMLElement);
const y = event.touches[0].clientY;
const dy = y - lastY;
lastY = y;
contentRef.scrollTo({
top: contentRef.scrollTop - dy,
scrollTarget.scrollTo({
top: scrollTarget.scrollTop - dy,
behavior: "instant",
});
};
Expand Down Expand Up @@ -151,17 +167,22 @@
>
<!-- Non-interactive element to render dark-mode bottom sheet border gradient -->
<div
class="from-border-secondary pointer-events-none absolute top-0 right-0 left-0 z-0 hidden rounded-t-2xl bg-gradient-to-b to-transparent p-[1px] max-sm:dark:block"
>
<div class="bg-bg-primary_alt h-24 rounded-t-2xl"></div>
</div>
class={[
"from-border-secondary pointer-events-none absolute top-0 right-0 left-0 z-1 hidden h-24 rounded-t-2xl bg-gradient-to-b to-transparent p-[1px] max-sm:dark:block",
// Use a mask to only show the gradient on the border area, and prevent it from overlapping with the dialog content.
"![mask-composite:exclude] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]",
]}
></div>
<div class="flex flex-1 flex-col">
<div
bind:this={contentRef}
class="relative max-h-[var(--max-content-height)] overflow-y-auto"
>
<div
class="flex flex-1 shrink-0 flex-col px-4 pt-4 pb-4 sm:px-6 sm:pt-6 sm:pb-8"
class={[
"flex flex-1 shrink-0 flex-col px-4 pt-4 pb-4 sm:px-6 sm:pt-6 sm:pb-8",
contentClass,
]}
>
{@render children?.()}
{#if showCloseButton && nonNullish(onClose)}
Expand Down
Loading
Loading