Files
Danny White a31ca2bad0 fix(ui): make brand text readable across themes (#49871)
## What kind of change does this PR introduce?

Bug fix and design-system update. Resolves DEPR-316.

Follow-up rename (`text-brand` → `text-primary`) is in a dedicated PR
(https://github.com/supabase/supabase/pull/50564) stacked on this one.

## What is the current behavior?

`text-brand` resolves to the canonical bright brand green in places that
need readable text, which fails WCAG AA on light surfaces. A separate
`text-brand-display` token adds another green for large type.

## What is the new behavior?

- `text-brand` maps to accessible `--primary` (light mode darkened to
meet ~4.5:1 AA)
- `--hue` / `--primary-hue` aligned to 157.5
- `text-brand-display` removed; former display callsites use
`text-brand`
- Bright fills/borders stay on `brand-default`
- Design-system colour and typography docs updated

| Before | After |
| --- | --- |
| <img width="514" height="112" alt="CleanShot 2026-09-02 at 11 13
09@2x"
src="https://github.com/user-attachments/assets/4e0138a9-a32d-4e4c-a426-90736706e1e7"
/> | <img width="512" height="138" alt="CleanShot 2026-09-21 at 11 42
05@2x"
src="https://github.com/user-attachments/assets/164cc5b1-a0c5-4e93-95f1-80016641a114"
/> |
| <img width="864" height="266" alt="CleanShot 2026-09-02 at 11 13
53@2x"
src="https://github.com/user-attachments/assets/3c1ca53f-bf9e-431e-bc15-816b4a275b8e"
/> | <img width="882" height="248" alt="CleanShot 2026-09-21 at 11 41
37@2x"
src="https://github.com/user-attachments/assets/24828e7b-ed6b-44cb-b9dc-becc3398bdfc"
/> |
| <img width="782" height="692" alt="CleanShot 2026-09-02 at 11 16
30@2x"
src="https://github.com/user-attachments/assets/fc871977-77bc-47fb-9e0e-9284e0ecd5cc"
/> | <img width="730" height="690" alt="CleanShot 2026-09-21 at 11 42
52@2x"
src="https://github.com/user-attachments/assets/bf479515-d5f9-471e-b82d-f097c0f4b56c"
/> |
| <img width="480" height="306" alt="CleanShot 2026-09-02 at 11 18
53@2x"
src="https://github.com/user-attachments/assets/03f341f4-f02e-44f8-a2b2-8c31670d0427"
/> | <img width="470" height="300" alt="CleanShot 2026-09-21 at 11 43
19@2x"
src="https://github.com/user-attachments/assets/9df18217-d5e6-48b8-ba0b-579d2664b94b"
/> |
| <img width="960" height="300" alt="CleanShot 2026-09-02 at 11 32
04@2x"
src="https://github.com/user-attachments/assets/6b1d9373-7a71-4247-81ff-26441604b09d"
/> | <img width="980" height="306" alt="CleanShot 2026-09-21 at 11 44
13@2x"
src="https://github.com/user-attachments/assets/41ad4784-02ec-4b29-b860-32af9fa79aa8"
/> |
| <img width="924" height="214" alt="CleanShot 2026-09-02 at 11 34
44@2x"
src="https://github.com/user-attachments/assets/1de661fe-c7b6-499b-a94f-e4737436ec79"
/> | <img width="752" height="162" alt="CleanShot 2026-09-21 at 11 44
56@2x"
src="https://github.com/user-attachments/assets/1811890f-0660-4445-84e9-447720954fa1"
/> |

## To test

Test each callsite **in light mode** (dark mode is largely unchanged).

### WWW

-
[Homepage](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/):
“Scale to millions” uses readable brand text (display token is gone)
-
[Careers](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/careers):
small “Careers” eyebrow readable; green dividers stay bright
`brand-default`
-
[Contact](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/contact-us):
email / policy links use readable brand text
-
[Regions](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/regions):
“Ask about early access to BYOC” readable

### Docs

- [Docs
homepage](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs):
“DOCS” wordmark and resource links readable
- [Database
overview](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/guides/database/overview):
nav / footer brand links readable
- [JavaScript
reference](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/reference/javascript/introduction):
active sidebar treatment readable

### Design system

-
[Typography](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/typography):
documents `text-brand` only (no display)
- [Colour
usage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/color-usage):
`text-brand` vs `bg-brand-default`
- [Design-system
homepage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/):
brand text examples across themes

### Studio

- [Auth
providers](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/auth/providers):
enabled provider badge text readable; status dot stays bright
- [Database
policies](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/database/policies?new=true):
template hover text more legible
- [Database
connections](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/observability/connections):
“Live” status readable; animated dot stays bright green

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-09-22 10:07:28 +10:00

392 lines
15 KiB
TypeScript

import { Handle, Node, NodeProps, Position } from '@xyflow/react'
import { useParams } from 'common'
import dayjs from 'dayjs'
import { Database, DatabaseBackup, HelpCircle, Loader2, MoreVertical } from 'lucide-react'
import Link from 'next/link'
import { parseAsBoolean, parseAsString, useQueryStates } from 'nuqs'
import { toast } from 'sonner'
import {
Badge,
Button,
cn,
copyToClipboard,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import { ComputeMetricsFooter } from './ComputeMetricsFooter'
import {
ERROR_STATES,
INIT_PROGRESS,
LoadBalancerData,
NODE_SEP,
NODE_WIDTH,
PrimaryNodeData,
REGION_NODE_HEIGHT,
ReplicaNodeData,
} from './InstanceConfiguration.constants'
import { formatSeconds } from './InstanceConfiguration.utils'
import { getReadReplicaPath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
import { REPLICA_STATUS } from '@/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicas.constants'
import { RegionFlag } from '@/components/ui/RegionFlag'
import { SparkBar } from '@/components/ui/SparkBar'
import {
DatabaseInitEstimations,
ReplicaInitializationStatus,
useReadReplicasStatusesQuery,
} from '@/data/read-replicas/replicas-status-query'
import { formatDatabaseID } from '@/data/read-replicas/replicas.utils'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
export const LoadBalancerNode = ({ data }: NodeProps<Node<LoadBalancerData>>) => {
const { ref } = useParams()
const { numDatabases } = data
return (
<>
<div className="flex flex-col rounded-sm bg-surface-100 border border-default">
<div
className="flex items-start justify-between p-3 gap-x-4"
style={{ width: NODE_WIDTH / 2 - 10 }}
>
<div className="flex gap-x-3">
<div className="min-w-8 h-8 bg-blue-600 border border-blue-800 rounded-md flex items-center justify-center">
<Database size={16} />
</div>
<div className="flex flex-col gap-y-0.5">
<p className="text-sm">API Load Balancer</p>
<p className="text-sm text-foreground-light">
Distributes incoming API requests across{' '}
<span className="text-foreground">{numDatabases} databases</span>
</p>
</div>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="text" icon={<MoreVertical />} className="px-1" />
</DropdownMenuTrigger>
<DropdownMenuContent className="w-40" side="bottom" align="end">
<DropdownMenuItem asChild className="gap-x-2">
<Link href={`/project/${ref}/integrations/data_api/overview?source=load-balancer`}>
View API URL
</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<Handle type="source" position={Position.Bottom} style={{ background: 'transparent' }} />
</>
)
}
export const PrimaryNode = ({ data }: NodeProps<Node<PrimaryNodeData>>) => {
// [Joshen] Just FYI Handles cannot be conditionally rendered
const { region, computeSize, numReplicas, numRegions, hasLoadBalancer } = data
const { projectHomepageShowInstanceSize } = useIsFeatureEnabled([
'project_homepage:show_instance_size',
])
return (
<>
<Handle
type="target"
position={Position.Top}
className={!hasLoadBalancer ? 'opacity-0' : ''}
style={{ background: 'transparent' }}
/>
<div className="flex flex-col rounded-sm bg-surface-100 border border-default">
<div
className="flex items-start justify-between p-3"
style={{ width: NODE_WIDTH / 2 - 10 }}
>
<div className="flex gap-x-3">
<div className="w-8 h-8 bg-brand-500 border border-brand-600 rounded-md flex items-center justify-center">
<Database size={16} />
</div>
<div className="flex flex-col gap-y-0.5">
<p className="text-sm">Primary Database</p>
<p className="flex items-center gap-x-1">
<span className="text-sm text-foreground-light">{region.name}</span>
</p>
<p className="flex items-center gap-x-1">
<Tooltip>
<TooltipTrigger asChild>
<span
className="text-sm transition text-foreground-light hover:text-foreground"
onClick={async () =>
await copyToClipboard(region.region, () => toast('Copied project region'))
}
>
{region.region}
</span>
</TooltipTrigger>
<TooltipContent side="bottom">Click to copy</TooltipContent>
</Tooltip>
{projectHomepageShowInstanceSize && (
<>
<span className="text-sm text-foreground-lighter">·</span>
<span className="text-sm text-foreground-light">{computeSize}</span>
</>
)}
</p>
</div>
</div>
<RegionFlag className="mt-0.5 w-8" region={region.region} />
</div>
{numReplicas > 0 && (
<div className="border-t p-3 py-2">
<p className="text-sm text-foreground-light">
<span className="text-foreground">
{numReplicas} replica{numReplicas > 1 ? 's' : ''}
</span>{' '}
deployed across{' '}
<span className="text-foreground">
{numRegions} region{numRegions > 1 ? 's' : ''}
</span>
</p>
</div>
)}
<ComputeMetricsFooter />
</div>
<Handle
type="source"
position={Position.Bottom}
className={numReplicas === 0 ? 'opacity-0' : ''}
style={{ background: 'transparent' }}
/>
</>
)
}
export const ReplicaNode = ({ data }: NodeProps<Node<ReplicaNodeData>>) => {
const { ref } = useParams()
const { id, region, computeSize, status, inserted_at } = data
const { projectHomepageShowInstanceSize } = useIsFeatureEnabled([
'project_homepage:show_instance_size',
])
const state = useDatabaseSelectorStateSnapshot()
const [, setConnect] = useQueryStates({
showConnect: parseAsBoolean.withDefault(false),
source: parseAsString,
})
const { data: databaseStatuses } = useReadReplicasStatusesQuery({ projectRef: ref })
const { replicaInitializationStatus } =
(databaseStatuses ?? []).find((db) => db.identifier === id) || {}
const {
status: initStatus,
progress,
estimations,
error,
} = (replicaInitializationStatus as {
status?: string
progress?: string
estimations?: DatabaseInitEstimations
error?: string
}) ?? { status: undefined, progress: undefined, estimations: undefined, error: undefined }
const created = dayjs(inserted_at).format('DD MMM YYYY')
const stage = progress !== undefined ? Number(progress.split('_')[0]) : 0
const stagePercent = stage / (Object.keys(INIT_PROGRESS).length - 1)
const isInTransition =
(
[
REPLICA_STATUS.UNKNOWN,
REPLICA_STATUS.COMING_UP,
REPLICA_STATUS.GOING_DOWN,
REPLICA_STATUS.RESTORING,
REPLICA_STATUS.RESTARTING,
REPLICA_STATUS.RESIZING,
REPLICA_STATUS.INIT_READ_REPLICA,
] as string[]
).includes(status) || initStatus === ReplicaInitializationStatus.InProgress
return (
<>
<Handle type="target" position={Position.Top} style={{ background: 'transparent' }} />
<div
className="flex justify-between items-start rounded-sm bg-surface-100 border border-default p-3"
style={{ width: NODE_WIDTH / 2 - 10 }}
>
<div className="flex gap-x-3">
<div
className={cn(
'w-8 h-8 border rounded-md flex items-center justify-center',
status === REPLICA_STATUS.ACTIVE_HEALTHY &&
initStatus === ReplicaInitializationStatus.Completed
? 'bg-brand-400 border-brand-500'
: 'bg-surface-100 border-foreground/20'
)}
>
{isInTransition ? (
<Loader2 className="animate-spin" size={16} />
) : (
<DatabaseBackup size={16} />
)}
</div>
<div className="flex flex-col gap-y-0.5">
<div className="flex items-center gap-x-2">
<p className="text-sm truncate">
Replica {id.length > 0 && `(ID: ${formatDatabaseID(id)})`}
</p>
{initStatus === ReplicaInitializationStatus.InProgress ||
status === REPLICA_STATUS.COMING_UP ||
status === REPLICA_STATUS.UNKNOWN ||
status === REPLICA_STATUS.INIT_READ_REPLICA ? (
<Badge>Coming up</Badge>
) : initStatus === ReplicaInitializationStatus.Failed ||
status === REPLICA_STATUS.INIT_READ_REPLICA_FAILED ? (
<>
<Badge variant="destructive">Init failed</Badge>
<Tooltip>
<TooltipTrigger>
<HelpCircle size={16} />
</TooltipTrigger>
<TooltipContent
side="bottom"
align="end"
alignOffset={-70}
className="w-60 text-center"
>
Replica failed to initialize. Please drop this replica and spin up a new one.
</TooltipContent>
</Tooltip>
</>
) : status === REPLICA_STATUS.GOING_DOWN ? (
<Badge>Going down</Badge>
) : status === REPLICA_STATUS.RESTARTING ? (
<Badge>Restarting</Badge>
) : status === REPLICA_STATUS.RESIZING ? (
<Badge>Resizing</Badge>
) : status === REPLICA_STATUS.ACTIVE_HEALTHY ? (
<Badge variant="success">Healthy</Badge>
) : (
<Badge variant="warning">Unhealthy</Badge>
)}
</div>
<div className="my-0.5">
<p className="text-sm text-foreground-light">{region.name}</p>
<p className="flex text-sm text-foreground-light items-center gap-x-1">
<Tooltip>
<TooltipTrigger asChild>
<span
className="text-sm transition text-foreground-light hover:text-foreground"
onClick={async () =>
await copyToClipboard(region.region, () => toast('Copied replica region'))
}
>
{region.region}
</span>
</TooltipTrigger>
<TooltipContent side="bottom">Click to copy</TooltipContent>
</Tooltip>
{projectHomepageShowInstanceSize && !!computeSize && (
<>
<span className="text-foreground-lighter">·</span>
<span>{computeSize}</span>
</>
)}
</p>
</div>
{initStatus === ReplicaInitializationStatus.InProgress && progress !== undefined ? (
<Tooltip>
<TooltipTrigger asChild>
<div className="w-56">
<SparkBar
labelBottom={INIT_PROGRESS[progress as keyof typeof INIT_PROGRESS]}
labelBottomClass="text-xs normal-nums! text-foreground-light"
type="horizontal"
value={stagePercent * 100}
max={100}
barClass="bg-brand-default"
/>
</div>
</TooltipTrigger>
{estimations !== undefined && (
<TooltipContent asChild side="bottom">
<div className="w-56">
<p className="text-foreground-light mb-0.5">Duration estimates:</p>
{estimations.baseBackupDownloadEstimateSeconds !== undefined && (
<p>
Base backup download:{' '}
{formatSeconds(estimations.baseBackupDownloadEstimateSeconds)}
</p>
)}
{estimations.walArchiveReplayEstimateSeconds !== undefined && (
<p>
WAL archive replay:{' '}
{formatSeconds(estimations.walArchiveReplayEstimateSeconds)}
</p>
)}
</div>
</TooltipContent>
)}
</Tooltip>
) : error !== undefined ? (
<p className="text-sm text-foreground-light">
Error: {ERROR_STATES[error as keyof typeof ERROR_STATES]}
</p>
) : (
<p className="text-sm text-foreground-light">
Created:{' '}
<TimestampInfo className="text-sm" utcTimestamp={inserted_at} label={created} />
</p>
)}
</div>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="text" icon={<MoreVertical />} className="px-1" />
</DropdownMenuTrigger>
<DropdownMenuContent className="w-40" side="bottom" align="end">
<DropdownMenuItem
className="gap-x-2"
onClick={() => {
setConnect({ showConnect: true, source: id })
state.setSelectedDatabaseId(id)
}}
>
View connection string
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem className="gap-x-2" asChild>
<Link href={getReadReplicaPath(ref, id)}>Manage replica</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</>
)
}
export const RegionNode = ({ data }: any) => {
const { region, numReplicas } = data
const regionNodeWidth =
20 + (NODE_WIDTH / 2 - 10) * numReplicas + (numReplicas - 1) * (NODE_SEP + 10)
return (
<div
className="relative flex justify-between rounded-sm bg-black/10 border border-default border-white/10 border-2 p-3"
style={{ width: regionNodeWidth, height: REGION_NODE_HEIGHT }}
>
<div className="absolute bottom-2 flex items-center justify-between gap-x-2">
<RegionFlag className="w-5" region={region.region} />
<p className="text-sm">{region.name}</p>
</div>
</div>
)
}