Files
Danny White 73c9dbfa52 fix(studio): standardise custom icon weight (#48478)
## What kind of change does this PR introduce?

Bug fix and internal tooling update. Resolves FE-3472.

## What is the current behavior?

Custom Studio icons use inconsistent source stroke widths, and some
child-level styling prevents component props from overriding them. Mixed
custom and Lucide icon sets can therefore appear uneven.

## What is the new behavior?

Custom stroke icons use a root-level `stroke-width="1.5"`; fill-only
logos use `stroke="none"`. The build validates that contract and
regenerated components preserve existing exports and props.

Studio applies the same `1.5` weight across Reports categories and uses
one shared destination icon mapping in the replication selector,
destination rows and diagram.

| Before | After |
| --- | --- |
| <img width="418" height="516" alt="56398"
src="https://github.com/user-attachments/assets/6afa7042-e6be-40e7-9911-af2f61238c9d"
/> | <img width="390" height="550" alt="CleanShot 2026-07-30 at 17 12
37@2x"
src="https://github.com/user-attachments/assets/870f49cf-c8fa-40db-8be8-2eb5f264ff4a"
/> |
| <img width="510" height="734" alt="CleanShot 2026-07-30 at 17 19
28@2x"
src="https://github.com/user-attachments/assets/a5b2c088-dcd2-4907-976b-5820794d06e3"
/> | <img width="554" height="742" alt="CleanShot 2026-07-30 at 17 16
06@2x"
src="https://github.com/user-attachments/assets/ed3a77c4-5d94-4ca7-b9e4-1403b725a981"
/> |


## Testing

At 100% zoom, compare custom and Lucide icon weight in:

- Reports: **Add your first chart** and **Add block**
- Database > Replication: the destination selector, destination rows and
replication diagram
- Command menu (`⌘K`): **Search Database Tables**, **Search RLS
Policies**, **Search Edge Functions** and **Search Storage**
- Authentication > Users: right-click a user row and compare the
context-menu icons
- Database > Schema Visualizer: open a table node overflow menu
- A paused project: **Export your data > Download backups**

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added consistent destination icons across replication panels, rows,
and diagrams.
  * Updated instance health and metric icons for clearer identification.
* Standardized icon stroke weight and reduced default icon stroke
thickness.

* **Documentation**
* Clarified custom icon requirements, default properties, and validation
guidance.

* **Bug Fixes**
* Improved consistency of icon rendering across replication destinations
and reports.

* **Tests**
* Added coverage for icon SVG validation and replication destination
icon rendering.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-03 17:48:50 +10:00

165 lines
6.2 KiB
TypeScript

import { Handle, Position } from '@xyflow/react'
import { useParams } from 'common'
import { PropsWithChildren, useMemo } from 'react'
import { AWS_REGIONS } from 'shared-data'
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { DestinationIcon } from '../DestinationIcon'
import { getStatusName } from '../Pipeline.utils'
import { getStatusLabel } from '../ReadReplicas/ReadReplicas.utils'
import { STATUS_REFRESH_FREQUENCY_MS } from '../Replication.constants'
import { getReplicationDestinationType } from './Nodes.utils'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { formatDatabaseID } from '@/data/read-replicas/replicas.utils'
import { useReplicationDestinationsQuery } from '@/data/replication/destinations-query'
import { useReplicationPipelineStatusQuery } from '@/data/replication/pipeline-status-query'
import { useReplicationPipelinesQuery } from '@/data/replication/pipelines-query'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { BASE_PATH } from '@/lib/constants'
export const NODE_WIDTH = 480
const NodeContainer = ({ className, children }: PropsWithChildren<{ className?: string }>) => {
return (
<div
style={{ width: NODE_WIDTH / 2 + 55 }}
className={cn(
'flex items-start justify-between p-3 rounded-sm bg-surface-100 border border-default',
className
)}
>
{children}
</div>
)
}
export const PrimaryDatabaseNode = () => {
const { ref: projectRef } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: databases = [] } = useReadReplicasQuery({ projectRef })
const hasReadReplicas = databases.some((x) => x.identifier !== projectRef)
const { data: destinationsData } = useReplicationDestinationsQuery({ projectRef })
const hasDestinations = (destinationsData?.destinations ?? []).length > 0
const region = Object.values(AWS_REGIONS).find((x) => x.code === project?.region)
const hasReplication = hasReadReplicas || hasDestinations
return (
<NodeContainer>
<div className="text-sm flex flex-col gap-y-0.5">
<p>Primary Database</p>
<p className="text-foreground-light">{region?.displayName}</p>
<p className="text-foreground-light">{region?.code}</p>
</div>
{!!project && (
<img
alt="region icon"
className="w-8 rounded-xs mt-0.5"
src={`${BASE_PATH}/img/regions/${project?.region}.svg`}
/>
)}
<Handle
type="source"
position={Position.Right}
className={hasReplication ? 'opacity-25' : 'opacity-0'}
/>
</NodeContainer>
)
}
export const ReplicationNode = ({ id }: { id: string }) => {
const { ref: projectRef } = useParams()
const { data: destinationsData } = useReplicationDestinationsQuery({ projectRef })
const destination = (destinationsData?.destinations ?? []).find((x) => x.id.toString() === id)
const { data: pipelinesData } = useReplicationPipelinesQuery({
projectRef,
})
const pipeline = (pipelinesData?.pipelines ?? []).find((x) => x.destination_id.toString() === id)
const { data: pipelineStatusData } = useReplicationPipelineStatusQuery(
{ projectRef, pipelineId: pipeline?.id },
{ refetchInterval: STATUS_REFRESH_FREQUENCY_MS }
)
const statusName = getStatusName(pipelineStatusData?.status)
const type = getReplicationDestinationType(destination?.config)
return (
<NodeContainer className="justify-start gap-x-3">
{type ? <DestinationIcon type={type} size={20} className="text-foreground-light" /> : null}
<div className="text-sm flex flex-col gap-y-0.5">
<div className="flex items-center">
<p>{type}</p>
{(statusName === 'started' || statusName === 'failed') && (
<Tooltip>
<TooltipTrigger>
<div className="w-6 h-full flex items-center justify-center">
<div
className={cn(
'w-2 h-2 rounded-full',
statusName === 'started' ? 'bg-brand' : 'bg-destructive'
)}
/>
</div>
</TooltipTrigger>
<TooltipContent side="bottom" className="capitalize">
{statusName}
</TooltipContent>
</Tooltip>
)}
</div>
<p className="text-foreground-light">{destination?.name}</p>
<p className="text-foreground-light">ID: {destination?.id}</p>
</div>
<Handle type="target" position={Position.Left} className="opacity-25" />
</NodeContainer>
)
}
export const ReadReplicaNode = ({ id }: { id: string }) => {
const { ref: projectRef } = useParams()
const { data: databases = [] } = useReadReplicasQuery({ projectRef })
const database = databases.find((x) => x.identifier === id)
const region = Object.values(AWS_REGIONS).find((x) => x.code === database?.region)
const formattedId = formatDatabaseID(database?.identifier ?? '')
const statusLabel = useMemo(
() => getStatusLabel({ status: database?.status }),
[database?.status]
)
return (
<NodeContainer className="justify-start gap-x-3">
<DestinationIcon type="Read Replica" size={20} className="text-foreground-light" />
<div className="flex flex-col gap-y-0.5">
<div className="flex items-center">
<p className="text-sm">Read Replica</p>
<Tooltip>
<TooltipTrigger>
<div className="w-6 h-full flex items-center justify-center">
<div
className={cn(
'w-2 h-2 rounded-full',
database?.status === 'ACTIVE_HEALTHY' ? 'bg-brand' : 'bg-selection'
)}
/>
</div>
</TooltipTrigger>
<TooltipContent side="bottom">{statusLabel}</TooltipContent>
</Tooltip>
</div>
<p className="text-sm text-foreground-light">{region?.displayName}</p>
<div className="flex gap-x-2 items-center text-sm text-foreground-light">
<span>ID: {formattedId}</span>
<span>•</span>
<span>{region?.code}</span>
</div>
</div>
<Handle type="target" position={Position.Left} className="opacity-25" />
</NodeContainer>
)
}