-
Notifications
You must be signed in to change notification settings - Fork 103
/
OnboardingLayout.svelte
46 lines (41 loc) · 1.53 KB
/
OnboardingLayout.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<script lang="ts">
import { Animation, Icon, Text, TextType } from '@ui'
import { isKeyboardOpen, keyboardHeight } from '@/auxiliary/keyboard'
export let allowBack = true
export let animation = ''
export let busy = false
export let title = ''
export let onBackClick = (): void => {}
let scrollWraper: HTMLElement
$: if ($isKeyboardOpen) {
setTimeout(() => {
scrollWraper?.scrollTo({ top: 100 })
})
}
</script>
<div data-label="mobile-onboarding-layout" class="relative h-full p-5 flex flex-col justify-between">
<header class="relative w-full flex justify-center px-6">
<Text type={TextType.h4} classes="text-center">{title}</Text>
{#if allowBack}
<button on:click={onBackClick} class="absolute left-0" disabled={busy}>
<Icon
icon="arrow-left"
classes={busy ? 'pointer-events-none text-gray-500' : 'cursor-pointer text-blue-500'}
/>
</button>
{/if}
</header>
<div class="flex flex-col overflow-y-auto h-full pt-5">
{#if animation && $isKeyboardOpen === false}
<div class="mt-24 w-full flex justify-center">
<Animation {animation} />
</div>
{/if}
<div bind:this={scrollWraper} class="overflow-hidden">
<slot name="content" />
</div>
</div>
<footer style={$isKeyboardOpen && `margin-bottom: ${$keyboardHeight}px`}>
<slot name="footer" />
</footer>
</div>