From 813658a3d4deb02499c8ee46000f61c8d201d753 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 29 Mar 2025 13:00:24 -0500 Subject: [PATCH] Offer matte background color configuration --- app/layout.tsx | 2 ++ src/admin/AdminAppConfigurationClient.tsx | 24 ++++++++++++++++++++--- src/app/ThemeColors.tsx | 14 +++++++++++++ src/app/config.ts | 6 ++++++ src/components/EnvVar.tsx | 3 +++ src/photo/PhotoLarge.tsx | 14 +++++++++++-- 6 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 src/app/ThemeColors.tsx diff --git a/app/layout.tsx b/app/layout.tsx index 7a6bf424..6f933459 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -23,6 +23,7 @@ import ShareModals from '@/share/ShareModals'; import AdminUploadPanel from '@/admin/upload/AdminUploadPanel'; import { revalidatePath } from 'next/cache'; import RecipeModal from '@/recipe/RecipeModal'; +import ThemeColors from '@/app/ThemeColors'; import '../tailwind.css'; @@ -79,6 +80,7 @@ export default function RootLayout({ '3xl:flex flex-col items-center', )}> +
- {variables.map(envVar => - )} + {variables.map(variable => + )}
; const renderSubStatus = ( @@ -478,7 +480,23 @@ export default function AdminAppConfigurationClient({ Set environment variable to {'"1"'} to constrain the size {' '} of each photo, and display a surrounding border: - {renderEnvVars(['NEXT_PUBLIC_MATTE_PHOTOS'])} +
+ + } + /> + } + /> +
+ {MATTE_COLOR && } + {MATTE_COLOR_DARK && } + ); +} diff --git a/src/app/config.ts b/src/app/config.ts index 534314a8..084e4581 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -232,6 +232,10 @@ export const DEFAULT_THEME = : 'system'; export const MATTE_PHOTOS = process.env.NEXT_PUBLIC_MATTE_PHOTOS === '1'; +export const MATTE_COLOR = + process.env.NEXT_PUBLIC_MATTE_COLOR; +export const MATTE_COLOR_DARK = + process.env.NEXT_PUBLIC_MATTE_COLOR_DARK; // DISPLAY @@ -350,6 +354,8 @@ export const APP_CONFIGURATION = { hasDefaultTheme: Boolean(process.env.NEXT_PUBLIC_DEFAULT_THEME), defaultTheme: DEFAULT_THEME, arePhotosMatted: MATTE_PHOTOS, + matteColor: MATTE_COLOR, + matteColorDark: MATTE_COLOR_DARK, // Display hasCategoryVisibility: Boolean(process.env.NEXT_PUBLIC_CATEGORY_VISIBILITY), diff --git a/src/components/EnvVar.tsx b/src/components/EnvVar.tsx index 44bd1158..484e0c5e 100644 --- a/src/components/EnvVar.tsx +++ b/src/components/EnvVar.tsx @@ -5,12 +5,14 @@ import CopyButton from './CopyButton'; export default function EnvVar({ variable, value, + accessory, includeCopyButton = true, trailingContent, className, }: { variable: string, value?: string, + accessory?: ReactNode, includeCopyButton?: boolean, trailingContent?: ReactNode, className?: string, @@ -33,6 +35,7 @@ export default function EnvVar({ )}> {variable}{value && ` = ${value}`} + {accessory} {includeCopyButton && ; - const largePhotoContainerClassName = clsx(arePhotosMatted && - 'flex items-center justify-center aspect-3/2 bg-gray-100', + const largePhotoContainerClassName = clsx( + arePhotosMatted && 'flex items-center justify-center aspect-3/2', + // Matte theme colors defined in root layout + arePhotosMatted && (MATTE_COLOR + ? 'bg-(--matte-bg)' + : 'bg-gray-100'), + arePhotosMatted && (MATTE_COLOR_DARK + ? 'dark:bg-(--matte-bg-dark)' + // Only specify dark background when MATTE_COLOR is not configured + : !MATTE_COLOR && 'dark:bg-gray-700/35'), ); return (