Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♻️ Migrate control panel settings pages to Field components (#2912)

Luke Vella6905a9394269
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 8f36d0c20..d00f62adf 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -387,6 +387,7 @@
"leaveSpaceSettingHint": "Remove yourself from this space and lose access to its polls.",
"leftSpaceSuccess": "You have left the space",
"license": "License",
+ "licenseDetails": "License details",
"licenseeEmail": "Licensee email",
"licenseeName": "Licensee name",
"licenseKey": "License key",
diff --git a/apps/web/src/app/[locale]/control-panel/branding/page.tsx b/apps/web/src/app/[locale]/control-panel/branding/page.tsx
index ba25edfc8..9274e408c 100644
--- a/apps/web/src/app/[locale]/control-panel/branding/page.tsx
+++ b/apps/web/src/app/[locale]/control-panel/branding/page.tsx
@@ -1,4 +1,11 @@
import { Alert, AlertDescription } from "@rallly/ui/alert";
+import {
+ Field,
+ FieldContent,
+ FieldGroup,
+ FieldLabel,
+ FieldTitle,
+} from "@rallly/ui/field";
import { Input } from "@rallly/ui/input";
import { Switch } from "@rallly/ui/switch";
import { CodeIcon, GemIcon } from "lucide-react";
@@ -155,19 +162,30 @@ export default async function BrandingPage() {
</PageSectionDescription>
</PageSectionHeader>
<PageSectionContent>
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="appName"
- defaults="App name"
- />
- </div>
- <Input value={appName} readOnly />
- <SetEnvironmentVariableAlert variable="APP_NAME" />
- </div>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldLabel htmlFor="app-name">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="appName"
+ defaults="App name"
+ />
+ </FieldLabel>
+ </FieldContent>
+ <Input
+ id="app-name"
+ className="w-56"
+ value={appName}
+ readOnly
+ />
+ </Field>
+ <SetEnvironmentVariableAlert variable="APP_NAME" />
+ </Field>
+ </FieldGroup>
</PageSectionContent>
</PageSection>
<PageSection variant="card">
@@ -192,50 +210,58 @@ export default async function BrandingPage() {
</PageSectionDescription>
</PageSectionHeader>
<PageSectionContent>
- <div className="space-y-6">
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="primaryColor"
- defaults="Primary color"
- />
- </div>
- <div className="flex items-center gap-2">
- <div
- className="size-8 rounded border"
- style={{ backgroundColor: primaryColorLight }}
- />
- <span className="font-mono text-sm">
- {primaryColorLight}
- </span>
- </div>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="primaryColor"
+ defaults="Primary color"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center gap-2">
+ <div
+ className="size-8 rounded border"
+ style={{ backgroundColor: primaryColorLight }}
+ />
+ <span className="font-mono text-sm">
+ {primaryColorLight}
+ </span>
+ </div>
+ </Field>
<SetEnvironmentVariableAlert variable="PRIMARY_COLOR" />
- </div>
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="primaryColorDark"
- defaults="Primary color (dark mode)"
- />
- </div>
- <div className="flex items-center gap-2">
- <div
- className="size-8 rounded border"
- style={{ backgroundColor: primaryColorDark }}
- />
- <span className="font-mono text-sm">
- {primaryColorDark}
- </span>
- </div>
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="primaryColorDark"
+ defaults="Primary color (dark mode)"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center gap-2">
+ <div
+ className="size-8 rounded border"
+ style={{ backgroundColor: primaryColorDark }}
+ />
+ <span className="font-mono text-sm">
+ {primaryColorDark}
+ </span>
+ </div>
+ </Field>
<SetEnvironmentVariableAlert variable="PRIMARY_COLOR_DARK" />
- </div>
- </div>
+ </Field>
+ </FieldGroup>
</PageSectionContent>
</PageSection>
<PageSection variant="card">
@@ -260,80 +286,92 @@ export default async function BrandingPage() {
</PageSectionDescription>
</PageSectionHeader>
<PageSectionContent>
- <div className="space-y-6">
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logo"
- defaults="Logo"
- />
- </div>
- <div className="flex items-center gap-4">
- <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-white">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoUrlLight}
- alt={t("logo", { ns: "app", defaultValue: "Logo" })}
- className="max-h-full max-w-full object-contain p-2"
- />
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logo"
+ defaults="Logo"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-white">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoUrlLight}
+ alt={t("logo", { ns: "app", defaultValue: "Logo" })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
</div>
- </div>
+ </Field>
<SetEnvironmentVariableAlert variable="LOGO_URL" />
- </div>
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logoDark"
- defaults="Logo (dark mode)"
- />
- </div>
- <div className="flex items-center gap-4">
- <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-gray-900">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoUrlDark}
- alt={t("logoDark", {
- ns: "app",
- defaultValue: "Logo (dark mode)",
- })}
- className="max-h-full max-w-full object-contain p-2"
- />
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logoDark"
+ defaults="Logo (dark mode)"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-gray-900">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoUrlDark}
+ alt={t("logoDark", {
+ ns: "app",
+ defaultValue: "Logo (dark mode)",
+ })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
</div>
- </div>
+ </Field>
<SetEnvironmentVariableAlert variable="LOGO_URL_DARK" />
- </div>
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logoIcon"
- defaults="Logo icon"
- />
- </div>
- <div className="flex items-center gap-4">
- <div className="flex size-16 items-center justify-center overflow-hidden rounded border bg-white">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoIconUrl}
- alt={t("logoIcon", {
- ns: "app",
- defaultValue: "Logo icon",
- })}
- className="max-h-full max-w-full object-contain p-2"
- />
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logoIcon"
+ defaults="Logo icon"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex size-16 items-center justify-center overflow-hidden rounded border bg-white">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoIconUrl}
+ alt={t("logoIcon", {
+ ns: "app",
+ defaultValue: "Logo icon",
+ })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
</div>
- </div>
+ </Field>
<SetEnvironmentVariableAlert variable="LOGO_ICON_URL" />
- </div>
- </div>
+ </Field>
+ </FieldGroup>
</PageSectionContent>
</PageSection>
<PageSection variant="card">
@@ -358,21 +396,29 @@ export default async function BrandingPage() {
</PageSectionDescription>
</PageSectionHeader>
<PageSectionContent>
- <div className="space-y-2">
- <div className="text-muted-foreground text-xs">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="hideAttribution"
- defaults="Hide attribution"
- />
- </div>
- <div className="flex items-center gap-2">
- <Switch checked={hideAttribution} disabled />
- </div>
- <SetEnvironmentVariableAlert variable="HIDE_ATTRIBUTION" />
- </div>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldLabel htmlFor="hide-attribution">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="hideAttribution"
+ defaults="Hide attribution"
+ />
+ </FieldLabel>
+ </FieldContent>
+ <Switch
+ id="hide-attribution"
+ checked={hideAttribution}
+ disabled
+ />
+ </Field>
+ <SetEnvironmentVariableAlert variable="HIDE_ATTRIBUTION" />
+ </Field>
+ </FieldGroup>
</PageSectionContent>
</PageSection>
</PageSectionGroup>
diff --git a/apps/web/src/app/[locale]/control-panel/license/page.tsx b/apps/web/src/app/[locale]/control-panel/license/page.tsx
index bdcee5e4e..01e058716 100644
--- a/apps/web/src/app/[locale]/control-panel/license/page.tsx
+++ b/apps/web/src/app/[locale]/control-panel/license/page.tsx
@@ -2,13 +2,9 @@ import { buttonVariants } from "@rallly/ui";
import { Badge } from "@rallly/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@rallly/ui/card";
+import { Field, FieldContent, FieldGroup, FieldTitle } from "@rallly/ui/field";
import { KeySquareIcon, PaletteIcon, ShoppingBagIcon } from "lucide-react";
import type { Metadata } from "next";
-import {
- DescriptionList,
- DescriptionListTitle,
- DescriptionListValue,
-} from "@/components/description-list";
import {
EmptyState,
EmptyStateDescription,
@@ -16,7 +12,12 @@ import {
EmptyStateIcon,
EmptyStateTitle,
} from "@/components/empty-state";
-import { PageSection } from "@/components/page-layout";
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionHeader,
+ PageSectionTitle,
+} from "@/components/page-layout";
import {
SettingsPage,
SettingsPageContent,
@@ -57,59 +58,91 @@ export default async function LicensePage() {
{license ? (
<>
<PageSection variant="card">
- <div className="flex justify-between">
- <DescriptionList>
- <DescriptionListTitle>
- <Trans i18nKey="licenseType" defaults="License type" />
- </DescriptionListTitle>
- <DescriptionListValue>
- <span className="text-primary capitalize">
- {license.type}
- </span>
- {license.seats ? (
- <span className="ml-2 text-muted-foreground">
- (
- <Trans
- i18nKey="seatCount"
- defaults="{count, plural, one {# seat} other {# seats}}"
- values={{ count: license.seats }}
- />
- )
- </span>
- ) : null}
- </DescriptionListValue>
- <DescriptionListTitle>
- <Trans i18nKey="licenseKey" defaults="License key" />
- </DescriptionListTitle>
- <DescriptionListValue>
- <span className="select-all font-mono text-sm">
- {license.licenseKey}
- </span>
- </DescriptionListValue>
- <DescriptionListTitle>
- <Trans i18nKey="licenseeName" defaults="Licensee name" />
- </DescriptionListTitle>
- <DescriptionListValue>
- {license.licenseeName ?? "-"}
- </DescriptionListValue>
- <DescriptionListTitle>
- <Trans i18nKey="licenseeEmail" defaults="Licensee email" />
- </DescriptionListTitle>
- <DescriptionListValue>
- {license.licenseeEmail ?? "-"}
- </DescriptionListValue>
- <DescriptionListTitle>
- <Trans i18nKey="purchaseDate" defaults="Purchase date" />
- </DescriptionListTitle>
- <DescriptionListValue>
- <Time value={license.issuedAt} preset="date" />
- </DescriptionListValue>
- </DescriptionList>
- <div className="flex gap-2">
+ <PageSectionHeader className="flex items-center justify-between gap-4">
+ <PageSectionTitle>
+ <Trans i18nKey="licenseDetails" defaults="License details" />
+ </PageSectionTitle>
+ <div className="flex shrink-0 gap-2">
<RefreshLicenseButton />
<RemoveLicenseButton />
</div>
- </div>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <FieldGroup variant="divided">
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans i18nKey="licenseType" defaults="License type" />
+ </FieldTitle>
+ </FieldContent>
+ <div className="font-mono text-sm">
+ <span className="text-primary capitalize">
+ {license.type}
+ </span>
+ {license.seats ? (
+ <span className="ml-2 text-muted-foreground">
+ (
+ <Trans
+ i18nKey="seatCount"
+ defaults="{count, plural, one {# seat} other {# seats}}"
+ values={{ count: license.seats }}
+ />
+ )
+ </span>
+ ) : null}
+ </div>
+ </Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans i18nKey="licenseKey" defaults="License key" />
+ </FieldTitle>
+ </FieldContent>
+ <div className="select-all font-mono text-sm">
+ {license.licenseKey}
+ </div>
+ </Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ i18nKey="licenseeName"
+ defaults="Licensee name"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="font-mono text-sm">
+ {license.licenseeName ?? "-"}
+ </div>
+ </Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ i18nKey="licenseeEmail"
+ defaults="Licensee email"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="font-mono text-sm">
+ {license.licenseeEmail ?? "-"}
+ </div>
+ </Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ i18nKey="purchaseDate"
+ defaults="Purchase date"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="font-mono text-sm">
+ <Time value={license.issuedAt} preset="date" />
+ </div>
+ </Field>
+ </FieldGroup>
+ </PageSectionContent>
</PageSection>
<div className="grid gap-4 lg:grid-cols-2">
<Card>
diff --git a/apps/web/src/app/[locale]/control-panel/settings/instance-settings-form.tsx b/apps/web/src/app/[locale]/control-panel/settings/instance-settings-form.tsx
index 2072dba72..ab06e28d6 100644
--- a/apps/web/src/app/[locale]/control-panel/settings/instance-settings-form.tsx
+++ b/apps/web/src/app/[locale]/control-panel/settings/instance-settings-form.tsx
@@ -1,7 +1,13 @@
"use client";
import { Alert, AlertDescription } from "@rallly/ui/alert";
-import { Label } from "@rallly/ui/label";
+import {
+ Field,
+ FieldContent,
+ FieldDescription,
+ FieldGroup,
+ FieldLabel,
+} from "@rallly/ui/field";
import {
Select,
SelectContent,
@@ -47,56 +53,58 @@ export function InstanceSettingsForm({
};
return (
- <div className="space-y-4">
- <div className="flex items-center justify-between gap-4">
- <div className="space-y-1">
- <Label htmlFor="userRegistration">
- <Trans i18nKey="userRegistration" defaults="User registration" />
- </Label>
- <p className="text-muted-foreground text-sm">
- <Trans
- i18nKey="userRegistrationDescription"
- defaults="Allow new users to register an account."
- />
- </p>
- </div>
- <Select
- items={{
- enabled: <Trans i18nKey="enabled" defaults="Enabled" />,
- disabled: <Trans i18nKey="disabled" defaults="Disabled" />,
- }}
- value={disableUserRegistration ? "disabled" : "enabled"}
- onValueChange={(value) => {
- if (value) {
- handleChange(value);
- }
- }}
- disabled={!isRegistrationEnabled}
- >
- <SelectTrigger id="userRegistration" className="w-32">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="enabled">
- <Trans i18nKey="enabled" defaults="Enabled" />
- </SelectItem>
- <SelectItem value="disabled">
- <Trans i18nKey="disabled" defaults="Disabled" />
- </SelectItem>
- </SelectContent>
- </Select>
- </div>
- {!isRegistrationEnabled && (
- <Alert variant="note">
- <ContainerIcon />
- <AlertDescription>
- <Trans
- i18nKey="configuredByEnvironmentVariable"
- defaults="This setting has been configured by environment variable."
- />
- </AlertDescription>
- </Alert>
- )}
- </div>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldLabel htmlFor="userRegistration">
+ <Trans i18nKey="userRegistration" defaults="User registration" />
+ </FieldLabel>
+ <FieldDescription>
+ <Trans
+ i18nKey="userRegistrationDescription"
+ defaults="Allow new users to register an account."
+ />
+ </FieldDescription>
+ </FieldContent>
+ <Select
+ items={{
+ enabled: <Trans i18nKey="enabled" defaults="Enabled" />,
+ disabled: <Trans i18nKey="disabled" defaults="Disabled" />,
+ }}
+ value={disableUserRegistration ? "disabled" : "enabled"}
+ onValueChange={(value) => {
+ if (value) {
+ handleChange(value);
+ }
+ }}
+ disabled={!isRegistrationEnabled}
+ >
+ <SelectTrigger id="userRegistration" className="w-32">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="enabled">
+ <Trans i18nKey="enabled" defaults="Enabled" />
+ </SelectItem>
+ <SelectItem value="disabled">
+ <Trans i18nKey="disabled" defaults="Disabled" />
+ </SelectItem>
+ </SelectContent>
+ </Select>
+ </Field>
+ {!isRegistrationEnabled && (
+ <Alert variant="note">
+ <ContainerIcon />
+ <AlertDescription>
+ <Trans
+ i18nKey="configuredByEnvironmentVariable"
+ defaults="This setting has been configured by environment variable."
+ />
+ </AlertDescription>
+ </Alert>
+ )}
+ </Field>
+ </FieldGroup>
);
}
diff --git a/apps/web/src/components/description-list.tsx b/apps/web/src/components/description-list.tsx
deleted file mode 100644
index de471fca4..000000000
--- a/apps/web/src/components/description-list.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-function DescriptionList({ children }: { children: React.ReactNode }) {
- return <dl>{children}</dl>;
-}
-
-function DescriptionListTitle({ children }: { children: React.ReactNode }) {
- return <dt className="mb-1 text-muted-foreground text-xs">{children}</dt>;
-}
-
-function DescriptionListValue({ children }: { children: React.ReactNode }) {
- return <dd className="mb-4 font-mono text-sm last:mb-0">{children}</dd>;
-}
-
-export { DescriptionList, DescriptionListTitle, DescriptionListValue };