style: Improved onboarding page styling and ux

This commit is contained in:
Aleksi Lassila
2024-06-18 19:24:51 +03:00
parent d687b33249
commit 7c31ee4ce9
3 changed files with 40 additions and 32 deletions

View File

@@ -9,6 +9,7 @@
export let disabled: boolean = false; export let disabled: boolean = false;
export let focusOnMount: boolean = false; export let focusOnMount: boolean = false;
export let focusedChild = false;
export let type: 'primary' | 'secondary' | 'primary-dark' = 'primary'; export let type: 'primary' | 'secondary' | 'primary-dark' = 'primary';
export let confirmDanger = false; export let confirmDanger = false;
export let action: (() => Promise<any>) | null = null; export let action: (() => Promise<any>) | null = null;
@@ -62,6 +63,7 @@
on:clickOrSelect={handleClickOrSelect} on:clickOrSelect={handleClickOrSelect}
on:enter on:enter
{focusOnMount} {focusOnMount}
{focusedChild}
> >
<div <div
class={classNames({ class={classNames({

View File

@@ -60,18 +60,18 @@
Looks like this is a new account. This setup will get you started with connecting your Looks like this is a new account. This setup will get you started with connecting your
services to get most out of Reiverr. services to get most out of Reiverr.
</div> </div>
<Container direction="horizontal" class="flex space-x-4"> <Container direction="horizontal" class="flex space-x-4 *:flex-1">
<Button type="primary-dark" on:clickOrSelect={() => sessions.removeSession()} <Button type="primary-dark" on:clickOrSelect={() => sessions.removeSession()}
>Log Out</Button >Log Out</Button
> >
<div class="flex-1"> <Button
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}> focusOnMount
Next type="primary-dark"
<div class="absolute inset-y-0 right-0 flex items-center justify-center"> on:clickOrSelect={() => tab.next()}
<ArrowRight size={24} /> iconAbsolute={ArrowRight}
</div> >
</Button> Next
</div> </Button>
</Container> </Container>
</Tab> </Tab>
@@ -97,13 +97,12 @@
{/if} {/if}
<Container direction="horizontal" class="flex space-x-4 *:flex-1 mt-4"> <Container direction="horizontal" class="flex space-x-4 *:flex-1 mt-4">
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button> <Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button>
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}> <Button focusedChild type="primary-dark" on:clickOrSelect={() => tab.next()}>
{#if connected} {#if connected}
Next Next
{:else} {:else}
Skip Skip
{/if} {/if}
<ArrowRight size={19} slot="icon-absolute" />
</Button> </Button>
</Container> </Container>
</TmdbIntegration> </TmdbIntegration>
@@ -160,7 +159,7 @@
<Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4"> <Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4">
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button> <Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button>
{#if empty || unchanged} {#if empty || unchanged}
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}> <Button focusedChild type="primary-dark" on:clickOrSelect={() => tab.next()}>
{empty ? 'Skip' : 'Next'} {empty ? 'Skip' : 'Next'}
</Button> </Button>
{:else} {:else}
@@ -233,7 +232,7 @@
<Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4"> <Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4">
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button> <Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button>
{#if empty || unchanged} {#if empty || unchanged}
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}> <Button focusedChild type="primary-dark" on:clickOrSelect={() => tab.next()}>
{empty ? 'Skip' : 'Next'} {empty ? 'Skip' : 'Next'}
</Button> </Button>
{:else} {:else}
@@ -257,7 +256,7 @@
<Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4"> <Container direction="horizontal" class="grid grid-cols-2 gap-4 mt-4">
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button> <Button type="primary-dark" on:clickOrSelect={() => tab.previous()}>Back</Button>
{#if empty || unchanged} {#if empty || unchanged}
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}> <Button focusedChild type="primary-dark" on:clickOrSelect={() => tab.next()}>
{empty ? 'Skip' : 'Next'} {empty ? 'Skip' : 'Next'}
</Button> </Button>
{:else} {:else}
@@ -278,16 +277,21 @@
<CheckCircled size={64} /> <CheckCircled size={64} />
</div> </div>
<h1 class="header2 text-center w-full">All Set!</h1> <h1 class="header2 text-center w-full">All Set!</h1>
<div class="header1 mb-8 text-center">Reiverr is now ready to use.</div> <div class="body mb-8 text-center">Reiverr is now ready to use.</div>
<Container direction="horizontal" class="inline-flex space-x-4 w-full"> <Container direction="horizontal" class="inline-flex space-x-4 w-full">
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()} icon={ArrowLeft} <Button type="primary-dark" on:clickOrSelect={() => tab.previous()} icon={ArrowLeft}>
>Back</Button Back
> </Button>
<div class="flex-1"> <div class="flex-1">
<Button type="primary-dark" on:clickOrSelect={finalizeSetup} iconAbsolute={ArrowRight} <Button
>Done</Button focusedChild
type="primary-dark"
on:clickOrSelect={finalizeSetup}
iconAbsolute={ArrowRight}
> >
Done
</Button>
</div> </div>
</Container> </Container>
</Tab> </Tab>

View File

@@ -580,6 +580,20 @@ export class Selectable {
console.error('No html element found for', this); console.error('No html element found for', this);
return; return;
} }
if (this.makeFocusedChild) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let el: Selectable = this;
let parent = el.parent;
while (parent && !get(parent.hasFocusWithin)) {
console.log('setting parent focusIndex', parent, parent.children.indexOf(el));
parent.focusIndex.update((prev) => parent?.children?.indexOf(el) || prev);
el = parent;
parent = el.parent;
}
}
} }
_unmountContainer() { _unmountContainer() {
@@ -744,18 +758,6 @@ export class Selectable {
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
child.parent = this; child.parent = this;
if (child.makeFocusedChild) {
let el = child;
let parent = el.parent;
while (parent && !get(parent.hasFocusWithin)) {
parent.focusIndex.update((prev) => parent?.children?.indexOf(el) || prev);
el = parent;
parent = el.parent;
}
}
return childToFocus; return childToFocus;
} }