feat: rebuild onboarding experience
This commit is contained in:
1 parent
d091362db2
commit
e41605640b
249 files changed
+8216
-14060
No files matched your search
@@ -0,0 +1,134 @@
|
||||
"use client";
|
||||
|
||||
import { Alert, Button, Group, Paper, Stack, Text, TextInput, ThemeIcon, Title } from "@mantine/core";
|
||||
import { IconArrowRight, IconShieldCheck, IconUserPlus } from "@tabler/icons-react";
|
||||
import type { z } from "zod/v4";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { signIn } from "@homarr/auth/client";
|
||||
import { revalidatePathActionAsync } from "@homarr/common/client";
|
||||
import { useZodForm } from "@homarr/form";
|
||||
import { UserCreatePasswordFields } from "@homarr/forms-collection";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { groupCreateSchema } from "@homarr/validation/group";
|
||||
import { userInitSchema } from "@homarr/validation/user";
|
||||
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
const AccountShell = ({
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
children: React.ReactNode;
|
||||
}) => (
|
||||
<main className={classes.page}>
|
||||
<div className={classes.shell}>
|
||||
<Stack mih="calc(100dvh - 6rem)" justify="center" align="center">
|
||||
<Paper className={classes.studio} radius="lg" p={{ base: "lg", sm: "xl" }} w="100%" maw="36rem">
|
||||
<Stack gap="xl">
|
||||
<Group wrap="nowrap" align="flex-start">
|
||||
<ThemeIcon size="xl" radius="lg" variant="light">
|
||||
<IconShieldCheck size={24} />
|
||||
</ThemeIcon>
|
||||
<Stack gap={4}>
|
||||
<Title order={1} size="h2">
|
||||
{title}
|
||||
</Title>
|
||||
<Text c="dimmed">{description}</Text>
|
||||
</Stack>
|
||||
</Group>
|
||||
{children}
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
|
||||
export const AccountSetup = ({ environment }: OnboardingStudioProps) => {
|
||||
if (environment.currentStep === "user") return <CredentialsSetup />;
|
||||
return <ExternalGroupSetup />;
|
||||
};
|
||||
|
||||
const CredentialsSetup = () => {
|
||||
const t = useScopedI18n("init.studio.account");
|
||||
const mutation = clientApi.user.initUser.useMutation();
|
||||
const form = useZodForm(userInitSchema, {
|
||||
initialValues: { username: "", password: "", confirmPassword: "" },
|
||||
});
|
||||
|
||||
const submitAsync = async (values: z.infer<typeof userInitSchema>) => {
|
||||
try {
|
||||
await mutation.mutateAsync(values);
|
||||
const result = await signIn("credentials", {
|
||||
name: values.username,
|
||||
password: values.password,
|
||||
redirect: false,
|
||||
});
|
||||
if (result?.error) throw new Error(t("signInError"));
|
||||
await revalidatePathActionAsync("/init");
|
||||
} catch (error) {
|
||||
form.setErrors({ username: error instanceof Error ? error.message : t("unknownError") });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AccountShell title={t("title")} description={t("description")}>
|
||||
<form onSubmit={form.onSubmit((values) => void submitAsync(values))}>
|
||||
<Stack gap="md">
|
||||
<TextInput label={t("username")} autoComplete="username" withAsterisk {...form.getInputProps("username")} />
|
||||
<UserCreatePasswordFields
|
||||
passwordInputProps={{ ...form.getInputProps("password"), autoComplete: "new-password" }}
|
||||
confirmPasswordInputProps={{ ...form.getInputProps("confirmPassword"), autoComplete: "new-password" }}
|
||||
/>
|
||||
{mutation.error ? (
|
||||
<Alert color="red" title={t("errorTitle")}>
|
||||
{mutation.error.message}
|
||||
</Alert>
|
||||
) : null}
|
||||
<Button type="submit" size="md" loading={mutation.isPending} rightSection={<IconArrowRight size={18} />}>
|
||||
{t("create")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</form>
|
||||
</AccountShell>
|
||||
);
|
||||
};
|
||||
|
||||
const ExternalGroupSetup = () => {
|
||||
const t = useScopedI18n("init.studio.externalGroup");
|
||||
const mutation = clientApi.group.createInitialExternalGroup.useMutation({
|
||||
async onSuccess() {
|
||||
await revalidatePathActionAsync("/init");
|
||||
},
|
||||
});
|
||||
const form = useZodForm(groupCreateSchema, { initialValues: { name: "" } });
|
||||
|
||||
return (
|
||||
<AccountShell title={t("title")} description={t("description")}>
|
||||
<form onSubmit={form.onSubmit((values) => mutation.mutate(values))}>
|
||||
<Stack gap="md">
|
||||
<TextInput
|
||||
label={t("name")}
|
||||
description={t("nameDescription")}
|
||||
leftSection={<IconUserPlus size={16} />}
|
||||
withAsterisk
|
||||
{...form.getInputProps("name")}
|
||||
/>
|
||||
{mutation.error ? (
|
||||
<Alert color="red" title={t("errorTitle")}>
|
||||
{mutation.error.message}
|
||||
</Alert>
|
||||
) : null}
|
||||
<Button type="submit" size="md" loading={mutation.isPending} rightSection={<IconArrowRight size={18} />}>
|
||||
{t("continue")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</form>
|
||||
</AccountShell>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,141 @@
|
||||
"use client";
|
||||
|
||||
import { Alert, Button, Group, Paper, SimpleGrid, Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||
import { IconArrowRight, IconBook2, IconLayoutDashboard, IconSparkles, IconTool } from "@tabler/icons-react";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
|
||||
import { createDocumentationLink } from "@homarr/definitions";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { Link } from "@homarr/ui";
|
||||
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
export const Finish = ({ environment }: OnboardingStudioProps) => {
|
||||
const t = useScopedI18n("init.studio.finish");
|
||||
const reduceMotion = useReducedMotion();
|
||||
const boardHref = `/boards/${encodeURIComponent(environment.initialBoard?.name ?? "dashboard")}`;
|
||||
const destination = environment.canConfigurePrivileged
|
||||
? boardHref
|
||||
: `/auth/login?callbackUrl=${encodeURIComponent(boardHref)}`;
|
||||
|
||||
return (
|
||||
<main className={classes.page}>
|
||||
<div className={classes.shell}>
|
||||
<Stack mih="calc(100dvh - 6rem)" justify="center" align="center">
|
||||
<motion.div
|
||||
initial={reduceMotion ? false : { opacity: 0, y: 22, scale: 0.97 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
style={{ width: "100%", maxWidth: "52rem" }}
|
||||
>
|
||||
<Paper className={classes.studio} radius="lg" p={{ base: "lg", sm: "xl" }}>
|
||||
<Stack gap="xl" align="center">
|
||||
<motion.div
|
||||
animate={reduceMotion ? undefined : { rotate: [0, 7, -7, 0], scale: [1, 1.08, 1] }}
|
||||
transition={{ duration: 2.8, repeat: Infinity, repeatDelay: 1.4 }}
|
||||
>
|
||||
<ThemeIcon size={78} radius="xl" variant="light" color="green">
|
||||
<IconSparkles size={36} />
|
||||
</ThemeIcon>
|
||||
</motion.div>
|
||||
<Stack gap="xs" align="center">
|
||||
<Title ta="center">{t("title")}</Title>
|
||||
<Text c="dimmed" ta="center" maw="42rem">
|
||||
{t("description")}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Button component={Link} href={destination} size="lg" rightSection={<IconArrowRight size={18} />}>
|
||||
{t("openBoard")}
|
||||
</Button>
|
||||
<Alert variant="light" w="100%" icon={<IconLayoutDashboard size={18} />}>
|
||||
{t("tutorial")}
|
||||
</Alert>
|
||||
<SimpleGrid cols={{ base: 1, sm: 3 }} w="100%">
|
||||
<NextCard
|
||||
icon={IconTool}
|
||||
title={t("manageTitle")}
|
||||
description={t("manageDescription")}
|
||||
href="/manage"
|
||||
/>
|
||||
<NextCard
|
||||
icon={IconSparkles}
|
||||
title={t("workshopTitle")}
|
||||
description={t("workshopDescription")}
|
||||
href="/manage/workshop"
|
||||
/>
|
||||
<NextCard
|
||||
icon={IconBook2}
|
||||
title={t("docsTitle")}
|
||||
description={t("docsDescription")}
|
||||
href={createDocumentationLink("/docs/getting-started/after-the-installation")}
|
||||
external
|
||||
/>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</motion.div>
|
||||
</Stack>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
const NextCard = (props: {
|
||||
icon: typeof IconTool;
|
||||
title: string;
|
||||
description: string;
|
||||
href: string;
|
||||
external?: boolean;
|
||||
}) => (props.external ? <ExternalNextCard {...props} /> : <InternalNextCard {...props} />);
|
||||
|
||||
const InternalNextCard = ({
|
||||
icon: Icon,
|
||||
title,
|
||||
description,
|
||||
href,
|
||||
}: {
|
||||
icon: typeof IconTool;
|
||||
title: string;
|
||||
description: string;
|
||||
href: string;
|
||||
}) => (
|
||||
<Paper className={classes.nextCard} component={Link} href={href} withBorder radius="md" p="md">
|
||||
<Stack gap="sm">
|
||||
<Group gap="xs">
|
||||
<ThemeIcon variant="light" size="md">
|
||||
<Icon size={17} />
|
||||
</ThemeIcon>
|
||||
<Text fw={650}>{title}</Text>
|
||||
</Group>
|
||||
<Text size="sm" c="dimmed">
|
||||
{description}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Paper>
|
||||
);
|
||||
|
||||
const ExternalNextCard = ({ icon: Icon, title, description, href }: Parameters<typeof NextCard>[0]) => (
|
||||
<Paper
|
||||
className={classes.nextCard}
|
||||
component="a"
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
withBorder
|
||||
radius="md"
|
||||
p="md"
|
||||
>
|
||||
<Stack gap="sm">
|
||||
<Group gap="xs">
|
||||
<ThemeIcon variant="light" size="md">
|
||||
<Icon size={17} />
|
||||
</ThemeIcon>
|
||||
<Text fw={650}>{title}</Text>
|
||||
</Group>
|
||||
<Text size="sm" c="dimmed">
|
||||
{description}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Paper>
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
export { OnboardingStudio } from "./onboarding-studio";
|
||||
export type { OnboardingEnvironment, OnboardingStudioProps } from "./types";
|
||||
@@ -0,0 +1,504 @@
|
||||
.page {
|
||||
--studio-surface: color-mix(in srgb, var(--mantine-color-body) 92%, transparent);
|
||||
min-height: 100dvh;
|
||||
overflow-x: clip;
|
||||
position: relative;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 10% 10%,
|
||||
color-mix(in srgb, var(--mantine-primary-color-filled) 14%, transparent),
|
||||
transparent 34rem
|
||||
),
|
||||
radial-gradient(
|
||||
circle at 90% 5%,
|
||||
color-mix(in srgb, var(--mantine-color-orange-6) 10%, transparent),
|
||||
transparent 30rem
|
||||
),
|
||||
var(--mantine-color-body);
|
||||
}
|
||||
|
||||
.page::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
opacity: 0.22;
|
||||
background-image: radial-gradient(circle, var(--mantine-color-dimmed) 0.7px, transparent 0.7px);
|
||||
background-size: 24px 24px;
|
||||
mask-image: linear-gradient(to bottom, black, transparent 75%);
|
||||
}
|
||||
|
||||
.shell {
|
||||
position: relative;
|
||||
width: min(100% - 2rem, 76rem);
|
||||
margin-inline: auto;
|
||||
padding-block: clamp(1rem, 3vw, 2.5rem) 5rem;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
min-height: 3rem;
|
||||
gap: var(--mantine-spacing-sm);
|
||||
}
|
||||
|
||||
.wordmark {
|
||||
display: block;
|
||||
width: clamp(9.5rem, 22vw, 14rem);
|
||||
height: auto;
|
||||
padding: 0.4rem 0.55rem;
|
||||
border-radius: var(--mantine-radius-md);
|
||||
background: rgba(12, 12, 14, 0.86);
|
||||
filter: drop-shadow(0 0.8rem 1.6rem color-mix(in srgb, black 22%, transparent));
|
||||
}
|
||||
|
||||
.hero {
|
||||
min-height: calc(100dvh - 8rem);
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(18rem, 0.9fr);
|
||||
align-items: center;
|
||||
gap: clamp(2rem, 6vw, 6rem);
|
||||
}
|
||||
|
||||
.heroTitle {
|
||||
font-size: clamp(2.5rem, 7vw, 5.8rem);
|
||||
line-height: 0.94;
|
||||
letter-spacing: -0.04em;
|
||||
text-wrap: balance;
|
||||
max-width: 11ch;
|
||||
}
|
||||
|
||||
.heroPanel,
|
||||
.studio {
|
||||
background: var(--studio-surface);
|
||||
backdrop-filter: blur(18px);
|
||||
border: 1px solid color-mix(in srgb, var(--mantine-color-default-border) 76%, transparent);
|
||||
box-shadow: var(--mantine-shadow-sm);
|
||||
}
|
||||
|
||||
.heroPanel {
|
||||
position: relative;
|
||||
min-height: 27rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.orbit {
|
||||
position: absolute;
|
||||
inset: 50% auto auto 50%;
|
||||
width: 18rem;
|
||||
height: 18rem;
|
||||
margin: -9rem;
|
||||
border-radius: 50%;
|
||||
border: 1px solid color-mix(in srgb, var(--mantine-primary-color-filled) 35%, transparent);
|
||||
}
|
||||
|
||||
.orbitItem {
|
||||
position: absolute;
|
||||
width: 3.25rem;
|
||||
height: 3.25rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: var(--mantine-radius-lg);
|
||||
background: var(--mantine-color-body);
|
||||
border: 1px solid var(--mantine-color-default-border);
|
||||
box-shadow: var(--mantine-shadow-md);
|
||||
}
|
||||
|
||||
.orbitItem:nth-child(1) {
|
||||
inset: -1.6rem auto auto calc(50% - 1.6rem);
|
||||
}
|
||||
.orbitItem:nth-child(2) {
|
||||
inset: calc(50% - 1.6rem) -1.6rem auto auto;
|
||||
}
|
||||
.orbitItem:nth-child(3) {
|
||||
inset: auto auto -1.6rem calc(50% - 1.6rem);
|
||||
}
|
||||
.orbitItem:nth-child(4) {
|
||||
inset: calc(50% - 1.6rem) auto auto -1.6rem;
|
||||
}
|
||||
|
||||
.studio {
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
.studioGrid {
|
||||
display: grid;
|
||||
grid-template-columns: 17rem minmax(0, 1fr);
|
||||
min-height: 40rem;
|
||||
}
|
||||
|
||||
.rail {
|
||||
padding: 1.25rem;
|
||||
border-right: 1px solid var(--mantine-color-default-border);
|
||||
background: color-mix(in srgb, var(--mantine-color-default) 40%, transparent);
|
||||
}
|
||||
|
||||
.railButton {
|
||||
width: 100%;
|
||||
min-height: 3.25rem;
|
||||
padding: 0.65rem 0.75rem;
|
||||
border-radius: var(--mantine-radius-md);
|
||||
color: var(--mantine-color-dimmed);
|
||||
transition:
|
||||
background-color 150ms ease,
|
||||
color 150ms ease,
|
||||
transform 150ms ease;
|
||||
}
|
||||
|
||||
.railButton[data-active="true"] {
|
||||
color: var(--mantine-color-text);
|
||||
background: var(--mantine-color-default-hover);
|
||||
}
|
||||
|
||||
.railButton:focus-visible {
|
||||
outline: 2px solid var(--mantine-primary-color-filled);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.content {
|
||||
min-width: 0;
|
||||
padding: clamp(1rem, 3vw, 2rem);
|
||||
}
|
||||
|
||||
.sectionCard {
|
||||
background: var(--studio-surface);
|
||||
border: 1px solid color-mix(in srgb, var(--mantine-color-default-border) 76%, transparent);
|
||||
}
|
||||
|
||||
.choiceGrid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: var(--mantine-spacing-sm);
|
||||
}
|
||||
|
||||
.choice {
|
||||
min-height: 9rem;
|
||||
text-align: left;
|
||||
border-radius: var(--mantine-radius-lg);
|
||||
border: 1px solid var(--mantine-color-default-border);
|
||||
background: var(--mantine-color-body);
|
||||
padding: var(--mantine-spacing-md);
|
||||
transition:
|
||||
border-color 150ms ease,
|
||||
background-color 150ms ease,
|
||||
transform 150ms ease;
|
||||
}
|
||||
|
||||
.choice[data-selected="true"] {
|
||||
border-color: var(--mantine-primary-color-filled);
|
||||
background: color-mix(in srgb, var(--mantine-primary-color-light) 70%, var(--mantine-color-body));
|
||||
}
|
||||
|
||||
.choice:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.choice:focus-visible {
|
||||
outline: 3px solid var(--mantine-primary-color-light-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.preview {
|
||||
margin: 0;
|
||||
aspect-ratio: 16 / 9;
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
padding: 0.6rem;
|
||||
overflow: hidden;
|
||||
border-radius: var(--mantine-radius-lg);
|
||||
background: color-mix(in srgb, var(--mantine-color-default) 66%, transparent);
|
||||
border: 1px solid var(--mantine-color-default-border);
|
||||
}
|
||||
|
||||
.previewLane {
|
||||
min-width: 0;
|
||||
border-radius: calc(var(--mantine-radius-lg) * 0.65);
|
||||
background: color-mix(in srgb, var(--mantine-color-body) 88%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--mantine-color-default-border) 70%, transparent);
|
||||
padding: 0.35rem;
|
||||
}
|
||||
|
||||
.previewTiles {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
grid-auto-rows: minmax(0.8rem, 1fr);
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.previewTile {
|
||||
border-radius: calc(var(--mantine-radius-lg) * 0.45);
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--mantine-primary-color-light),
|
||||
color-mix(in srgb, var(--mantine-color-orange-light) 60%, transparent)
|
||||
);
|
||||
border: 1px solid color-mix(in srgb, var(--mantine-primary-color-filled) 22%, transparent);
|
||||
}
|
||||
|
||||
.previewTile:nth-child(1) {
|
||||
grid-column: span 2;
|
||||
grid-row: span 2;
|
||||
}
|
||||
.previewTile:nth-child(2) {
|
||||
grid-column: span 2;
|
||||
}
|
||||
.previewTile:nth-child(3) {
|
||||
grid-column: span 1;
|
||||
}
|
||||
.previewTile:nth-child(4) {
|
||||
grid-column: span 1;
|
||||
}
|
||||
.previewTile:nth-child(5) {
|
||||
grid-column: span 4;
|
||||
}
|
||||
|
||||
.assistantStage {
|
||||
position: relative;
|
||||
min-height: 13rem;
|
||||
overflow: hidden;
|
||||
border-radius: var(--mantine-radius-lg);
|
||||
background: color-mix(in srgb, var(--mantine-primary-color-light) 44%, var(--mantine-color-body));
|
||||
}
|
||||
|
||||
.assistantGlow {
|
||||
position: absolute;
|
||||
inset: 50% auto auto 50%;
|
||||
width: 12rem;
|
||||
height: 12rem;
|
||||
margin: -6rem;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(
|
||||
circle,
|
||||
color-mix(in srgb, var(--mantine-primary-color-filled) 35%, transparent),
|
||||
transparent 68%
|
||||
);
|
||||
}
|
||||
|
||||
.stickyActions {
|
||||
position: sticky;
|
||||
z-index: 2;
|
||||
bottom: 0;
|
||||
margin: 1.5rem -2rem -2rem;
|
||||
padding: 1rem 2rem;
|
||||
background: color-mix(in srgb, var(--mantine-color-body) 92%, transparent);
|
||||
border-top: 1px solid var(--mantine-color-default-border);
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.applyError {
|
||||
margin-top: var(--mantine-spacing-lg);
|
||||
}
|
||||
|
||||
.nextCard {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background-color 150ms ease,
|
||||
transform 150ms ease;
|
||||
}
|
||||
|
||||
.nextCard:hover {
|
||||
background: var(--mantine-color-default-hover);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.nextCard:focus-visible {
|
||||
outline: 3px solid var(--mantine-primary-color-light-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.content :global(.mantine-Button-root),
|
||||
.content :global(.mantine-SegmentedControl-label),
|
||||
.page :global(.mantine-Input-input),
|
||||
.page :global(.mantine-Tabs-tab) {
|
||||
min-height: 2.75rem;
|
||||
}
|
||||
|
||||
.page :global(.mantine-Switch-body) {
|
||||
min-height: 2.75rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@media (max-width: 62em) {
|
||||
.hero {
|
||||
grid-template-columns: 1fr;
|
||||
padding-block: 3rem;
|
||||
}
|
||||
|
||||
.heroPanel {
|
||||
min-height: 22rem;
|
||||
}
|
||||
|
||||
.studioGrid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.rail {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--mantine-color-default-border);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.railList {
|
||||
min-width: max-content;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.railButton {
|
||||
width: auto;
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 48em) {
|
||||
.shell {
|
||||
width: min(100% - 1rem, 76rem);
|
||||
}
|
||||
|
||||
.heroTitle {
|
||||
font-size: clamp(2.35rem, 14vw, 4.5rem);
|
||||
}
|
||||
|
||||
.choiceGrid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.stickyActions {
|
||||
margin: 1rem -1rem -1rem;
|
||||
padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.primaryActions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.primaryActions > * {
|
||||
flex: 1 1 12rem;
|
||||
}
|
||||
|
||||
.content :global(.mantine-SegmentedControl-root) {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.content :global(.mantine-Tabs-list) {
|
||||
flex-wrap: nowrap;
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 30em) {
|
||||
.shell {
|
||||
width: calc(100% - 0.75rem);
|
||||
padding-top: 0.75rem;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.wordmark {
|
||||
width: 9.5rem;
|
||||
}
|
||||
|
||||
.hero {
|
||||
min-height: auto;
|
||||
gap: 2rem;
|
||||
padding-block: 2rem 3rem;
|
||||
}
|
||||
|
||||
.heroPanel {
|
||||
min-height: 19rem;
|
||||
}
|
||||
|
||||
.orbit {
|
||||
scale: 0.78;
|
||||
}
|
||||
|
||||
.rail {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.railButton {
|
||||
min-width: 8.5rem;
|
||||
}
|
||||
|
||||
.stickyActions {
|
||||
gap: var(--mantine-spacing-xs);
|
||||
}
|
||||
|
||||
.backAction {
|
||||
flex: 0 0 2.75rem;
|
||||
width: 2.75rem;
|
||||
padding-inline: 0;
|
||||
}
|
||||
|
||||
.backAction :global(.mantine-Button-section) {
|
||||
margin-inline: 0;
|
||||
}
|
||||
|
||||
.backAction :global(.mantine-Button-label) {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.primaryActions {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.fastAction {
|
||||
flex: 1.15 1 0;
|
||||
min-width: 0;
|
||||
padding-inline: 0.25rem;
|
||||
}
|
||||
|
||||
.primaryActions > :global(.mantine-Button-root):last-child {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
padding-inline: 0.25rem;
|
||||
}
|
||||
|
||||
.primaryActions > :global(.mantine-Button-root) {
|
||||
font-size: var(--mantine-font-size-sm);
|
||||
}
|
||||
|
||||
.content :global(.mantine-SegmentedControl-label) {
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
padding: 0.45rem 0.3rem;
|
||||
line-height: 1.15;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.sectionCard :global(.mantine-Group-root) {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.page {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
|
||||
.choice,
|
||||
.railButton,
|
||||
.nextCard {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.choice:hover {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.nextCard:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Button, Center, Loader, Paper, Stack, Text, Title } from "@mantine/core";
|
||||
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { Link } from "@homarr/ui";
|
||||
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import { AccountSetup } from "./account";
|
||||
import { Finish } from "./finish";
|
||||
import { SetupStudio } from "./setup-studio";
|
||||
import { Welcome } from "./welcome";
|
||||
|
||||
export const OnboardingStudio = (props: OnboardingStudioProps) => {
|
||||
const t = useScopedI18n("init.studio.claim");
|
||||
const tCommon = useScopedI18n("common.action");
|
||||
const [claimState, setClaimState] = useState<"checking" | "ready" | "locked" | "signIn" | "error">(
|
||||
props.environment.currentStep === "start" || props.environment.currentStep === "finish" ? "ready" : "checking",
|
||||
);
|
||||
const [claimError, setClaimError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.environment.currentStep === "start" || props.environment.currentStep === "finish") return;
|
||||
if (props.environment.canConfigurePrivileged) {
|
||||
setClaimState("ready");
|
||||
return;
|
||||
}
|
||||
if (
|
||||
props.environment.hasUsers ||
|
||||
(props.environment.externalAuthEnabled && props.environment.currentStep === "setup")
|
||||
) {
|
||||
setClaimState("signIn");
|
||||
return;
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
void fetch("/api/onboarding/claim", { method: "POST", signal: controller.signal })
|
||||
.then(async (response) => {
|
||||
if (response.ok) {
|
||||
setClaimState("ready");
|
||||
return;
|
||||
}
|
||||
const body = (await response.json().catch(() => null)) as { error?: string } | null;
|
||||
setClaimError(body?.error ?? t("errorDescription"));
|
||||
setClaimState(response.status === 423 ? "locked" : response.status === 403 ? "signIn" : "error");
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
if (controller.signal.aborted) return;
|
||||
setClaimError(error instanceof Error ? error.message : t("errorDescription"));
|
||||
setClaimState("error");
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, [
|
||||
props.environment.canConfigurePrivileged,
|
||||
props.environment.currentStep,
|
||||
props.environment.externalAuthEnabled,
|
||||
props.environment.hasUsers,
|
||||
t,
|
||||
]);
|
||||
|
||||
if (claimState !== "ready") {
|
||||
const signIn = claimState === "signIn";
|
||||
return (
|
||||
<Center mih="100dvh" p="md">
|
||||
<Paper withBorder radius="lg" p="xl" maw="32rem" w="100%">
|
||||
<Stack align="center">
|
||||
{claimState === "checking" ? <Loader aria-label={t("checking")} /> : null}
|
||||
<Title order={1} size="h2" ta="center">
|
||||
{claimState === "checking"
|
||||
? t("checkingTitle")
|
||||
: signIn
|
||||
? t("signInTitle")
|
||||
: claimState === "locked"
|
||||
? t("lockedTitle")
|
||||
: t("errorTitle")}
|
||||
</Title>
|
||||
<Text c="dimmed" ta="center">
|
||||
{signIn
|
||||
? t("signInDescription")
|
||||
: claimState === "locked"
|
||||
? t("lockedDescription")
|
||||
: claimState === "checking"
|
||||
? t("checking")
|
||||
: (claimError ?? t("errorDescription"))}
|
||||
</Text>
|
||||
{signIn ? (
|
||||
<Button component={Link} href="/auth/login?callbackUrl=%2Finit">
|
||||
{t("signIn")}
|
||||
</Button>
|
||||
) : claimState === "locked" ? (
|
||||
<Button onClick={() => window.location.reload()}>{tCommon("tryAgain")}</Button>
|
||||
) : claimState === "error" ? (
|
||||
<Stack align="center">
|
||||
<Alert color="red" role="alert">
|
||||
{claimError ?? t("errorDescription")}
|
||||
</Alert>
|
||||
<Button onClick={() => window.location.reload()}>{tCommon("tryAgain")}</Button>
|
||||
</Stack>
|
||||
) : null}
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Center>
|
||||
);
|
||||
}
|
||||
|
||||
switch (props.environment.currentStep) {
|
||||
case "start":
|
||||
return <Welcome {...props} />;
|
||||
case "user":
|
||||
case "group":
|
||||
return <AccountSetup {...props} />;
|
||||
case "setup":
|
||||
return <SetupStudio {...props} />;
|
||||
case "finish":
|
||||
return <Finish {...props} />;
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,25 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import type { OnboardingStep } from "@homarr/definitions";
|
||||
|
||||
export interface OnboardingEnvironment {
|
||||
currentStep: OnboardingStep;
|
||||
databaseDriver: "sqlite" | "mysql" | "postgresql";
|
||||
credentialsEnabled: boolean;
|
||||
externalAuthEnabled: boolean;
|
||||
dockerConfigured: boolean;
|
||||
kubernetesConfigured: boolean;
|
||||
workshopEnabled: boolean;
|
||||
workshopApiUrl: string;
|
||||
workshopUrl: string;
|
||||
mcpEndpoint: string;
|
||||
canConfigurePrivileged: boolean;
|
||||
hasUsers: boolean;
|
||||
initialBoard: { id: string; name: string } | null;
|
||||
availableBoards: { id: string; name: string }[];
|
||||
}
|
||||
|
||||
export interface OnboardingStudioProps {
|
||||
environment: OnboardingEnvironment;
|
||||
sqliteRestore?: ReactNode;
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Alert, Badge, Button, Group, Paper, Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||
import { IconArrowRight, IconDatabaseImport, IconLayoutDashboard, IconSparkles } from "@tabler/icons-react";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { revalidatePathActionAsync } from "@homarr/common/client";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
export const Welcome = ({ environment, sqliteRestore }: OnboardingStudioProps) => {
|
||||
const t = useScopedI18n("init.studio.welcome");
|
||||
const reduceMotion = useReducedMotion();
|
||||
const [showRestore, setShowRestore] = useState(false);
|
||||
const [claimPending, setClaimPending] = useState(false);
|
||||
const [claimError, setClaimError] = useState<string | null>(null);
|
||||
const start = clientApi.onboard.nextStep.useMutation({
|
||||
async onSuccess() {
|
||||
await revalidatePathActionAsync("/init");
|
||||
},
|
||||
});
|
||||
|
||||
const claimOnboardingAsync = async () => {
|
||||
setClaimPending(true);
|
||||
setClaimError(null);
|
||||
try {
|
||||
const response = await fetch("/api/onboarding/claim", { method: "POST" });
|
||||
if (!response.ok) {
|
||||
const body = (await response.json().catch(() => null)) as { error?: string } | null;
|
||||
throw new Error(body?.error ?? t("errorTitle"));
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
setClaimError(error instanceof Error ? error.message : t("errorTitle"));
|
||||
return false;
|
||||
} finally {
|
||||
setClaimPending(false);
|
||||
}
|
||||
};
|
||||
|
||||
const startOnboardingAsync = async () => {
|
||||
if (await claimOnboardingAsync()) await start.mutateAsync();
|
||||
};
|
||||
|
||||
const toggleRestoreAsync = async () => {
|
||||
if (showRestore) {
|
||||
setShowRestore(false);
|
||||
return;
|
||||
}
|
||||
if (await claimOnboardingAsync()) setShowRestore(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<main className={classes.page}>
|
||||
<div className={classes.shell}>
|
||||
<Group className={classes.topbar} justify="space-between">
|
||||
<motion.img
|
||||
src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/homarr-wordmark-light.svg"
|
||||
alt="Homarr"
|
||||
className={classes.wordmark}
|
||||
initial={reduceMotion ? false : { opacity: 0, y: -10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.45 }}
|
||||
/>
|
||||
<Badge variant="light" size="lg">
|
||||
{t("badge")}
|
||||
</Badge>
|
||||
</Group>
|
||||
|
||||
<section className={classes.hero} aria-labelledby="onboarding-welcome-title">
|
||||
<Stack gap="xl" align="flex-start">
|
||||
<Stack gap="md">
|
||||
<Text c="dimmed" fw={650} tt="uppercase" fz="xs" lts="0.14em">
|
||||
{t("eyebrow")}
|
||||
</Text>
|
||||
<Title id="onboarding-welcome-title" className={classes.heroTitle}>
|
||||
{t("title")}
|
||||
</Title>
|
||||
<Text size="lg" c="dimmed" maw="38rem">
|
||||
{t("description")}
|
||||
</Text>
|
||||
</Stack>
|
||||
|
||||
<Group className={classes.primaryActions} gap="sm">
|
||||
<Button
|
||||
size="lg"
|
||||
rightSection={<IconArrowRight size={18} />}
|
||||
loading={start.isPending || claimPending}
|
||||
onClick={() => void startOnboardingAsync()}
|
||||
>
|
||||
{t("start")}
|
||||
</Button>
|
||||
{environment.databaseDriver === "sqlite" && sqliteRestore ? (
|
||||
<Button
|
||||
size="lg"
|
||||
variant="default"
|
||||
leftSection={<IconDatabaseImport size={18} />}
|
||||
onClick={() => void toggleRestoreAsync()}
|
||||
loading={claimPending}
|
||||
aria-expanded={showRestore}
|
||||
aria-controls="sqlite-restore-flow"
|
||||
>
|
||||
{t("restore")}
|
||||
</Button>
|
||||
) : null}
|
||||
</Group>
|
||||
|
||||
{showRestore && sqliteRestore ? (
|
||||
<Paper id="sqlite-restore-flow" withBorder p="lg" radius="lg" w="100%" maw="38rem">
|
||||
<Stack>
|
||||
<Group gap="xs">
|
||||
<ThemeIcon variant="light" color="orange">
|
||||
<IconDatabaseImport size={18} />
|
||||
</ThemeIcon>
|
||||
<Text fw={650}>{t("restoreTitle")}</Text>
|
||||
</Group>
|
||||
<Text size="sm" c="dimmed">
|
||||
{t("restoreDescription")}
|
||||
</Text>
|
||||
{sqliteRestore}
|
||||
</Stack>
|
||||
</Paper>
|
||||
) : null}
|
||||
|
||||
{claimError || start.error ? (
|
||||
<Alert color="red" title={t("errorTitle")} maw="38rem">
|
||||
{claimError ?? start.error?.message}
|
||||
</Alert>
|
||||
) : null}
|
||||
</Stack>
|
||||
|
||||
<motion.div
|
||||
initial={reduceMotion ? false : { opacity: 0, scale: 0.96, y: 24 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
transition={{ duration: 0.55, delay: 0.08 }}
|
||||
>
|
||||
<Paper className={classes.heroPanel} radius="lg" p="xl">
|
||||
<div className={classes.orbit} aria-hidden>
|
||||
{[IconLayoutDashboard, IconSparkles, IconDatabaseImport, IconLayoutDashboard].map((Icon, index) => (
|
||||
<motion.div
|
||||
key={index}
|
||||
className={classes.orbitItem}
|
||||
animate={reduceMotion ? undefined : { y: [0, index % 2 === 0 ? -6 : 6, 0] }}
|
||||
transition={{ duration: 3.4 + index * 0.35, repeat: Infinity, ease: "easeInOut" }}
|
||||
>
|
||||
<Icon size={22} />
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
<Stack h="100%" justify="space-between" pos="relative">
|
||||
<Badge variant="dot" color="green">
|
||||
{t("ready")}
|
||||
</Badge>
|
||||
<Stack gap={4} align="center">
|
||||
<ThemeIcon size={72} radius="xl" variant="light">
|
||||
<IconLayoutDashboard size={34} />
|
||||
</ThemeIcon>
|
||||
<Text fw={700} size="lg">
|
||||
{t("panelTitle")}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed" ta="center" maw="19rem">
|
||||
{t("panelDescription")}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Group gap="xs" justify="center">
|
||||
<Badge variant="light">{t("chipDiscover")}</Badge>
|
||||
<Badge variant="light">{t("chipConnect")}</Badge>
|
||||
<Badge variant="light">{t("chipBuild")}</Badge>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</motion.div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user