From 1f2f7b6269c0d00538af4171e85c67dbbee75b5b Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Fri, 28 Aug 2026 01:20:12 -0400 Subject: [PATCH] feat(preferences): add background texture toggle --- src/app/(frontend)/account/actions.ts | 4 +- src/app/(frontend)/account/page.tsx | 37 ++++----- src/app/(frontend)/layout.tsx | 14 ++-- src/collections/users/Users.ts | 76 ++++++++++--------- .../frontend/account/PreferencesForm.tsx | 34 +++++++-- src/components/frontend/blocks/AppSidebar.tsx | 1 + ...11500_add_background_texture_preference.ts | 15 ++++ src/migrations/index.ts | 30 +++++--- src/payload-types.ts | 2 + tests/int/preferences-form.int.spec.ts | 2 + 10 files changed, 137 insertions(+), 78 deletions(-) create mode 100644 src/migrations/20260828_011500_add_background_texture_preference.ts diff --git a/src/app/(frontend)/account/actions.ts b/src/app/(frontend)/account/actions.ts index 5f9d519..4817b65 100644 --- a/src/app/(frontend)/account/actions.ts +++ b/src/app/(frontend)/account/actions.ts @@ -205,6 +205,7 @@ export async function updatePreferences(input: { mutedTypes: string[]; showCallsign: boolean; showVersionOverlay: boolean; + showBackgroundTexture: boolean; leadOrActual: "lead" | "actual"; discordEnabled: boolean; discordMutedTypes: string[]; @@ -221,7 +222,7 @@ export async function updatePreferences(input: { (MUTEABLE_NOTIFICATION_VALUES as readonly string[]).includes(t), ); - await payload.update({ + await payload.update({ collection: "users", id: userId, data: { @@ -230,6 +231,7 @@ export async function updatePreferences(input: { display: { showCallsign: input.showCallsign, showVersionOverlay: input.showVersionOverlay, + showBackgroundTexture: input.showBackgroundTexture, leadOrActual: input.leadOrActual, xpDisplayMini: input.xpDisplayMini, }, diff --git a/src/app/(frontend)/account/page.tsx b/src/app/(frontend)/account/page.tsx index 064e0db..75ebb67 100644 --- a/src/app/(frontend)/account/page.tsx +++ b/src/app/(frontend)/account/page.tsx @@ -81,24 +81,25 @@ export default async function AccountPage() { - - - Preferences - Control in-app notifications and display options. - - - - - + + + Preferences + Control in-app notifications and display options. + + + + + ); diff --git a/src/app/(frontend)/layout.tsx b/src/app/(frontend)/layout.tsx index fde806f..5d63d16 100644 --- a/src/app/(frontend)/layout.tsx +++ b/src/app/(frontend)/layout.tsx @@ -133,7 +133,13 @@ export default async function RootLayout(props: { children: React.ReactNode }) { preferences={user.preferences} className="border-r" /> - + {impersonating && } {children} @@ -156,11 +162,7 @@ export default async function RootLayout(props: { children: React.ReactNode }) { {user && } {isLogistics && } - + ); diff --git a/src/collections/users/Users.ts b/src/collections/users/Users.ts index 2080b50..6028b59 100644 --- a/src/collections/users/Users.ts +++ b/src/collections/users/Users.ts @@ -268,41 +268,47 @@ export const Users: CollectionConfig = { }, ], }, - { - name: "display", - label: "Display", - type: "group", - fields: [ - { - name: "showCallsign", - label: "Show callsign (username) instead of display name in the sidebar", - type: "checkbox", - defaultValue: false, - }, - { - name: "leadOrActual", - label: 'Use "Lead" or "Actual" when reviewing the unit roster', - type: "select", - options: [ - { label: "Lead", value: "lead" }, - { label: "Actual", value: "actual" }, - ], - defaultValue: "lead", - }, - { - name: "showVersionOverlay", - label: "Show version overlay at top of page", - type: "checkbox", - defaultValue: true, - }, - { - name: "xpDisplayMini", - label: "Use mini mode for XP display", - type: "checkbox", - defaultValue: false, - }, - ], - }, + { + name: "display", + label: "Display", + type: "group", + fields: [ + { + name: "showCallsign", + label: "Show callsign (username) instead of display name in the sidebar", + type: "checkbox", + defaultValue: false, + }, + { + name: "leadOrActual", + label: 'Use "Lead" or "Actual" when reviewing the unit roster', + type: "select", + options: [ + { label: "Lead", value: "lead" }, + { label: "Actual", value: "actual" }, + ], + defaultValue: "lead", + }, + { + name: "showVersionOverlay", + label: "Show version overlay at top of page", + type: "checkbox", + defaultValue: true, + }, + { + name: "xpDisplayMini", + label: "Use mini mode for XP display", + type: "checkbox", + defaultValue: false, + }, + { + name: "showBackgroundTexture", + label: "Show diagonal background texture", + type: "checkbox", + defaultValue: true, + }, + ], + }, { name: "discord", label: "Discord", diff --git a/src/components/frontend/account/PreferencesForm.tsx b/src/components/frontend/account/PreferencesForm.tsx index 505512e..e5233aa 100644 --- a/src/components/frontend/account/PreferencesForm.tsx +++ b/src/components/frontend/account/PreferencesForm.tsx @@ -17,6 +17,7 @@ interface PreferencesFormProps { readonly mutedTypes: readonly string[]; readonly showCallsign: boolean; readonly showVersionOverlay: boolean; + readonly showBackgroundTexture: boolean; readonly leadOrActual: "lead" | "actual"; readonly discordEnabled: boolean; readonly discordMutedTypes: readonly string[]; @@ -28,6 +29,7 @@ export function PreferencesForm({ mutedTypes: initialMutedTypes, showCallsign: initialShowCallsign, showVersionOverlay: initialShowVersionOverlay, + showBackgroundTexture: initialShowBackgroundTexture, leadOrActual: initialLeadOrActual, discordEnabled: initialDiscordEnabled, discordMutedTypes: initialDiscordMutedTypes, @@ -38,6 +40,7 @@ export function PreferencesForm({ const [mutedTypes, setMutedTypes] = useState(() => [...initialMutedTypes]); const [showCallsign, setShowCallsign] = useState(initialShowCallsign); const [showVersionOverlay, setShowVersionOverlay] = useState(initialShowVersionOverlay); + const [showBackgroundTexture, setShowBackgroundTexture] = useState(initialShowBackgroundTexture); const [leadOrActual, setLeadOrActual] = useState<"lead" | "actual">(initialLeadOrActual); const [discordEnabled, setDiscordEnabled] = useState(initialDiscordEnabled); const [discordMutedTypes, setDiscordMutedTypes] = useState(() => [ @@ -72,6 +75,7 @@ export function PreferencesForm({ mutedTypes, showCallsign, showVersionOverlay, + showBackgroundTexture, leadOrActual, discordEnabled, discordMutedTypes, @@ -104,10 +108,7 @@ export function PreferencesForm({ Choose what appears in the app shell and roster views. - -