Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♻️ Replace the Setting primitives with the Field component (#2874)
Luke Vellaad8d88f56079
diff --git a/apps/web/src/app/[locale]/(space)/settings/general/components/custom-branding-section.tsx b/apps/web/src/app/[locale]/(space)/settings/general/components/custom-branding-section.tsxindex cc3dcc453..4ffe9b800 100644--- a/apps/web/src/app/[locale]/(space)/settings/general/components/custom-branding-section.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/general/components/custom-branding-section.tsx@@ -2,6 +2,14 @@import type { Color } from "@rallly/ui/color-picker";import { ColorPicker, parseColor } from "@rallly/ui/color-picker";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldLabel,+ FieldTitle,+} from "@rallly/ui/field";import { InputGroupButton } from "@rallly/ui/input-group";import { toast } from "@rallly/ui/sonner";import { Switch } from "@rallly/ui/switch";@@ -16,16 +24,6 @@ import {PageSectionHeader,PageSectionTitle,} from "@/components/page-layout";-import {- Setting,- SettingControl,- SettingDescription,- SettingHint,- SettingRow,- SettingsGroup,- SettingTitle,- useSettingLabels,-} from "@/components/setting";import { showPayWall, useIsFree } from "@/features/billing/client";import { ProBadge } from "@/features/billing/components/pro-badge";import { DEFAULT_PRIMARY_COLOR } from "@/features/branding/constants";@@ -117,78 +115,74 @@ export function CustomBrandingSection({</PageSectionDescription></PageSectionHeader><PageSectionContent>- <SettingsGroup>+ <FieldGroup variant="divided"><SpaceSettingsForm space={space} disabled={disabled} />- <SettingRow>- <SettingTitle>- <Trans- i18nKey="primaryColorSettingTitle"- defaults="Primary color"- />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="primaryColorSettingHint"- defaults="Used for buttons and highlights."- />- </SettingDescription>- <SettingControl>- <PrimaryColorField- value={color}- onChange={setColor}- disabled={disabled}- isDefault={isDefault}- isDirty={isDirty}- isSaving={updateSpace.isExecuting}- onSave={handleSave}- onReset={handleReset}- />- </SettingControl>- </SettingRow>+ <Field orientation="responsive">+ <FieldContent>+ <FieldTitle>+ <Trans+ i18nKey="primaryColorSettingTitle"+ defaults="Primary color"+ />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="primaryColorSettingHint"+ defaults="Used for buttons and highlights."+ />+ </FieldDescription>+ </FieldContent>+ <PrimaryColorField+ value={color}+ onChange={setColor}+ disabled={disabled}+ isDefault={isDefault}+ isDirty={isDirty}+ isSaving={updateSpace.isExecuting}+ onSave={handleSave}+ onReset={handleReset}+ />+ </Field><IfCloudHosted><RemoveAttributionSetting disabled={disabled} /></IfCloudHosted>- <Setting>- <SettingTitle>- <Trans- i18nKey="customBrandingSettingTitle"- defaults="Custom branding"- />- {space.tier !== "pro" && <ProBadge />}- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="customBrandingSettingLabel"- defaults="Show your logo and colors to participants."- />- </SettingDescription>- <SettingControl>+ <Field>+ <Field orientation="horizontal">+ <FieldContent>+ <FieldLabel htmlFor="show-branding">+ <Trans+ i18nKey="customBrandingSettingTitle"+ defaults="Custom branding"+ />+ {space.tier !== "pro" && <ProBadge />}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="customBrandingSettingLabel"+ defaults="Show your logo and colors to participants."+ />+ </FieldDescription>+ </FieldContent><Switch+ id="show-branding"checked={showBranding}onCheckedChange={handleToggle}disabled={disabled || updateShowBranding.isExecuting}/>- </SettingControl>- <SettingHint plain>- <BrandingPreview- spaceName={space.name}- spaceImage={space.image}- primaryColor={hexColor}- hostName={user.name}- />- </SettingHint>- </Setting>- </SettingsGroup>+ </Field>+ <BrandingPreview+ spaceName={space.name}+ spaceImage={space.image}+ primaryColor={hexColor}+ hostName={user.name}+ />+ </Field>+ </FieldGroup></PageSectionContent></PageSection>);}-/**- * Split out so `useSettingLabels()` runs inside the Setting provider. The- * picker is a composite control, so `SettingControl` cannot label it directly- * — the row's title and description are forwarded to the hex input instead.- */function PrimaryColorField({value,onChange,@@ -209,14 +203,12 @@ function PrimaryColorField({onReset: () => void;}) {const { t } = useTranslation();- const labels = useSettingLabels();return (<ColorPickerclassName="w-44"value={value}onChange={onChange}- {...labels}actions={disabled ? null : (<>diff --git a/apps/web/src/app/[locale]/(space)/settings/general/components/remove-attribution-setting.tsx b/apps/web/src/app/[locale]/(space)/settings/general/components/remove-attribution-setting.tsxindex 1022aa6af..203ace573 100644--- a/apps/web/src/app/[locale]/(space)/settings/general/components/remove-attribution-setting.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/general/components/remove-attribution-setting.tsx@@ -1,14 +1,14 @@"use client";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldLabel,+} from "@rallly/ui/field";import { toast } from "@rallly/ui/sonner";import { Switch } from "@rallly/ui/switch";import React from "react";-import {- Setting,- SettingControl,- SettingDescription,- SettingTitle,-} from "@/components/setting";import { showPayWall, useIsFree } from "@/features/billing/client";import { ProBadge } from "@/features/billing/components/pro-badge";import { updateSpaceHideAttributionAction } from "@/features/space/actions";@@ -52,27 +52,28 @@ export function RemoveAttributionSetting({};return (- <Setting>- <SettingTitle>- <Trans- i18nKey="removeAttributionSettingTitle"- defaults="Remove attribution"- />- {space.tier !== "pro" && <ProBadge />}- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="removeAttributionSettingDescription"- defaults='Hide "Powered by Rallly" on invite pages and participant emails.'- />- </SettingDescription>- <SettingControl>- <Switch- checked={hideAttribution}- onCheckedChange={handleToggle}- disabled={disabled || updateHideAttribution.isExecuting}- />- </SettingControl>- </Setting>+ <Field orientation="horizontal">+ <FieldContent>+ <FieldLabel htmlFor="hide-attribution">+ <Trans+ i18nKey="removeAttributionSettingTitle"+ defaults="Remove attribution"+ />+ {space.tier !== "pro" && <ProBadge />}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="removeAttributionSettingDescription"+ defaults='Hide "Powered by Rallly" on invite pages and participant emails.'+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="hide-attribution"+ checked={hideAttribution}+ onCheckedChange={handleToggle}+ disabled={disabled || updateHideAttribution.isExecuting}+ />+ </Field>);}diff --git a/apps/web/src/app/[locale]/(space)/settings/general/components/space-settings-form.tsx b/apps/web/src/app/[locale]/(space)/settings/general/components/space-settings-form.tsxindex 4cb6b645a..8b708c601 100644--- a/apps/web/src/app/[locale]/(space)/settings/general/components/space-settings-form.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/general/components/space-settings-form.tsx@@ -1,7 +1,14 @@"use client";import { zodResolver } from "@hookform/resolvers/zod";-import { FieldError } from "@rallly/ui/field";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldLabel,+ FieldTitle,+} from "@rallly/ui/field";import {InputGroup,InputGroupAddon,@@ -20,13 +27,6 @@ import {ImageUploadControl,ImageUploadPreview,} from "@/components/image-upload";-import {- SettingControl,- SettingDescription,- SettingRow,- SettingTitle,- useSettingLabels,-} from "@/components/setting";import {getSpaceImageUploadUrlAction,removeSpaceImageAction,@@ -92,60 +92,63 @@ export function SpaceSettingsForm({return (<>- <SettingRow>- <SettingTitle>- <Trans i18nKey="logo" defaults="Logo" />- </SettingTitle>- <SettingDescription>- <Trans i18nKey="spaceLogoSettingHint" defaults="Your space's logo." />- </SettingDescription>- <SettingControl>- <ImageUpload>- <ImageUploadPreview>- <SpaceIcon name={space.name} src={space.image} size="xl" />- </ImageUploadPreview>- <ImageUploadControl- getUploadUrl={handleGetUploadUrl}- onUploadSuccess={handleImageUploadSuccess}- onRemoveSuccess={handleImageRemoveSuccess}- hasCurrentImage={!!space.image}+ <Field orientation="responsive">+ <FieldContent>+ <FieldTitle>+ <Trans i18nKey="logo" defaults="Logo" />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="spaceLogoSettingHint"+ defaults="Your space's logo."/>- </ImageUpload>- </SettingControl>- </SettingRow>- <SettingRow>- <SettingTitle>- <Trans i18nKey="name" defaults="Name" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="spaceNameSettingLabel"- defaults="What this space is called."+ </FieldDescription>+ </FieldContent>+ <ImageUpload>+ <ImageUploadPreview>+ <SpaceIcon name={space.name} src={space.image} size="xl" />+ </ImageUploadPreview>+ <ImageUploadControl+ getUploadUrl={handleGetUploadUrl}+ onUploadSuccess={handleImageUploadSuccess}+ onRemoveSuccess={handleImageRemoveSuccess}+ hasCurrentImage={!!space.image}/>- </SettingDescription>- <SettingControl>- <SpaceNameField- control={form.control}- disabled={disabled}- isSaving={updateSpace.isExecuting}- isDirty={form.formState.isDirty}- onSubmit={form.handleSubmit(async (data) => {- const result = await updateSpace.executeAsync({- name: data.name,- });-- if (!result?.serverError && !result?.validationErrors) {- form.reset(data);- toast.success(- t("spaceUpdatedSuccess", {- defaultValue: "Space updated successfully",- }),- );- }- })}- />- </SettingControl>- </SettingRow>+ </ImageUpload>+ </Field>+ <Field orientation="responsive">+ <FieldContent>+ <FieldLabel htmlFor="space-name">+ <Trans i18nKey="name" defaults="Name" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="spaceNameSettingLabel"+ defaults="What this space is called."+ />+ </FieldDescription>+ </FieldContent>+ <SpaceNameField+ control={form.control}+ disabled={disabled}+ isSaving={updateSpace.isExecuting}+ isDirty={form.formState.isDirty}+ onSubmit={form.handleSubmit(async (data) => {+ const result = await updateSpace.executeAsync({+ name: data.name,+ });++ if (!result?.serverError && !result?.validationErrors) {+ form.reset(data);+ toast.success(+ t("spaceUpdatedSuccess", {+ defaultValue: "Space updated successfully",+ }),+ );+ }+ })}+ />+ </Field></>);}@@ -164,7 +167,6 @@ function SpaceNameField({onSubmit: React.FormEventHandler<HTMLFormElement>;}) {const { t } = useTranslation();- const labels = useSettingLabels();return (<form onSubmit={onSubmit}>@@ -176,7 +178,7 @@ function SpaceNameField({<InputGroup className="w-56"><InputGroupInput{...field}- {...labels}+ id="space-name"disabled={disabled}placeholder={t("spaceNamePlaceholder", {defaultValue: "My Team",diff --git a/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx b/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsxindex 8bdba05a3..5872a83b1 100644--- a/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/general/page-client.tsx@@ -2,7 +2,15 @@import { subject } from "@casl/ability";import { Alert, AlertDescription } from "@rallly/ui/alert";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldTitle,+} from "@rallly/ui/field";import { EyeIcon, LogOutIcon, TrashIcon } from "lucide-react";+import { PageIcon } from "@/components/page-icons";import {PageSection,PageSectionContent,@@ -11,14 +19,6 @@ import {PageSectionHeader,PageSectionTitle,} from "@/components/page-layout";-import {- SettingControl,- SettingDescription,- SettingIcon,- SettingRow,- SettingsGroup,- SettingTitle,-} from "@/components/setting";import {SettingsPage,SettingsPageContent,@@ -82,49 +82,56 @@ export function GeneralSettingsPageClient() {</PageSectionDescription></PageSectionHeader><PageSectionContent>- <SettingsGroup>+ <FieldGroup variant="divided">{!isOwner ? (- <SettingRow>- <SettingIcon>- <LogOutIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="leaveSpace" defaults="Leave Space" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="leaveSpaceSettingHint"- defaults="Remove yourself from this space and lose access to its polls."- />- </SettingDescription>- <SettingControl>- <LeaveSpaceButton- spaceName={space.name}- spaceId={space.id}- />- </SettingControl>- </SettingRow>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <LogOutIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldTitle>+ <Trans i18nKey="leaveSpace" defaults="Leave Space" />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="leaveSpaceSettingHint"+ defaults="Remove yourself from this space and lose access to its polls."+ />+ </FieldDescription>+ </FieldContent>+ <LeaveSpaceButton+ spaceName={space.name}+ spaceId={space.id}+ />+ </Field>) : null}{canDeleteSpace ? (- <SettingRow>- <SettingIcon>- <TrashIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="deleteSpace" defaults="Delete Space" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="deleteSpaceSettingHint"- defaults="Permanently delete this space and everything in it."- />- </SettingDescription>- <SettingControl>- <DeleteSpaceButton spaceName={space.name} />- </SettingControl>- </SettingRow>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <TrashIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldTitle>+ <Trans+ i18nKey="deleteSpace"+ defaults="Delete Space"+ />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="deleteSpaceSettingHint"+ defaults="Permanently delete this space and everything in it."+ />+ </FieldDescription>+ </FieldContent>+ <DeleteSpaceButton spaceName={space.name} />+ </Field>) : null}- </SettingsGroup>+ </FieldGroup></PageSectionContent></PageSection>) : null}diff --git a/apps/web/src/app/[locale]/(space)/settings/notifications/notifications-page.tsx b/apps/web/src/app/[locale]/(space)/settings/notifications/notifications-page.tsxindex 8b609624b..a254b1fa5 100644--- a/apps/web/src/app/[locale]/(space)/settings/notifications/notifications-page.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/notifications/notifications-page.tsx@@ -1,9 +1,17 @@"use client";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldLabel,+} from "@rallly/ui/field";import { toast } from "@rallly/ui/sonner";import { Switch } from "@rallly/ui/switch";import { InboxIcon, MessageCircleIcon } from "lucide-react";import React from "react";+import { PageIcon } from "@/components/page-icons";import {PageSection,PageSectionContent,@@ -12,14 +20,6 @@ import {PageSectionHeader,PageSectionTitle,} from "@/components/page-layout";-import {- Setting,- SettingControl,- SettingDescription,- SettingIcon,- SettingsGroup,- SettingTitle,-} from "@/components/setting";import { updateNotificationPreferenceAction } from "@/features/notifications/actions";import type {ActivityEventType,@@ -68,52 +68,58 @@ export function NotificationsPage({</PageSectionDescription></PageSectionHeader><PageSectionContent>- <SettingsGroup>- <Setting>- <SettingIcon>- <InboxIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="notifyNewResponse" defaults="New response" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="notifyNewResponseDescription"- defaults="Receive an email when a participant submits a response."- />- </SettingDescription>- <SettingControl>- <Switch- checked={preferences["poll.response.submitted"]}- onCheckedChange={(enabled) => {- setPreference("poll.response.submitted", enabled);- }}- />- </SettingControl>- </Setting>- <Setting>- <SettingIcon>- <MessageCircleIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="notifyNewComment" defaults="New comment" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="notifyNewCommentDescription"- defaults="Receive an email when someone comments on your poll."- />- </SettingDescription>- <SettingControl>- <Switch- checked={preferences["poll.comment.added"]}- onCheckedChange={(enabled) => {- setPreference("poll.comment.added", enabled);- }}- />- </SettingControl>- </Setting>- </SettingsGroup>+ <FieldGroup variant="divided">+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <InboxIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="notify-new-response">+ <Trans i18nKey="notifyNewResponse" defaults="New response" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="notifyNewResponseDescription"+ defaults="Receive an email when a participant submits a response."+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="notify-new-response"+ checked={preferences["poll.response.submitted"]}+ onCheckedChange={(enabled) => {+ setPreference("poll.response.submitted", enabled);+ }}+ />+ </Field>+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <MessageCircleIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="notify-new-comment">+ <Trans i18nKey="notifyNewComment" defaults="New comment" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="notifyNewCommentDescription"+ defaults="Receive an email when someone comments on your poll."+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="notify-new-comment"+ checked={preferences["poll.comment.added"]}+ onCheckedChange={(enabled) => {+ setPreference("poll.comment.added", enabled);+ }}+ />+ </Field>+ </FieldGroup></PageSectionContent></PageSection></PageSectionGroup>diff --git a/apps/web/src/app/[locale]/(space)/settings/preferences/components/localization-preferences.tsx b/apps/web/src/app/[locale]/(space)/settings/preferences/components/localization-preferences.tsxindex edef15463..15fa5050a 100644--- a/apps/web/src/app/[locale]/(space)/settings/preferences/components/localization-preferences.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/preferences/components/localization-preferences.tsx@@ -1,6 +1,13 @@"use client";import { buttonVariants } from "@rallly/ui";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldLabel,+} from "@rallly/ui/field";import {Select,SelectContent,@@ -19,14 +26,7 @@ import {import Link from "next/link";import React from "react";import { LanguageSelect } from "@/components/language-selector";-import {- Setting,- SettingControl,- SettingDescription,- SettingIcon,- SettingsGroup,- SettingTitle,-} from "@/components/setting";+import { PageIcon } from "@/components/page-icons";import { TimeZoneSelect } from "@/components/time-zone-picker/time-zone-select";import { updateLocalizationAction } from "@/features/user/actions";import { Trans, useTranslation } from "@/i18n/client";@@ -92,167 +92,177 @@ export const LocalizationPreferences = ({return (<div>- <SettingsGroup>- <Setting>- <SettingIcon>- <LanguagesIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="language" defaults="Language" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="languageSettingDescription"- defaults="The language the app is displayed in."- />- </SettingDescription>- <SettingControl>- <LanguageSelect- className="min-w-32"- value={language}- onChange={async (nextLanguage) => {- if (nextLanguage === language) {- return;- }- const previousLanguage = language;- setLanguage(nextLanguage);- // Set the cookie before executing: useSafeAction refreshes the- // router on success, and that refresh must read the new locale.- // Writing the cookie server-side would collide with- // updateUser's session cookie and drop it. Roll it back to the- // locale this page is rendered in if the save doesn't land.- setLocaleCookie(nextLanguage);- let saved = false;- try {- saved = await save({ locale: nextLanguage });- } finally {- if (!saved) {- setLocaleCookie(locale);- setLanguage(previousLanguage);- }- }- }}- />- </SettingControl>- </Setting>- <Setting>- <SettingIcon>- <GlobeIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="timeZone" defaults="Time Zone" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="timeZoneSettingDescription"- defaults="Dates and times are shown in this time zone."- />- </SettingDescription>- <SettingControl>- <TimeZoneSelect- className="min-w-56"- value={timeZone}- onValueChange={async (nextTimeZone) => {- if (nextTimeZone === timeZone) {- return;- }- const previousTimeZone = timeZone;- setTimeZone(nextTimeZone);- if (!(await save({ timeZone: nextTimeZone }))) {- setTimeZone(previousTimeZone);- }- }}- />- </SettingControl>- </Setting>- <Setting>- <SettingIcon>- <ClockIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="timeFormat" defaults="Time Format" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="timeFormatSettingDescription"- defaults="Show times in 12-hour or 24-hour format."- />- </SettingDescription>- <SettingControl>- <Select- items={timeFormatOptions}- value={timeFormat}- onValueChange={async (value) => {- if (!value || value === timeFormat) {- return;- }- const previousTimeFormat = timeFormat;- const nextTimeFormat = value as TimeFormat;- setTimeFormat(nextTimeFormat);- if (!(await save({ timeFormat: nextTimeFormat }))) {- setTimeFormat(previousTimeFormat);- }- }}- >- <SelectTrigger className="min-w-32">- <SelectValue />- </SelectTrigger>- <SelectContent>- {timeFormatOptions.map((option) => (- <SelectItem key={option.value} value={option.value}>- {option.label}- </SelectItem>- ))}- </SelectContent>- </Select>- </SettingControl>- </Setting>- <Setting>- <SettingIcon>- <CalendarIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="startOfWeek" defaults="Start of Week" />- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="startOfWeekSettingDescription"- defaults="The day calendars start the week on."- />- </SettingDescription>- <SettingControl>- <Select- items={weekStartOptions}- value={weekStart.toString()}- onValueChange={async (value) => {- if (!value) {- return;- }- const previousWeekStart = weekStart;- const nextWeekStart = Number.parseInt(value, 10);- if (nextWeekStart === previousWeekStart) {- return;- }- setWeekStart(nextWeekStart);- if (!(await save({ weekStart: nextWeekStart }))) {- setWeekStart(previousWeekStart);+ <FieldGroup variant="divided">+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <LanguagesIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="language-select">+ <Trans i18nKey="language" defaults="Language" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="languageSettingDescription"+ defaults="The language the app is displayed in."+ />+ </FieldDescription>+ </FieldContent>+ <LanguageSelect+ id="language-select"+ className="min-w-32"+ value={language}+ onChange={async (nextLanguage) => {+ if (nextLanguage === language) {+ return;+ }+ const previousLanguage = language;+ setLanguage(nextLanguage);+ // Set the cookie before executing: useSafeAction refreshes the+ // router on success, and that refresh must read the new locale.+ // Writing the cookie server-side would collide with+ // updateUser's session cookie and drop it. Roll it back to the+ // locale this page is rendered in if the save doesn't land.+ setLocaleCookie(nextLanguage);+ let saved = false;+ try {+ saved = await save({ locale: nextLanguage });+ } finally {+ if (!saved) {+ setLocaleCookie(locale);+ setLanguage(previousLanguage);}- }}- >- <SelectTrigger className="min-w-32">- <SelectValue />- </SelectTrigger>- <SelectContent>- {weekStartOptions.map((option) => (- <SelectItem key={option.value} value={option.value}>- {option.label}- </SelectItem>- ))}- </SelectContent>- </Select>- </SettingControl>- </Setting>- </SettingsGroup>+ }+ }}+ />+ </Field>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <GlobeIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="time-zone-select">+ <Trans i18nKey="timeZone" defaults="Time Zone" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="timeZoneSettingDescription"+ defaults="Dates and times are shown in this time zone."+ />+ </FieldDescription>+ </FieldContent>+ <TimeZoneSelect+ id="time-zone-select"+ className="min-w-56"+ value={timeZone}+ onValueChange={async (nextTimeZone) => {+ if (nextTimeZone === timeZone) {+ return;+ }+ const previousTimeZone = timeZone;+ setTimeZone(nextTimeZone);+ if (!(await save({ timeZone: nextTimeZone }))) {+ setTimeZone(previousTimeZone);+ }+ }}+ />+ </Field>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <ClockIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="time-format-select">+ <Trans i18nKey="timeFormat" defaults="Time Format" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="timeFormatSettingDescription"+ defaults="Show times in 12-hour or 24-hour format."+ />+ </FieldDescription>+ </FieldContent>+ <Select+ items={timeFormatOptions}+ value={timeFormat}+ onValueChange={async (value) => {+ if (!value || value === timeFormat) {+ return;+ }+ const previousTimeFormat = timeFormat;+ const nextTimeFormat = value as TimeFormat;+ setTimeFormat(nextTimeFormat);+ if (!(await save({ timeFormat: nextTimeFormat }))) {+ setTimeFormat(previousTimeFormat);+ }+ }}+ >+ <SelectTrigger id="time-format-select" className="min-w-32">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {timeFormatOptions.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <CalendarIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="week-start-select">+ <Trans i18nKey="startOfWeek" defaults="Start of Week" />+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="startOfWeekSettingDescription"+ defaults="The day calendars start the week on."+ />+ </FieldDescription>+ </FieldContent>+ <Select+ items={weekStartOptions}+ value={weekStart.toString()}+ onValueChange={async (value) => {+ if (!value) {+ return;+ }+ const previousWeekStart = weekStart;+ const nextWeekStart = Number.parseInt(value, 10);+ if (nextWeekStart === previousWeekStart) {+ return;+ }+ setWeekStart(nextWeekStart);+ if (!(await save({ weekStart: nextWeekStart }))) {+ setWeekStart(previousWeekStart);+ }+ }}+ >+ <SelectTrigger id="week-start-select" className="min-w-32">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {weekStartOptions.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>+ </FieldGroup><div className="mt-4 border-t pt-4"><Linktarget="_blank"diff --git a/apps/web/src/app/[locale]/(space)/settings/profile/components/cancel-account-deletion-button.tsx b/apps/web/src/app/[locale]/(space)/settings/profile/components/cancel-account-deletion-button.tsxindex cb73de4b2..adb077ee6 100644--- a/apps/web/src/app/[locale]/(space)/settings/profile/components/cancel-account-deletion-button.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/profile/components/cancel-account-deletion-button.tsx@@ -5,12 +5,7 @@ import { Trans, useTranslation } from "@/i18n/client";import { useSafeAction } from "@/lib/safe-action/client";import { cancelAccountDeletionAction } from "../actions";-export function CancelAccountDeletionButton({- ...rest-}: {- "aria-labelledby"?: string;- "aria-describedby"?: string;-}) {+export function CancelAccountDeletionButton() {const { t } = useTranslation();const cancelAccountDeletion = useSafeAction(cancelAccountDeletionAction, {onSuccess: () => {@@ -26,7 +21,6 @@ export function CancelAccountDeletionButton({<Buttonloading={cancelAccountDeletion.isExecuting}onClick={() => cancelAccountDeletion.executeAsync()}- {...rest}><Trans i18nKey="cancelAccountDeletion" defaults="Cancel deletion" /></Button>diff --git a/apps/web/src/app/[locale]/(space)/settings/profile/components/delete-account-setting.tsx b/apps/web/src/app/[locale]/(space)/settings/profile/components/delete-account-setting.tsxindex 73615e560..d14463960 100644--- a/apps/web/src/app/[locale]/(space)/settings/profile/components/delete-account-setting.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/profile/components/delete-account-setting.tsx@@ -1,12 +1,12 @@import { Button } from "@rallly/ui/button";-import { TriangleAlertIcon } from "lucide-react";import {- SettingControl,- SettingDescription,- SettingIcon,- SettingRow,- SettingTitle,-} from "@/components/setting";+ Field,+ FieldContent,+ FieldDescription,+ FieldTitle,+} from "@rallly/ui/field";+import { TriangleAlertIcon } from "lucide-react";+import { PageIcon } from "@/components/page-icons";import { getScheduledDeletionDate } from "@/features/user/account-deletion/utils";import { Trans } from "@/i18n/client";import { getSession } from "@/lib/auth";@@ -14,9 +14,6 @@ import { formatDateTime } from "@/lib/datetime/format";import { CancelAccountDeletionButton } from "./cancel-account-deletion-button";import { DeleteAccountDialog } from "./delete-account-dialog";-const pendingDeletionTitleId = "pending-deletion-title";-const pendingDeletionDescriptionId = "pending-deletion-description";-export async function PendingDeletionSetting({deletedAt,}: {@@ -30,66 +27,60 @@ export async function PendingDeletionSetting({});return (- <SettingRow>- <SettingIcon>- <TriangleAlertIcon />- </SettingIcon>- <SettingTitle id={pendingDeletionTitleId}>- <Trans i18nKey="deleteAccount" defaults="Delete Account" />- </SettingTitle>- <SettingDescription id={pendingDeletionDescriptionId}>- <Trans- i18nKey="pendingDeletionNotice"- defaults="Your account and data will be permanently deleted on {deletionDate}."- values={{ deletionDate }}- />- </SettingDescription>- <SettingControl>- <CancelAccountDeletionButton- aria-labelledby={pendingDeletionTitleId}- aria-describedby={pendingDeletionDescriptionId}- />- </SettingControl>- </SettingRow>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <TriangleAlertIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldTitle>+ <Trans i18nKey="deleteAccount" defaults="Delete Account" />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="pendingDeletionNotice"+ defaults="Your account and data will be permanently deleted on {deletionDate}."+ values={{ deletionDate }}+ />+ </FieldDescription>+ </FieldContent>+ <CancelAccountDeletionButton />+ </Field>);}-const deleteAccountTitleId = "delete-account-title";-const deleteAccountDescriptionId = "delete-account-description";-export function DeleteAccountSetting({summary,}: {summary?: React.ReactNode;}) {return (- <SettingRow>- <SettingIcon>- <TriangleAlertIcon />- </SettingIcon>- <SettingTitle id={deleteAccountTitleId}>- <Trans i18nKey="deleteAccount" defaults="Delete Account" />- </SettingTitle>- <SettingDescription id={deleteAccountDescriptionId}>- <Trans- i18nKey="dangerZoneAccountDeletion"- defaults="Delete your account and all data associated with it"- />- </SettingDescription>- <SettingControl>- <DeleteAccountDialog- trigger={- <Button- className="text-destructive"- aria-labelledby={deleteAccountTitleId}- aria-describedby={deleteAccountDescriptionId}- >- <Trans i18nKey="deleteAccount" defaults="Delete Account" />- </Button>- }- summary={summary}- />- </SettingControl>- </SettingRow>+ <Field orientation="responsive">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <TriangleAlertIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldTitle>+ <Trans i18nKey="deleteAccount" defaults="Delete Account" />+ </FieldTitle>+ <FieldDescription>+ <Trans+ i18nKey="dangerZoneAccountDeletion"+ defaults="Delete your account and all data associated with it"+ />+ </FieldDescription>+ </FieldContent>+ <DeleteAccountDialog+ trigger={+ <Button className="text-destructive">+ <Trans i18nKey="deleteAccount" defaults="Delete Account" />+ </Button>+ }+ summary={summary}+ />+ </Field>);}diff --git a/apps/web/src/app/[locale]/(space)/settings/profile/page.tsx b/apps/web/src/app/[locale]/(space)/settings/profile/page.tsxindex 03e8266e6..dcfb1476f 100644--- a/apps/web/src/app/[locale]/(space)/settings/profile/page.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/profile/page.tsx@@ -1,7 +1,7 @@+import { FieldGroup } from "@rallly/ui/field";import type { Metadata } from "next";import { redirect } from "next/navigation";import { Suspense } from "react";-import type { Params } from "@/app/[locale]/types";import {PageSection,@@ -11,7 +11,6 @@ import {PageSectionHeader,PageSectionTitle,} from "@/components/page-layout";-import { SettingsGroup } from "@/components/setting";import {SettingsPage,SettingsPageContent,@@ -94,7 +93,7 @@ export default async function Page() {</PageSectionTitle></PageSectionHeader><PageSectionContent>- <SettingsGroup>+ <FieldGroup variant="divided">{user.deletedAt ? (<PendingDeletionSetting deletedAt={user.deletedAt} />) : (@@ -106,7 +105,7 @@ export default async function Page() {}/>)}- </SettingsGroup>+ </FieldGroup></PageSectionContent></PageSection></PageSectionGroup>diff --git a/apps/web/src/components/language-selector.tsx b/apps/web/src/components/language-selector.tsxindex 8de154af7..7babbad28 100644--- a/apps/web/src/components/language-selector.tsx+++ b/apps/web/src/components/language-selector.tsx@@ -10,12 +10,13 @@ import {import { LanguagesIcon } from "lucide-react";export const LanguageSelect: React.FunctionComponent<{+ id?: string;className?: string;value?: string;onChange?: (language: string) => void;"aria-labelledby"?: string;"aria-describedby"?: string;-}> = ({ className, value, onChange, ...ariaProps }) => {+}> = ({ id, className, value, onChange, ...ariaProps }) => {return (<Selectitems={languages}@@ -26,7 +27,7 @@ export const LanguageSelect: React.FunctionComponent<{}}}>- <SelectTrigger className={className} {...ariaProps}>+ <SelectTrigger id={id} className={className} {...ariaProps}><Icon><LanguagesIcon /></Icon>diff --git a/apps/web/src/components/setting.tsx b/apps/web/src/components/setting.tsxdeleted file mode 100644index cf9399d7e..000000000--- a/apps/web/src/components/setting.tsx+++ /dev/null@@ -1,203 +0,0 @@-"use client";--import { cva } from "class-variance-authority";-import { InfoIcon } from "lucide-react";-import React from "react";-import { PageIcon } from "@/components/page-icons";--const SettingContext = React.createContext<{- titleId: string;- descriptionId: string;- hintId: string;- /** Whether SettingControl labels its child, or the control names itself. */- labelsControl: boolean;-} | null>(null);--const useSetting = () => {- const context = React.useContext(SettingContext);- if (!context) {- throw new Error("Setting components must be used within <Setting>");- }- return context;-};--export const SettingsGroup = ({ children }: React.PropsWithChildren) => {- return <div className="divide-y">{children}</div>;-};--const settingVariants = cva(- // The icon column is `auto`, so it collapses to zero width without a- // SettingIcon; a uniform `gap-x` would still indent iconless rows, so the- // gap is zero and SettingIcon/SettingControl carry their own margins.- // Below `sm` everything stacks in one column so wide controls (pickers,- // input groups) get the full width rather than being squeezed beside the- // title; from `sm` up the control moves to its own column on the right.- "grid grid-cols-1 py-4 [column-gap:0] [grid-template-areas:'title'_'description'_'control'_'hint'] first:pt-0 last:pb-0 sm:grid-cols-[auto_1fr_auto] sm:[grid-template-areas:'icon_title_control'_'icon_description_control'_'icon_hint_hint']",- {- variants: {- interactive: {- true: "cursor-pointer select-none",- false: "",- },- },- defaultVariants: { interactive: false },- },-);--const SettingProvider = ({- children,- labelsControl,-}: React.PropsWithChildren<{ labelsControl: boolean }>) => {- const titleId = React.useId();- const descriptionId = React.useId();- const hintId = React.useId();- const value = React.useMemo(- () => ({ titleId, descriptionId, hintId, labelsControl }),- [titleId, descriptionId, hintId, labelsControl],- );- return (- <SettingContext.Provider value={value}>{children}</SettingContext.Provider>- );-};--/**- * A setting whose control is a single labelable element — a switch, a select.- * The row renders as a label, so clicking anywhere on it activates the- * control, and SettingControl labels the control automatically.- *- * For a control made of several elements (an input with a button, a picker, a- * dialog trigger) use SettingRow instead: there is no single element for a- * label to point at, and wrapping several controls in one label is invalid.- */-export const Setting = ({ children }: React.PropsWithChildren) => {- return (- <SettingProvider labelsControl>- {/* biome-ignore lint/a11y/noLabelWithoutControl: control is rendered inside */}- <label className={settingVariants({ interactive: true })}>- {children}- </label>- </SettingProvider>- );-};--/**- * A setting whose control is not a single labelable element — a button, an- * input with its own actions, a picker. Renders a plain row, so the control has- * to name itself: spread `useSettingLabels()` onto whichever element is the- * real control.- */-export const SettingRow = ({ children }: React.PropsWithChildren) => {- return (- <SettingProvider labelsControl={false}>- <div className={settingVariants()}>{children}</div>- </SettingProvider>- );-};--export const SettingIcon = ({ children }: React.PropsWithChildren) => {- return (- <div className="mr-3 hidden self-start [grid-area:icon] sm:block">- <PageIcon size="lg">{children}</PageIcon>- </div>- );-};--export const SettingTitle = ({- children,- id,-}: React.PropsWithChildren<{ id?: string }>) => {- const { titleId } = useSetting();- return (- <div- id={id ?? titleId}- className="flex items-center gap-x-2 text-sm [grid-area:title]"- >- {children}- </div>- );-};--export const SettingDescription = ({- children,- id,-}: React.PropsWithChildren<{ id?: string }>) => {- const { descriptionId } = useSetting();- return (- <div- id={id ?? descriptionId}- className="mt-0.5 text-muted-foreground text-xs [grid-area:description]"- >- {children}- </div>- );-};--/**- * Holds the row's control. Inside `Setting` the control is a single labelable- * element, so the row's title and description are applied to it directly.- * Inside `SettingRow` there is no single element to label — the control names- * itself with `useSettingLabels()` — so the child is rendered untouched.- *- * Inside `Setting` the child must be created in client code: cloneElement- * corrupts elements streamed from server components (dev SSR bails out with- * "Element type is invalid"). Server-composed controls go in `SettingRow`.- */-export const SettingControl = ({- children,-}: {- children: React.ReactElement<{- "aria-labelledby"?: string;- "aria-describedby"?: string;- }>;-}) => {- const { titleId, descriptionId, hintId, labelsControl } = useSetting();- return (- <div className="mt-3 self-start justify-self-start [grid-area:control] sm:mt-0 sm:ml-3 sm:justify-self-end">- {/* A dangling hint id is ignored by assistive tech while no hint is rendered */}- {labelsControl- ? React.cloneElement(children, {- "aria-labelledby": titleId,- "aria-describedby": `${descriptionId} ${hintId}`,- })- : children}- </div>- );-};--export const useSettingLabels = () => {- const { titleId, descriptionId, hintId } = useSetting();- return {- "aria-labelledby": titleId,- "aria-describedby": `${descriptionId} ${hintId}`,- };-};--/**- * Supplementary content spanning the full row width, below the title and- * control. Text hints get an info icon; `plain` drops the icon and the text- * styling for rich content such as an embedded preview.- */-export const SettingHint = ({- children,- plain = false,-}: React.PropsWithChildren<{ plain?: boolean }>) => {- const { hintId } = useSetting();-- if (plain) {- return (- <div id={hintId} className="mt-4 [grid-area:hint]">- {children}- </div>- );- }-- return (- <div- id={hintId}- className="mt-4 flex items-start gap-x-1.5 text-muted-foreground text-xs [grid-area:hint]"- >- <InfoIcon className="size-3.5 shrink-0 translate-y-px" />- <span>{children}</span>- </div>- );-};diff --git a/apps/web/src/components/time-zone-picker/time-zone-select.tsx b/apps/web/src/components/time-zone-picker/time-zone-select.tsxindex ee049d711..efa6551f1 100644--- a/apps/web/src/components/time-zone-picker/time-zone-select.tsx+++ b/apps/web/src/components/time-zone-picker/time-zone-select.tsx@@ -31,12 +31,14 @@ function filterTimezone(id: string, query: string): boolean {}export function TimeZoneSelect({+ id,value,onValueChange,className,disabled,...ariaProps}: {+ id?: string;value?: string;onValueChange?: (value: string) => void;className?: string;@@ -74,6 +76,7 @@ export function TimeZoneSelect({><div ref={anchorRef} className={cn("min-w-64", className)}><ComboboxInput+ id={id}disabled={disabled}placeholder={t("timezoneInputPlaceholder", {defaultValue: "Search timezone…",diff --git a/apps/web/src/features/poll/components/forms/poll-settings.tsx b/apps/web/src/features/poll/components/forms/poll-settings.tsxindex ee33091e5..a5bae5a08 100644--- a/apps/web/src/features/poll/components/forms/poll-settings.tsx+++ b/apps/web/src/features/poll/components/forms/poll-settings.tsx@@ -3,24 +3,24 @@import { posthog } from "@rallly/posthog/client";import { Badge } from "@rallly/ui/badge";import { Card, CardContent, CardTitle } from "@rallly/ui/card";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldLabel,+} from "@rallly/ui/field";import { FormField } from "@rallly/ui/form";import { Switch } from "@rallly/ui/switch";import {BarChart2Icon,+ InfoIcon,MailIcon,MessageCircleIcon,VenetianMaskIcon,} from "lucide-react";import { useFormContext } from "react-hook-form";-import {- Setting,- SettingControl,- SettingDescription,- SettingHint,- SettingIcon,- SettingsGroup,- SettingTitle,-} from "@/components/setting";+import { PageIcon } from "@/components/page-icons";import { showPayWall, useIsFree } from "@/features/billing/client";import { ProBadge } from "@/features/billing/components/pro-badge";import type { PollSettingsFormData } from "@/features/poll/components/forms/types";@@ -38,146 +38,163 @@ export const PollSettingsForm = ({ children }: React.PropsWithChildren) => {</CardTitle></div><CardContent>- <SettingsGroup>+ <FieldGroup variant="divided"><FormFieldcontrol={form.control}name="requireParticipantEmail"render={({ field }) => (- <Setting>- <SettingIcon>- <MailIcon />- </SettingIcon>- <SettingTitle>- <Trans- i18nKey="requireParticipantEmailTitle"- defaults="Require email"- />- {isFree ? <ProBadge /> : null}- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="requireParticipantEmailDescription"- defaults="Participants must provide an email address to respond."- />- </SettingDescription>- <SettingControl>- <Switch- checked={!!field.value}- onCheckedChange={(checked) => {- if (checked && isFree) {- showPayWall({- from: "poll-settings",- setting: "requireParticipantEmail",- });- } else {- field.onChange(checked);- }- }}- />- </SettingControl>- </Setting>+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <MailIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="require-participant-email">+ <Trans+ i18nKey="requireParticipantEmailTitle"+ defaults="Require email"+ />+ {isFree ? <ProBadge /> : null}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="requireParticipantEmailDescription"+ defaults="Participants must provide an email address to respond."+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="require-participant-email"+ checked={!!field.value}+ onCheckedChange={(checked) => {+ if (checked && isFree) {+ showPayWall({+ from: "poll-settings",+ setting: "requireParticipantEmail",+ });+ } else {+ field.onChange(checked);+ }+ }}+ />+ </Field>)}/><FormFieldcontrol={form.control}name="hideParticipants"render={({ field }) => (- <Setting>- <SettingIcon>- <VenetianMaskIcon />- </SettingIcon>- <SettingTitle>- <Trans- i18nKey="hideParticipantsTitle"- defaults="Hide participant names"- />- {isFree ? <ProBadge /> : null}- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="hideParticipantsDescription"- defaults="Participants will not be able to see the names of other respondents."- />- </SettingDescription>- <SettingControl>- <Switch- checked={!!field.value}- onCheckedChange={(checked) => {- if (checked && isFree) {- showPayWall({- from: "poll-settings",- setting: "hideParticipants",- });- } else {- field.onChange(checked);- }- }}- />- </SettingControl>- </Setting>+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <VenetianMaskIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="hide-participants">+ <Trans+ i18nKey="hideParticipantsTitle"+ defaults="Hide participant names"+ />+ {isFree ? <ProBadge /> : null}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="hideParticipantsDescription"+ defaults="Participants will not be able to see the names of other respondents."+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="hide-participants"+ checked={!!field.value}+ onCheckedChange={(checked) => {+ if (checked && isFree) {+ showPayWall({+ from: "poll-settings",+ setting: "hideParticipants",+ });+ } else {+ field.onChange(checked);+ }+ }}+ />+ </Field>)}/><FormFieldcontrol={form.control}name="hideScores"render={({ field }) => (- <Setting>- <SettingIcon>- <BarChart2Icon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="hideScoresTitle" defaults="Hide votes" />- {isFree ? <ProBadge /> : null}- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="hideScoresDescription"- defaults="Hide everyone's votes from a participant until they cast their own."- />- </SettingDescription>- <SettingControl>- <Switch- checked={!!field.value}- onCheckedChange={(checked) => {- if (checked && isFree) {- showPayWall({- from: "poll-settings",- setting: "hideScores",- });- } else {- field.onChange(checked);- }- }}- />- </SettingControl>- </Setting>+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <BarChart2Icon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="hide-scores">+ <Trans i18nKey="hideScoresTitle" defaults="Hide votes" />+ {isFree ? <ProBadge /> : null}+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="hideScoresDescription"+ defaults="Hide everyone's votes from a participant until they cast their own."+ />+ </FieldDescription>+ </FieldContent>+ <Switch+ id="hide-scores"+ checked={!!field.value}+ onCheckedChange={(checked) => {+ if (checked && isFree) {+ showPayWall({+ from: "poll-settings",+ setting: "hideScores",+ });+ } else {+ field.onChange(checked);+ }+ }}+ />+ </Field>)}/><FormFieldcontrol={form.control}name="enableComments"render={({ field }) => (- <Setting>- <SettingIcon>- <MessageCircleIcon />- </SettingIcon>- <SettingTitle>- <Trans i18nKey="commentsSettingTitle" defaults="Comments" />- <Badge size="sm">- <Trans- i18nKey="commentsSettingLegacyBadge"- defaults="Legacy"- />- </Badge>- </SettingTitle>- <SettingDescription>- <Trans- i18nKey="commentsSettingDescription"- defaults="Allow participants to post public comments on the poll."- />- </SettingDescription>- <SettingControl>+ <Field>+ <Field orientation="horizontal">+ <div className="@md/field-group:block hidden">+ <PageIcon size="lg">+ <MessageCircleIcon />+ </PageIcon>+ </div>+ <FieldContent>+ <FieldLabel htmlFor="enable-comments">+ <Trans+ i18nKey="commentsSettingTitle"+ defaults="Comments"+ />+ <Badge size="sm">+ <Trans+ i18nKey="commentsSettingLegacyBadge"+ defaults="Legacy"+ />+ </Badge>+ </FieldLabel>+ <FieldDescription>+ <Trans+ i18nKey="commentsSettingDescription"+ defaults="Allow participants to post public comments on the poll."+ />+ </FieldDescription>+ </FieldContent><Switch+ id="enable-comments"checked={!!field.value}onCheckedChange={(checked) => {field.onChange(checked);@@ -186,19 +203,22 @@ export const PollSettingsForm = ({ children }: React.PropsWithChildren) => {});}}/>- </SettingControl>+ </Field>{field.value ? (- <SettingHint>- <Trans- i18nKey="commentsSettingPhaseOutHint"- defaults="Comments are being phased out. Participants can include a note with their response instead."- />- </SettingHint>+ <FieldDescription className="flex items-start gap-x-1.5">+ <InfoIcon className="size-3.5 shrink-0 translate-y-px" />+ <span>+ <Trans+ i18nKey="commentsSettingPhaseOutHint"+ defaults="Comments are being phased out. Participants can include a note with their response instead."+ />+ </span>+ </FieldDescription>) : null}- </Setting>+ </Field>)}/>- </SettingsGroup>+ </FieldGroup></CardContent>{children}</Card>diff --git a/packages/ui/src/field.tsx b/packages/ui/src/field.tsxindex 76d4e0369..3b6a3e718 100644--- a/packages/ui/src/field.tsx+++ b/packages/ui/src/field.tsx@@ -38,14 +38,30 @@ function FieldLegend({);}-function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {+const fieldGroupVariants = cva(+ "group/field-group @container/field-group flex w-full flex-col data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",+ {+ variants: {+ variant: {+ default: "gap-5",+ // Spacing comes from per-child padding instead of gap so the+ // divider sits centered between rows rather than hugging the next.+ divided: "gap-0 divide-y *:not-first:pt-4 *:not-last:pb-4",+ },+ },+ defaultVariants: { variant: "default" },+ },+);++function FieldGroup({+ className,+ variant = "default",+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof fieldGroupVariants>) {return (<divdata-slot="field-group"- className={cn(- "group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",- className,- )}+ className={cn(fieldGroupVariants({ variant }), className)}{...props}/>);diff --git a/packages/ui/src/switch.tsx b/packages/ui/src/switch.tsxindex 8f76d1add..ff70d8fdb 100644--- a/packages/ui/src/switch.tsx+++ b/packages/ui/src/switch.tsx@@ -13,7 +13,14 @@ function Switch({icon?: React.ReactNode;}) {return (+ // Rendered as a native <button> (Base UI defaults to a span) so the+ // switch is a labelable element: with nativeButton, a caller-supplied+ // `id` lands on it and `<Label htmlFor>` both names and activates it.+ // Base UI's default reserves the id for the hidden checkbox, which is+ // excluded from the accessibility tree, leaving the switch nameless.<SwitchPrimitive.Root+ render={<button type="button" />}+ nativeButtondata-slot="switch"className={cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full p-0.5 ring-1 ring-button-outline ring-inset transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 data-disabled:cursor-not-allowed data-checked:bg-primary data-unchecked:bg-muted data-disabled:opacity-50",