Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Apply space branding to the new poll page (#2526)
Luke Vella2f11620a0fd3
diff --git a/apps/web/src/app/[locale]/(optional-space)/new/page.tsx b/apps/web/src/app/[locale]/(optional-space)/new/page.tsxindex 7ce8b2470..dafc5f53c 100644--- a/apps/web/src/app/[locale]/(optional-space)/new/page.tsx+++ b/apps/web/src/app/[locale]/(optional-space)/new/page.tsx@@ -1,3 +1,4 @@+import { prisma } from "@rallly/database";import {Breadcrumb,BreadcrumbItem,@@ -11,12 +12,50 @@ import type { Metadata } from "next";import Link from "next/link";import { CreatePoll } from "@/components/create-poll";import { UserDropdown } from "@/components/user-dropdown";+import { BrandStyle } from "@/features/branding/brand-style";+import { createSpaceDTO } from "@/features/space/data";import { Trans } from "@/i18n/client";import { getTranslation } from "@/i18n/server";+import { getSession } from "@/lib/auth";++const getActiveSpace = async () => {+ const session = await getSession();++ if (session?.user.isGuest || !session?.user.id) {+ return null;+ }++ const spaceMember = await prisma.spaceMember.findFirst({+ where: {+ userId: session?.user.id,+ },+ orderBy: {+ lastSelectedAt: "desc",+ },+ include: {+ space: true,+ },+ });++ return spaceMember?.space+ ? createSpaceDTO({ ...spaceMember.space, role: spaceMember.role })+ : null;+};++async function getPrimaryColor() {+ const space = await getActiveSpace();+ if (space) {+ return space.showBranding && space.primaryColor ? space.primaryColor : null;+ }+ return null;+}export default async function Page() {+ const primaryColor = await getPrimaryColor();+return (<div className="page-bg-gray-100 absolute inset-0 h-dvh overflow-auto dark:bg-gray-900">+ {primaryColor ? <BrandStyle primaryColor={primaryColor} /> : null}<div className="sticky top-0 z-20 border-b bg-gray-100/90 p-3 backdrop-blur-md sm:grid-cols-3 dark:bg-gray-900/90"><div className="mx-auto flex items-center justify-between gap-x-2"><div className="sm:flex-1">diff --git a/apps/web/src/app/[locale]/e/[id]/page.tsx b/apps/web/src/app/[locale]/e/[id]/page.tsxindex 0084d676f..b0df11512 100644--- a/apps/web/src/app/[locale]/e/[id]/page.tsx+++ b/apps/web/src/app/[locale]/e/[id]/page.tsx@@ -12,7 +12,7 @@ import LogoMarkGray from "@/assets/logo-mark-gray.svg";import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";import TruncatedLinkify from "@/components/poll/truncated-linkify";import { SessionRefresher } from "@/components/session-refresher";-import { BrandingStyle } from "@/features/branding/branding-style";+import { BrandStyle } from "@/features/branding/brand-style";import { formatLocationText } from "@/features/location/utils";import {EventCalendarCard,@@ -109,7 +109,7 @@ export default async function EventPage({><div className="page-bg-gray-50 absolute inset-0 h-dvh overflow-auto md:h-dvh md:items-center md:justify-center md:p-5 dark:bg-gray-900"><SessionRefresher />- {brandingColor ? <BrandingStyle primaryColor={brandingColor} /> : null}+ {brandingColor ? <BrandStyle primaryColor={brandingColor} /> : null}<header className="fixed top-0 right-0 left-0 z-10 flex justify-between p-4"><Link href="/"><LogoMarkGray className="size-8 text-muted-foreground" />diff --git a/apps/web/src/components/poll/poll-branding.tsx b/apps/web/src/components/poll/poll-branding.tsxindex 1c1921841..8923a0c14 100644--- a/apps/web/src/components/poll/poll-branding.tsx+++ b/apps/web/src/components/poll/poll-branding.tsx@@ -1,29 +1,12 @@"use client";import { usePoll } from "@/contexts/poll";-import { getPrimaryColorVars } from "@/features/branding/color";+import { BrandStyle } from "@/features/branding/brand-style";export function PollBrandingFromContext() {const poll = usePoll();if (!poll.space?.showBranding || !poll.space.primaryColor) {return null;}- return <PollBranding primaryColor={poll.space.primaryColor} />;-}--export function PollBranding({ primaryColor }: { primaryColor: string }) {- const primaryColorVars = getPrimaryColorVars(primaryColor);-- return (- <style>{`- .light {- --primary: ${primaryColorVars.light};- --primary-foreground: ${primaryColorVars.lightForeground};- }- .dark {- --primary: ${primaryColorVars.dark};- --primary-foreground: ${primaryColorVars.darkForeground};- }- `}</style>- );+ return <BrandStyle primaryColor={poll.space.primaryColor} />;}diff --git a/apps/web/src/features/branding/branding-style.tsx b/apps/web/src/features/branding/brand-style.tsxsimilarity index 84%rename from apps/web/src/features/branding/branding-style.tsxrename to apps/web/src/features/branding/brand-style.tsxindex b5ae6b34d..18c86557c 100644--- a/apps/web/src/features/branding/branding-style.tsx+++ b/apps/web/src/features/branding/brand-style.tsx@@ -1,6 +1,6 @@import { getPrimaryColorVars } from "@/features/branding/color";-export function BrandingStyle({ primaryColor }: { primaryColor: string }) {+export function BrandStyle({ primaryColor }: { primaryColor: string }) {const v = getPrimaryColorVars(primaryColor);return (<style>{`