feat: enhance onboarding
This commit is contained in:
1 parent
e5d6b6be87
commit
2283ec7113
23 files changed
+415
-170
No files matched your search
@@ -17,6 +17,7 @@ import { groupCreateSchema } from "@homarr/validation/group";
|
||||
import { userInitSchema } from "@homarr/validation/user";
|
||||
|
||||
import { didCredentialsSignInFail } from "./account-recovery";
|
||||
import { OnboardingBackdrop } from "./onboarding-backdrop";
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
@@ -30,6 +31,7 @@ const AccountShell = ({
|
||||
children: React.ReactNode;
|
||||
}) => (
|
||||
<main className={classes.page}>
|
||||
<OnboardingBackdrop />
|
||||
<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">
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import type { MouseEvent as ReactMouseEvent } from "react";
|
||||
import { Button, Group, Paper, SimpleGrid, Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||
import { IconArrowRight, IconBook2, IconSparkles, IconTool } from "@tabler/icons-react";
|
||||
import confetti from "canvas-confetti";
|
||||
|
||||
import { createDocumentationLink } from "@homarr/definitions";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { Link } from "@homarr/ui";
|
||||
|
||||
import { OnboardingBackdrop } from "./onboarding-backdrop";
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
@@ -14,9 +17,36 @@ export const Finish = ({ environment }: OnboardingStudioProps) => {
|
||||
const t = useScopedI18n("init.studio.finish");
|
||||
const boardHref = `/boards/${encodeURIComponent(environment.initialBoard?.name ?? "dashboard")}`;
|
||||
const destination = environment.canConfigurePrivileged ? boardHref : "/auth/login?callbackUrl=%2Finit";
|
||||
const openBoard = (event: ReactMouseEvent<HTMLAnchorElement>) => {
|
||||
if (
|
||||
event.button !== 0 ||
|
||||
event.metaKey ||
|
||||
event.ctrlKey ||
|
||||
event.shiftKey ||
|
||||
event.altKey ||
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
const button = event.currentTarget.getBoundingClientRect();
|
||||
void confetti({
|
||||
particleCount: 120,
|
||||
spread: 75,
|
||||
startVelocity: 45,
|
||||
origin: {
|
||||
x: (button.left + button.width / 2) / window.innerWidth,
|
||||
y: (button.top + button.height / 2) / window.innerHeight,
|
||||
},
|
||||
disableForReducedMotion: true,
|
||||
});
|
||||
window.setTimeout(() => window.location.assign(destination), 450);
|
||||
};
|
||||
|
||||
return (
|
||||
<main className={classes.page}>
|
||||
<OnboardingBackdrop />
|
||||
<div className={classes.shell}>
|
||||
<Stack mih="calc(100dvh - 6rem)" justify="center" align="center">
|
||||
<div style={{ width: "100%", maxWidth: "52rem" }}>
|
||||
@@ -33,7 +63,13 @@ export const Finish = ({ environment }: OnboardingStudioProps) => {
|
||||
{t("description")}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Button component={Link} href={destination} size="lg" rightSection={<IconArrowRight size={18} />}>
|
||||
<Button
|
||||
component={Link}
|
||||
href={destination}
|
||||
size="lg"
|
||||
rightSection={<IconArrowRight size={18} />}
|
||||
onClick={openBoard}
|
||||
>
|
||||
{t("openBoard")}
|
||||
</Button>
|
||||
<SimpleGrid cols={{ base: 1, sm: 3 }} w="100%">
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { IntegrationMarquee } from "@homarr/ui";
|
||||
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
|
||||
export const OnboardingBackdrop = () => (
|
||||
<div className={classes.marqueeBackdrop} aria-hidden>
|
||||
<div className={`${classes.marqueeRail} ${classes.marqueeRailLeft}`}>
|
||||
<IntegrationMarquee />
|
||||
</div>
|
||||
<div className={`${classes.marqueeRail} ${classes.marqueeRailRight}`}>
|
||||
<IntegrationMarquee />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -19,22 +19,44 @@
|
||||
var(--mantine-color-body);
|
||||
}
|
||||
|
||||
.page::before {
|
||||
content: "";
|
||||
.marqueeBackdrop {
|
||||
position: fixed;
|
||||
inset: -2rem;
|
||||
z-index: 0;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
opacity: 0.28;
|
||||
background-image:
|
||||
linear-gradient(color-mix(in srgb, var(--mantine-color-dimmed) 28%, transparent) 1px, transparent 1px),
|
||||
linear-gradient(90deg, color-mix(in srgb, var(--mantine-color-dimmed) 28%, transparent) 1px, transparent 1px);
|
||||
background-size: 32px 32px;
|
||||
filter: blur(0.35px);
|
||||
mask-image: radial-gradient(ellipse 66% 86% at center, transparent 22%, black 88%);
|
||||
opacity: 0.42;
|
||||
filter: blur(1.25px) saturate(0.92);
|
||||
mask-image: linear-gradient(to right, black 0%, black 18%, transparent 40%, transparent 60%, black 82%, black 100%);
|
||||
}
|
||||
|
||||
.marqueeRail {
|
||||
position: absolute;
|
||||
top: -14rem;
|
||||
bottom: -14rem;
|
||||
width: clamp(22rem, 26vw, 32rem);
|
||||
mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
|
||||
}
|
||||
|
||||
.marqueeRail > * {
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.marqueeRailLeft {
|
||||
left: -7rem;
|
||||
--integration-marquee-accent: var(--studio-glow-color);
|
||||
}
|
||||
|
||||
.marqueeRailRight {
|
||||
right: -7rem;
|
||||
top: -22rem;
|
||||
--integration-marquee-accent: var(--studio-secondary-glow-color);
|
||||
}
|
||||
|
||||
.shell {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: min(100% - 2rem, 76rem);
|
||||
margin-inline: auto;
|
||||
padding-block: clamp(1rem, 3vw, 2.5rem) calc(6rem + env(safe-area-inset-bottom));
|
||||
@@ -56,7 +78,12 @@
|
||||
max-width: min(70vw, 28rem);
|
||||
}
|
||||
|
||||
:global([data-mantine-color-scheme="light"]) .wordmark {
|
||||
.wordmark.welcomeWordmark {
|
||||
height: clamp(8rem, 20vw, 12rem);
|
||||
max-width: min(92vw, 42rem);
|
||||
}
|
||||
|
||||
:global([data-mantine-color-scheme="light"]) .wordmark:not([data-recolored="true"]) {
|
||||
filter: brightness(0);
|
||||
}
|
||||
|
||||
@@ -304,6 +331,23 @@
|
||||
}
|
||||
|
||||
@media (max-width: 48em) {
|
||||
.marqueeBackdrop {
|
||||
opacity: 0.24;
|
||||
mask-image: linear-gradient(to right, black, transparent 42%, transparent 58%, black);
|
||||
}
|
||||
|
||||
.marqueeRail {
|
||||
width: 17rem;
|
||||
}
|
||||
|
||||
.marqueeRailLeft {
|
||||
left: -8rem;
|
||||
}
|
||||
|
||||
.marqueeRailRight {
|
||||
right: -8rem;
|
||||
}
|
||||
|
||||
.shell {
|
||||
width: min(100% - 1rem, 76rem);
|
||||
}
|
||||
@@ -371,6 +415,10 @@
|
||||
height: 3rem;
|
||||
}
|
||||
|
||||
.wordmark.welcomeWordmark {
|
||||
height: clamp(7rem, 34vw, 10rem);
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding-block: 2rem 3rem;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,66 @@
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
"use client";
|
||||
|
||||
export const OnboardingWordmark = () => (
|
||||
<img
|
||||
src="/logo/homarr-wordmark-light.svg"
|
||||
alt="Homarr"
|
||||
className={`${classes.wordmark} ${classes.onboardingWordmark}`}
|
||||
/>
|
||||
);
|
||||
import type { MouseEvent as ReactMouseEvent } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useComputedColorScheme } from "@mantine/core";
|
||||
import confetti from "canvas-confetti";
|
||||
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
import { recolorWordmark } from "./wordmark-colors";
|
||||
|
||||
interface OnboardingWordmarkProps {
|
||||
primaryColor?: string;
|
||||
secondaryColor?: string;
|
||||
large?: boolean;
|
||||
}
|
||||
|
||||
const wordmarkUrl = "/logo/homarr-wordmark-light.svg";
|
||||
|
||||
export const OnboardingWordmark = ({ primaryColor, secondaryColor, large = false }: OnboardingWordmarkProps) => {
|
||||
const [source, setSource] = useState<string | null>(null);
|
||||
const colorScheme = useComputedColorScheme("light");
|
||||
const recolored = Boolean(source && primaryColor && secondaryColor);
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
void fetch(wordmarkUrl, { signal: controller.signal })
|
||||
.then((response) => (response.ok ? response.text() : null))
|
||||
.then((svg) => {
|
||||
if (svg) setSource(svg);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
return () => controller.abort();
|
||||
}, []);
|
||||
|
||||
const src = useMemo(() => {
|
||||
if (!source || !primaryColor || !secondaryColor) return wordmarkUrl;
|
||||
return `data:image/svg+xml,${encodeURIComponent(
|
||||
recolorWordmark(source, primaryColor, secondaryColor, colorScheme === "light" ? "#1A1B1E" : undefined),
|
||||
)}`;
|
||||
}, [colorScheme, primaryColor, secondaryColor, source]);
|
||||
|
||||
const celebrate = (event: ReactMouseEvent<HTMLImageElement>) => {
|
||||
const logo = event.currentTarget.getBoundingClientRect();
|
||||
void confetti({
|
||||
particleCount: 60,
|
||||
spread: 65,
|
||||
startVelocity: 32,
|
||||
origin: {
|
||||
x: (logo.left + logo.width / 2) / window.innerWidth,
|
||||
y: (logo.top + logo.height / 2) / window.innerHeight,
|
||||
},
|
||||
colors: primaryColor && secondaryColor ? [primaryColor, secondaryColor] : undefined,
|
||||
disableForReducedMotion: true,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<img
|
||||
src={src}
|
||||
alt="Homarr"
|
||||
data-recolored={recolored || undefined}
|
||||
className={`${classes.wordmark} ${classes.onboardingWordmark} ${large ? classes.welcomeWordmark : ""}`}
|
||||
onMouseEnter={celebrate}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -64,6 +64,7 @@ import {
|
||||
IconServer,
|
||||
IconSparkles,
|
||||
IconSunMoon,
|
||||
IconX,
|
||||
} from "@tabler/icons-react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
@@ -95,6 +96,7 @@ import { BoardColorInput, ColorSchemeCombobox, IntegrationAvatar, LanguageCombob
|
||||
import { IntegrationMultiSelectGrid } from "@homarr/ui/integration-select-grid";
|
||||
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import { OnboardingBackdrop } from "./onboarding-backdrop";
|
||||
import { OnboardingWordmark } from "./onboarding-wordmark";
|
||||
import {
|
||||
isHttpUrl,
|
||||
@@ -217,6 +219,7 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
|
||||
const [boardName, setBoardName] = useState(initialBoard?.name ?? "dashboard");
|
||||
const [primaryColor, setPrimaryColor] = useState("#fa5252");
|
||||
const [secondaryColor, setSecondaryColor] = useState("#fd7e14");
|
||||
const [boardColorsDirty, setBoardColorsDirty] = useState(false);
|
||||
const [itemRadius, setItemRadius] = useState<MantineSize>("lg");
|
||||
const [columnCount, setColumnCount] = useState(10);
|
||||
const [leftSidebar, setLeftSidebar] = useState(false);
|
||||
@@ -425,6 +428,7 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
|
||||
|
||||
setApplyMessage(t("review.progress.applying"));
|
||||
setApplyProgress(20);
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
const selectedSourceIds = new Set(draftsToApply.flatMap((draft) => (draft.sourceId ? [draft.sourceId] : [])));
|
||||
const completion = await complete.mutateAsync({
|
||||
server: {
|
||||
@@ -557,9 +561,15 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
|
||||
selectedBoardId,
|
||||
setSelectedBoardId,
|
||||
primaryColor,
|
||||
setPrimaryColor,
|
||||
setPrimaryColor: (value) => {
|
||||
setPrimaryColor(value);
|
||||
setBoardColorsDirty(true);
|
||||
},
|
||||
secondaryColor,
|
||||
setSecondaryColor,
|
||||
setSecondaryColor: (value) => {
|
||||
setSecondaryColor(value);
|
||||
setBoardColorsDirty(true);
|
||||
},
|
||||
itemRadius,
|
||||
setItemRadius,
|
||||
columnCount,
|
||||
@@ -595,9 +605,13 @@ export const SetupStudio = ({ environment, assistantConfiguration }: OnboardingS
|
||||
} as CSSProperties
|
||||
}
|
||||
>
|
||||
<OnboardingBackdrop />
|
||||
<div className={classes.shell}>
|
||||
<Group className={classes.topbar} mb="lg">
|
||||
<OnboardingWordmark />
|
||||
<OnboardingWordmark
|
||||
primaryColor={boardColorsDirty ? primaryColor : undefined}
|
||||
secondaryColor={boardColorsDirty ? secondaryColor : undefined}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Paper className={classes.studio} radius="lg">
|
||||
@@ -1238,11 +1252,20 @@ const IntegrationEditor = ({
|
||||
testConnection.reset();
|
||||
update(patch);
|
||||
};
|
||||
const testFailed = testConnection.data?.success === false || testConnection.isError;
|
||||
const testSucceeded = testConnection.data?.success === true;
|
||||
const status = needsConfiguration
|
||||
? { color: "orange", label: t("needsConfiguration"), icon: <IconAlertCircle size={14} /> }
|
||||
: testSucceeded
|
||||
? { color: "green", label: t("tested"), icon: <IconCheck size={14} /> }
|
||||
: testFailed
|
||||
? { color: "red", label: t("testFailed"), icon: <IconX size={14} /> }
|
||||
: { color: "gray", label: t("testConnection"), icon: <IconPlugConnected size={14} /> };
|
||||
return (
|
||||
<Accordion.Item value={draft.id}>
|
||||
<Accordion.Control
|
||||
icon={<IntegrationAvatar kind={draft.kind} size="sm" />}
|
||||
aria-label={needsConfiguration ? `${draft.name}: ${t("needsConfiguration")}` : draft.name}
|
||||
aria-label={`${draft.name}: ${status.label}`}
|
||||
>
|
||||
<Group justify="space-between" wrap="nowrap" pr="sm">
|
||||
<Stack gap={0} miw={0}>
|
||||
@@ -1255,13 +1278,13 @@ const IntegrationEditor = ({
|
||||
</Stack>
|
||||
<ThemeIcon
|
||||
className={classes.integrationStatus}
|
||||
color={needsConfiguration ? "orange" : "green"}
|
||||
color={status.color}
|
||||
variant="light"
|
||||
size="sm"
|
||||
radius="xl"
|
||||
aria-label={t(needsConfiguration ? "needsConfiguration" : "configured")}
|
||||
aria-label={status.label}
|
||||
>
|
||||
{needsConfiguration ? <IconAlertCircle size={14} /> : <IconCheck size={14} />}
|
||||
{status.icon}
|
||||
</ThemeIcon>
|
||||
</Group>
|
||||
</Accordion.Control>
|
||||
@@ -1337,10 +1360,16 @@ const IntegrationEditor = ({
|
||||
size="xs"
|
||||
disabled={needsConfiguration}
|
||||
loading={testConnection.isPending}
|
||||
color={
|
||||
testConnection.data?.success ? "green" : testConnection.data?.success === false ? "red" : undefined
|
||||
color={testSucceeded ? "green" : testFailed ? "red" : undefined}
|
||||
leftSection={
|
||||
testSucceeded ? (
|
||||
<IconCheck size={14} />
|
||||
) : testFailed ? (
|
||||
<IconX size={14} />
|
||||
) : (
|
||||
<IconPlugConnected size={14} />
|
||||
)
|
||||
}
|
||||
leftSection={testConnection.data?.success ? <IconCheck size={14} /> : <IconPlugConnected size={14} />}
|
||||
onClick={() =>
|
||||
testConnection.mutate({
|
||||
sourceId: draft.sourceId ?? draft.id,
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ReactNode } from "react";
|
||||
import type { OnboardingStep } from "@homarr/definitions";
|
||||
|
||||
export interface OnboardingEnvironment {
|
||||
version: string;
|
||||
currentStep: OnboardingStep;
|
||||
databaseDriver: "sqlite" | "mysql" | "postgresql";
|
||||
externalAuthEnabled: boolean;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Alert, Badge, Button, Group, Paper, Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||
import { Alert, Button, Group, Paper, Stack, Text, ThemeIcon, Title } from "@mantine/core";
|
||||
import { IconArrowRight, IconDatabaseImport } from "@tabler/icons-react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
@@ -9,6 +9,7 @@ import { revalidatePathActionAsync } from "@homarr/common/client";
|
||||
import { showErrorNotification } from "@homarr/notifications";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
|
||||
import { OnboardingBackdrop } from "./onboarding-backdrop";
|
||||
import { OnboardingWordmark } from "./onboarding-wordmark";
|
||||
import type { OnboardingStudioProps } from "./types";
|
||||
import classes from "./onboarding-studio.module.css";
|
||||
@@ -75,20 +76,18 @@ export const Welcome = ({ environment, sqliteRestore }: OnboardingStudioProps) =
|
||||
|
||||
return (
|
||||
<main className={classes.page}>
|
||||
<OnboardingBackdrop />
|
||||
<div className={classes.shell}>
|
||||
<Group className={classes.topbar} justify="space-between">
|
||||
<OnboardingWordmark />
|
||||
<Badge variant="light" size="lg">
|
||||
{t("badge")}
|
||||
</Badge>
|
||||
</Group>
|
||||
|
||||
<section className={classes.hero} aria-labelledby="onboarding-welcome-title">
|
||||
<Stack gap="xl" align="center">
|
||||
<OnboardingWordmark large />
|
||||
<Stack gap="sm" align="center">
|
||||
<Title id="onboarding-welcome-title" className={classes.heroTitle} ta="center">
|
||||
{t("title")}
|
||||
</Title>
|
||||
<Text fw={600} size="lg" ta="center">
|
||||
{t("version", { version: environment.version })}
|
||||
</Text>
|
||||
<Text size="lg" c="dimmed" maw="38rem" ta="center">
|
||||
{t("description")}
|
||||
</Text>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { recolorWordmark } from "./wordmark-colors";
|
||||
|
||||
describe("recolorWordmark", () => {
|
||||
it("recolors red fills while preserving white details", () => {
|
||||
const svg = '<path fill="#FA5252"/><path fill="#FDD7D7"/><path fill="#FEFDFD"/>';
|
||||
|
||||
expect(recolorWordmark(svg, "#228BE6", "#15AABF", "#1A1B1E")).toBe(
|
||||
'<path fill="#228BE6"/><path fill="#15AABF"/><path fill="#1A1B1E"/>',
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves the source unchanged for incomplete colors", () => {
|
||||
const svg = '<path fill="#FA5252"/>';
|
||||
expect(recolorWordmark(svg, "#228BE6", "")).toBe(svg);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
const hexColorPattern = /^#[0-9a-f]{6}$/iu;
|
||||
|
||||
export const recolorWordmark = (
|
||||
svg: string,
|
||||
primaryColor: string,
|
||||
secondaryColor: string,
|
||||
foregroundColor?: string,
|
||||
) => {
|
||||
if (!hexColorPattern.test(primaryColor) || !hexColorPattern.test(secondaryColor)) return svg;
|
||||
|
||||
return svg.replace(/fill="(#[0-9a-f]{6})"/giu, (fill, color: string) => {
|
||||
const red = Number.parseInt(color.slice(1, 3), 16);
|
||||
const green = Number.parseInt(color.slice(3, 5), 16);
|
||||
const blue = Number.parseInt(color.slice(5, 7), 16);
|
||||
const redDifference = red - Math.max(green, blue);
|
||||
|
||||
if (foregroundColor && hexColorPattern.test(foregroundColor) && Math.min(red, green, blue) >= 235) {
|
||||
return `fill="${foregroundColor}"`;
|
||||
}
|
||||
if (redDifference < 15) return fill;
|
||||
return `fill="${Math.min(green, blue) >= 150 ? secondaryColor : primaryColor}"`;
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user