feat: add progress bar to signup flow #234
@@ -15,6 +15,7 @@
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ProgressBar from "@app/components/ProgressBar.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {PLATFORM_NAME} from "@app/core/state"
|
||||
|
||||
@@ -22,9 +23,11 @@
|
||||
secret: string
|
||||
next: () => unknown
|
||||
submitText?: string
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {secret, next, submitText = "Continue"}: Props = $props()
|
||||
const {secret, next, submitText = "Continue", step, totalSteps}: Props = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
@@ -150,6 +153,9 @@
|
||||
</Button>
|
||||
</div>
|
||||
</ModalBody>
|
||||
{#if step && totalSteps}
|
||||
<ProgressBar current={step} total={totalSteps} />
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
|
||||
@@ -23,9 +23,10 @@
|
||||
onsubmit: (values: Values) => void
|
||||
isSignup?: boolean
|
||||
footer: Snippet
|
||||
progressBar?: Snippet
|
||||
}
|
||||
|
||||
const {initialValues, isSignup, onsubmit, footer}: Props = $props()
|
||||
const {initialValues, isSignup, onsubmit, footer, progressBar}: Props = $props()
|
||||
|
||||
const values = $state(initialValues)
|
||||
|
||||
@@ -103,6 +104,9 @@
|
||||
</Field>
|
||||
{/if}
|
||||
</ModalBody>
|
||||
{#if progressBar}
|
||||
{@render progressBar()}
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
{@render footer()}
|
||||
</ModalFooter>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<script lang="ts">
|
||||
const {current, total}: {current: number; total: number} = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex w-full">
|
||||
{#each Array(total) as _, i}
|
||||
<div class="h-1 flex-1 transition-colors {i < current ? 'bg-primary' : 'bg-base-300'}"></div>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -62,9 +62,10 @@
|
||||
|
||||
const flows = {
|
||||
email: {
|
||||
start: () => pushModal(SignUpEmail, {next: flows.email.profile}),
|
||||
profile: () => pushModal(SignUpProfile, {next: flows.email.complete}),
|
||||
complete: () => pushModal(SignUpComplete, {next: flows.email.finalize}),
|
||||
start: () => pushModal(SignUpEmail, {next: flows.email.profile, step: 1, totalSteps: 3}),
|
||||
profile: () => pushModal(SignUpProfile, {next: flows.email.complete, step: 2, totalSteps: 3}),
|
||||
complete: () =>
|
||||
pushModal(SignUpComplete, {next: flows.email.finalize, step: 3, totalSteps: 3}),
|
||||
finalize: () => {
|
||||
const email = getKey<string>("signup.email")!
|
||||
const clientOptions = getKey<ClientOptions>("signup.clientOptions")!
|
||||
@@ -74,9 +75,10 @@
|
||||
},
|
||||
},
|
||||
nostr: {
|
||||
start: () => pushModal(SignUpProfile, {next: flows.nostr.key}),
|
||||
key: () => pushModal(SignUpKey, {next: flows.nostr.complete}),
|
||||
complete: () => pushModal(SignUpComplete, {next: flows.nostr.finalize}),
|
||||
start: () => pushModal(SignUpProfile, {next: flows.nostr.key, step: 1, totalSteps: 3}),
|
||||
key: () => pushModal(SignUpKey, {next: flows.nostr.complete, step: 2, totalSteps: 3}),
|
||||
complete: () =>
|
||||
pushModal(SignUpComplete, {next: flows.nostr.finalize, step: 3, totalSteps: 3}),
|
||||
finalize: () => {
|
||||
const secret = getKey<string>("signup.secret")!
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ProgressBar from "@app/components/ProgressBar.svelte"
|
||||
|
||||
type Props = {
|
||||
next: () => void
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {next}: Props = $props()
|
||||
const {next, step, totalSteps}: Props = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
</script>
|
||||
@@ -33,6 +36,9 @@
|
||||
on groups you've already joined. Click below to get started!
|
||||
</p>
|
||||
</ModalBody>
|
||||
{#if step && totalSteps}
|
||||
<ProgressBar current={step} total={totalSteps} />
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import SignUpEmailConfirm from "@app/components/SignUpEmailConfirm.svelte"
|
||||
import ProgressBar from "@app/components/ProgressBar.svelte"
|
||||
import {pushToast, popToast} from "@app/util/toast"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
type Props = {
|
||||
next: () => void
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {next}: Props = $props()
|
||||
const {next, step, totalSteps}: Props = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
@@ -81,7 +84,7 @@
|
||||
setKey("signup.clientOptions", clientOptions)
|
||||
|
||||
popToast(toastId)
|
||||
pushModal(SignUpEmailConfirm, {next})
|
||||
pushModal(SignUpEmailConfirm, {next, step, totalSteps})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
@@ -139,6 +142,9 @@
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
</ModalBody>
|
||||
{#if step && totalSteps}
|
||||
<ProgressBar current={step} total={totalSteps} />
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
||||
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ProgressBar from "@app/components/ProgressBar.svelte"
|
||||
|
||||
type Props = {
|
||||
next: () => void
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {next}: Props = $props()
|
||||
const {next, step, totalSteps}: Props = $props()
|
||||
|
||||
const email = getKey<string>("signup.email")
|
||||
|
||||
@@ -61,6 +64,9 @@
|
||||
above.
|
||||
</p>
|
||||
</ModalBody>
|
||||
{#if step && totalSteps}
|
||||
<ProgressBar current={step} total={totalSteps} />
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back} disabled={loading}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
type Props = {
|
||||
next: () => void
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {next}: Props = $props()
|
||||
const {next, step, totalSteps}: Props = $props()
|
||||
|
||||
const secret = getKey<string>("signup.secret")!
|
||||
</script>
|
||||
|
||||
<KeyDownload {secret} {next} />
|
||||
<KeyDownload {secret} {next} {step} {totalSteps} />
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
import {getKey, setKey} from "@lib/implicit"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Modal from "@lib/components/Modal.svelte"
|
||||
import ModalBody from "@lib/components/ModalBody.svelte"
|
||||
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
||||
import ProgressBar from "@app/components/ProgressBar.svelte"
|
||||
|
||||
type Props = {
|
||||
next: () => void
|
||||
step?: number
|
||||
totalSteps?: number
|
||||
}
|
||||
|
||||
const {next}: Props = $props()
|
||||
const {next, step, totalSteps}: Props = $props()
|
||||
|
||||
const profile = getKey<Profile>("signup.profile")!
|
||||
|
||||
@@ -27,19 +28,20 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal>
|
||||
<ModalBody>
|
||||
<ProfileEditForm isSignup {initialValues} {onsubmit}>
|
||||
{#snippet footer()}
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button class="btn btn-primary" type="submit">
|
||||
Create Account
|
||||
<Icon icon={AltArrowRight} />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</ProfileEditForm>
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
<ProfileEditForm isSignup {initialValues} {onsubmit}>
|
||||
{#snippet footer()}
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button class="btn btn-primary" type="submit">
|
||||
Create Account
|
||||
<Icon icon={AltArrowRight} />
|
||||
</Button>
|
||||
{/snippet}
|
||||
{#snippet progressBar()}
|
||||
{#if step && totalSteps}
|
||||
<ProgressBar current={step} total={totalSteps} />
|
||||
{/if}
|
||||
{/snippet}
|
||||
</ProfileEditForm>
|
||||
|
||||
Reference in New Issue
Block a user