mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 11:55:05 +03:00
## What kind of change does this PR introduce? Bug fix / design-system alignment for the legacy `Button` from `ui`. ## What is the current behavior? Omitting `variant` on the legacy `Button` falls back to brand-green `primary`. That makes accidental greens easy, and it is hard to spot the real main action on busy pages. ## What is the new behavior? - Legacy `Button` now defaults to neutral `default` - Intentional primary CTAs (create, save, submit, marketing CTAs, and matching `ButtonTooltip` usages) now set `variant="primary"` so their appearance is unchanged - Neutral actions that previously relied on the old fallback (cancel, close, back, dashboard nav, and similar) become grey/white - Design-system docs updated; regression tests cover the new default `Button_Shadcn_` is unchanged. It already uses its own CVA default. This is PR 1 of 2 in a stack. PR 2 drops now-redundant `variant="default"` props. ## To test Studio (http://localhost:8082): - `/sign-in`: Sign in stays green - Open a project → Database → Tables: New table stays green - Auth → Users → Invite: Invite user stays green; Cancel / dismiss controls stay neutral - Project Settings → General: edit a field so Cancel and Save appear. Cancel is neutral, Save is green Design system (http://localhost:3003): - Components → Button: default demo is neutral; primary demo is green; featured preview is the default variant Marketing (optional): - www header: Start your project stays green; logged-in Dashboard is neutral <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Style** - Buttons now default to a neutral style, while primary actions across Studio, documentation, marketing pages, forms, dialogs, and error states use prominent primary styling. - Updated button examples and previews clarify the distinction between default and primary variants. - Event registration now includes a directional arrow icon. - **Tests** - Added coverage confirming default button styling and explicit primary styling behave as expected. - Updated related test fixtures to use primary styling where appropriate. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
217 lines
7.5 KiB
TypeScript
217 lines
7.5 KiB
TypeScript
'use client'
|
|
|
|
import { useEvents } from '~/app/events/context'
|
|
import { formatHosts } from '~/lib/eventsUtils'
|
|
import { ArrowRightIcon, CalendarIcon, MapPinIcon, VideoIcon } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { Badge, Button } from 'ui'
|
|
|
|
export function EventBanner() {
|
|
const { isLoading, featuredEvent } = useEvents()
|
|
|
|
if (isLoading) {
|
|
return <EventBannerSkeleton />
|
|
}
|
|
|
|
if (!featuredEvent) return null
|
|
|
|
return (
|
|
<section className="flex flex-col gap-6 rounded-lg py-6">
|
|
<article className="flex flex-col md:flex-row md:items-stretch gap-8 lg:py-2">
|
|
<div className="flex flex-col gap-6 flex-1">
|
|
<div className="flex flex-col">
|
|
<div className="flex items-center gap-4">
|
|
<h2 className="text-2xl font-medium lg:line-clamp-2">{featuredEvent.title}</h2>
|
|
{featuredEvent.isSpeaking && (
|
|
<Badge variant="success" className="flex items-center gap-1 shrink-0">
|
|
Speaking
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
{featuredEvent.hosts.length > 0 && (
|
|
<p
|
|
className="text-lg font-medium text-foreground-light"
|
|
title={`Hosted by ${formatHosts(featuredEvent.hosts).fullList}`}
|
|
>
|
|
{formatHosts(featuredEvent.hosts).displayText}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
<p className="text-foreground-light line-clamp-3 lg:line-clamp-4">
|
|
{featuredEvent.description}
|
|
</p>
|
|
</div>
|
|
|
|
<div className="flex flex-col justify-between gap-8">
|
|
<div className="flex flex-row gap-6">
|
|
<DateWidget date={featuredEvent.date} endDate={featuredEvent.end_date} />
|
|
<LocationWidget
|
|
location={featuredEvent.location}
|
|
categories={featuredEvent.categories}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex items-center md:justify-end gap-2">
|
|
{featuredEvent.meetingLink && (
|
|
<Button variant="secondary" size="medium" asChild>
|
|
<Link href={featuredEvent.meetingLink} target="_blank" rel="noopener noreferrer">
|
|
Meet with us
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
{featuredEvent.link && (
|
|
<Button
|
|
variant="primary"
|
|
size="medium"
|
|
asChild
|
|
iconRight={<ArrowRightIcon size={14} />}
|
|
>
|
|
<Link
|
|
href={featuredEvent.link.href}
|
|
target={featuredEvent.link.target}
|
|
rel="noopener noreferrer"
|
|
>
|
|
Register
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
const DateWidget = ({ date, endDate }: { date: string; endDate?: string }) => {
|
|
const eventDate = new Date(date)
|
|
// Date-only Notion events are normalized to noon UTC (T12:00:00Z); detect them
|
|
// so we can display in UTC and suppress the fabricated time component.
|
|
const isDateOnly = date.endsWith('T12:00:00Z')
|
|
const tzOption = isDateOnly ? ({ timeZone: 'UTC' } as const) : {}
|
|
|
|
const formattedDate = eventDate.toLocaleDateString('en-US', {
|
|
weekday: 'long',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
...tzOption,
|
|
})
|
|
|
|
const currentYear = new Date().getFullYear()
|
|
const eventYear = isDateOnly ? parseInt(date.slice(0, 4), 10) : eventDate.getFullYear()
|
|
const formattedDateWithYear =
|
|
eventYear !== currentYear ? `${formattedDate}, ${eventYear}` : formattedDate
|
|
|
|
// Only show time for events that have a real time component
|
|
let timeDisplay: string | null = null
|
|
if (!isDateOnly) {
|
|
const startTime = eventDate.toLocaleTimeString('en-US', {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
})
|
|
|
|
if (endDate && !endDate.endsWith('T12:00:00Z')) {
|
|
const endEventDate = new Date(endDate)
|
|
const endTime = endEventDate.toLocaleTimeString('en-US', {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
})
|
|
timeDisplay = `${startTime} - ${endTime}`
|
|
} else {
|
|
timeDisplay = startTime
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex items-center gap-4">
|
|
<div className="bg-surface-100 w-10 h-10 flex items-center justify-center border rounded-md">
|
|
<CalendarIcon className="size-5" strokeWidth={1.5} />
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-0">
|
|
<p>{formattedDateWithYear}</p>
|
|
{timeDisplay && <p className="text-foreground-light text-sm">{timeDisplay}</p>}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const LocationWidget = ({ location, categories }: { location?: string; categories?: string[] }) => {
|
|
// Webinars have no physical location; show a camera icon and the format instead.
|
|
if (categories?.includes('webinar')) {
|
|
return (
|
|
<div className="flex items-center gap-4">
|
|
<div className="bg-surface-100 w-10 h-10 flex items-center justify-center border rounded-md">
|
|
<VideoIcon className="size-5" strokeWidth={1.5} />
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-0">
|
|
<p>Supabase Live</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const hasLocation = location && location.length > 0
|
|
const locationText = hasLocation ? location : 'Unknown'
|
|
|
|
return (
|
|
<div className="flex items-center gap-4">
|
|
<div className="bg-surface-100 w-10 h-10 flex items-center justify-center border rounded-md">
|
|
<MapPinIcon className="size-5" strokeWidth={1.5} />
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-0">
|
|
<p>Hosted at</p>
|
|
<p className="text-foreground-light text-sm">{locationText}</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const EventBannerSkeleton = () => {
|
|
return (
|
|
<section className="flex flex-col gap-6 rounded-lg p-6">
|
|
<article className="flex flex-col md:flex-row md:items-stretch gap-6 lg:py-2">
|
|
{/* Left: title + host + description */}
|
|
<div className="flex flex-col gap-6 flex-1">
|
|
<div className="flex flex-col gap-1.5">
|
|
<div className="h-8 bg-surface-200 rounded-sm animate-pulse w-3/4" />
|
|
<div className="h-5 bg-surface-200 rounded-sm animate-pulse w-1/2 mt-1" />
|
|
</div>
|
|
<div className="h-16 bg-surface-200 rounded-sm animate-pulse w-full" />
|
|
</div>
|
|
|
|
{/* Right: widgets top, button bottom */}
|
|
<div className="flex flex-col justify-between gap-6">
|
|
<div className="flex flex-row gap-6">
|
|
{/* Date Widget Skeleton */}
|
|
<div className="flex items-center gap-4">
|
|
<div className="bg-surface-200 w-10 h-10 rounded-md animate-pulse" />
|
|
<div className="flex flex-col gap-2">
|
|
<div className="h-4 w-32 bg-surface-200 rounded-sm animate-pulse" />
|
|
<div className="h-3 w-20 bg-surface-200 rounded-sm animate-pulse" />
|
|
</div>
|
|
</div>
|
|
{/* Location Widget Skeleton */}
|
|
<div className="flex items-center gap-4">
|
|
<div className="bg-surface-200 w-10 h-10 rounded-md animate-pulse" />
|
|
<div className="flex flex-col gap-2">
|
|
<div className="h-4 w-20 bg-surface-200 rounded-sm animate-pulse" />
|
|
<div className="h-3 w-24 bg-surface-200 rounded-sm animate-pulse" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Button Skeleton */}
|
|
<div className="flex justify-end">
|
|
<div className="h-9 w-24 bg-surface-200 rounded-sm animate-pulse" />
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</section>
|
|
)
|
|
}
|