feat: basic settings layout

This commit is contained in:
Shibo Lyu 2024-10-15 02:53:26 +08:00
parent 5c82a79b9c
commit 3097b8a9dd
8 changed files with 118 additions and 15 deletions

View file

@ -15,9 +15,10 @@
});
});
$: isSettings = $page.route.id?.startsWith('/settings');
$: isSettings = $page.route.id?.startsWith('/(app)/settings');
$: mainVisible =
!!$page.params.chatId || (isSettings && !$page.route.id?.startsWith('/settings/_mobile_empty'));
!!$page.params.chatId ||
(isSettings && !$page.route.id?.startsWith('/(app)/settings/_mobile_empty'));
</script>
<div
@ -29,7 +30,7 @@
>
<ChatList />
{#if isSettings}
<SettingsList />
<SettingsList class="absolute inset-0 z-10 size-full [view-transition-name:settings-list]" />
{/if}
</aside>
{#if mainVisible}
@ -61,6 +62,27 @@
}
}
@keyframes float-in {
from {
transform: scale(0.9);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
@keyframes float-out {
from {
transform: scale(1);
opacity: 1;
}
to {
transform: scale(0.9);
opacity: 0;
}
}
:root::view-transition-old(root),
:root::view-transition-new(root) {
animation-duration: 250ms;
@ -71,4 +93,14 @@
:root::view-transition-new(main) {
animation: 250ms ease-out slide-in;
}
:root::view-transition-old(settings-list),
:root::view-transition-new(settings-list) {
transform-origin: top left;
}
:root::view-transition-old(settings-list) {
animation: 250ms ease-out float-out;
}
:root::view-transition-new(settings-list) {
animation: 250ms ease-out float-in;
}
</style>

View file

@ -25,6 +25,8 @@
}
</script>
{#await getAccount($currentAccountStore) then currentAccount}
{#await getAccount($currentAccountStore)}
<ProfilePicture account={undefined} />
{:then currentAccount}
<ProfilePicture account={currentAccount} {size} />
{/await}

View file

@ -3,6 +3,7 @@
import { formatUnreadCount } from '$lib/formatters';
import type { Chat } from '$lib/types';
import { AvatarBeam } from 'svelte-boring-avatars';
import { ChevronLeft, Icon } from 'svelte-hero-icons';
export let info: Chat;
export let outsideUnreadCount = 0;
@ -12,16 +13,7 @@
class="relative z-10 box-border flex min-h-[calc(3rem+1px)] w-full items-center gap-2 border-b border-ss-secondary bg-sb-primary p-2 shadow-sm"
>
<Button href="/" class="rounded-full sm:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="-me-0.5 -ms-1 size-5"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5 8.25 12l7.5-7.5" />
</svg>
<Icon src={ChevronLeft} />
{#if outsideUnreadCount}
<span class="text-xs text-sf-tertiary">{formatUnreadCount(outsideUnreadCount)}</span>
{/if}

View file

@ -0,0 +1,39 @@
<script lang="ts">
import Button from '$lib/components/Button.svelte';
import { GroupedListSection, GroupedListItem } from '$lib/components/GroupedList';
import { tw } from '$lib/tw';
import {
Bell,
Cog,
DevicePhoneMobile,
InformationCircle,
LockClosed,
QuestionMarkCircle,
UserPlus
} from 'svelte-hero-icons';
let className = '';
export { className as class };
</script>
<div class={tw('flex flex-col bg-sb-secondary shadow-md', className)}>
<div class="flex items-center border-b border-ss-secondary bg-sb-primary p-2 shadow-sm">
<Button href="/">Done</Button>
<h2 class="flex-1 truncate text-center font-semibold text-sf-primary">Settings</h2>
</div>
<div class="flex-1 overflow-y-scroll">
<GroupedListSection>
<GroupedListItem icon={UserPlus}>Add Account</GroupedListItem>
</GroupedListSection>
<GroupedListSection>
<GroupedListItem icon={Cog}>General</GroupedListItem>
<GroupedListItem icon={Bell}>Notifications</GroupedListItem>
<GroupedListItem icon={LockClosed}>Privacy and Security</GroupedListItem>
<GroupedListItem icon={DevicePhoneMobile}>Devices</GroupedListItem>
</GroupedListSection>
<GroupedListSection>
<GroupedListItem icon={InformationCircle}>About Blah & Weblah</GroupedListItem>
<GroupedListItem icon={QuestionMarkCircle}>Ask a Question</GroupedListItem>
</GroupedListSection>
</div>
</div>