🎨 refactor(badge): restore status-badge sizes and classic color scheme
- Restore StatusBadge sizes to h-5/text-xs (sm, md) and h-6/text-xs (lg). - Restore classic textColorMap coloring and status indicator dot. - Embed channel type icon directly inside StatusBadge as custom children. - Re-align status badge colors: danger for manual disabled, warning for auto disabled.
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ export function GroupBadge(props: GroupBadgeProps) {
|
|||||||
{badge}
|
{badge}
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'inline-flex h-5 items-center rounded-full px-2 font-mono text-xs leading-none font-medium tabular-nums',
|
'inline-flex h-5 items-center rounded-full px-1.5 font-mono text-xs leading-none font-medium tabular-nums',
|
||||||
getGroupRatioClassName(ratio)
|
getGroupRatioClassName(ratio)
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
+15
-30
@@ -74,34 +74,11 @@ export const textColorMap = {
|
|||||||
export type StatusVariant = keyof typeof dotColorMap
|
export type StatusVariant = keyof typeof dotColorMap
|
||||||
|
|
||||||
const sizeMap = {
|
const sizeMap = {
|
||||||
sm: 'h-5 gap-1 px-2 text-xs leading-none',
|
sm: 'h-5 gap-1 px-1.5 text-xs leading-none',
|
||||||
md: 'h-6 gap-1 px-2 text-xs leading-none',
|
md: 'h-5 gap-1 px-1.5 text-xs leading-none',
|
||||||
lg: 'h-7 gap-1.5 px-2.5 text-sm leading-none',
|
lg: 'h-6 gap-1.5 px-2 text-xs leading-none',
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
const badgeSurfaceMap = {
|
|
||||||
success: 'bg-success/10 text-success',
|
|
||||||
warning: 'bg-warning/10 text-warning',
|
|
||||||
danger: 'bg-destructive/10 text-destructive',
|
|
||||||
info: 'bg-info/10 text-info',
|
|
||||||
neutral: 'bg-muted text-muted-foreground',
|
|
||||||
purple: 'bg-chart-4/10 text-chart-4',
|
|
||||||
amber: 'bg-warning/10 text-warning',
|
|
||||||
blue: 'bg-chart-1/10 text-chart-1',
|
|
||||||
cyan: 'bg-chart-2/10 text-chart-2',
|
|
||||||
green: 'bg-success/10 text-success',
|
|
||||||
grey: 'bg-muted text-muted-foreground',
|
|
||||||
indigo: 'bg-chart-1/10 text-chart-1',
|
|
||||||
'light-blue': 'bg-info/10 text-info',
|
|
||||||
'light-green': 'bg-success/10 text-success',
|
|
||||||
lime: 'bg-chart-3/10 text-chart-3',
|
|
||||||
orange: 'bg-warning/10 text-warning',
|
|
||||||
pink: 'bg-chart-5/10 text-chart-5',
|
|
||||||
red: 'bg-destructive/10 text-destructive',
|
|
||||||
teal: 'bg-chart-2/10 text-chart-2',
|
|
||||||
violet: 'bg-chart-4/10 text-chart-4',
|
|
||||||
yellow: 'bg-warning/10 text-warning',
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export interface StatusBadgeProps extends Omit<
|
export interface StatusBadgeProps extends Omit<
|
||||||
React.HTMLAttributes<HTMLSpanElement>,
|
React.HTMLAttributes<HTMLSpanElement>,
|
||||||
@@ -127,7 +104,7 @@ export function StatusBadge({
|
|||||||
variant,
|
variant,
|
||||||
size = 'sm',
|
size = 'sm',
|
||||||
pulse = false,
|
pulse = false,
|
||||||
showDot = false,
|
showDot = true,
|
||||||
copyable = true,
|
copyable = true,
|
||||||
copyText,
|
copyText,
|
||||||
autoColor,
|
autoColor,
|
||||||
@@ -136,7 +113,6 @@ export function StatusBadge({
|
|||||||
...props
|
...props
|
||||||
}: StatusBadgeProps) {
|
}: StatusBadgeProps) {
|
||||||
const { copyToClipboard } = useCopyToClipboard()
|
const { copyToClipboard } = useCopyToClipboard()
|
||||||
void showDot
|
|
||||||
|
|
||||||
const computedVariant: StatusVariant = autoColor
|
const computedVariant: StatusVariant = autoColor
|
||||||
? (stringToColor(autoColor) as StatusVariant)
|
? (stringToColor(autoColor) as StatusVariant)
|
||||||
@@ -158,7 +134,7 @@ export function StatusBadge({
|
|||||||
className={cn(
|
className={cn(
|
||||||
'inline-flex w-fit max-w-full shrink-0 items-center rounded-full font-medium tracking-normal whitespace-nowrap transition-colors',
|
'inline-flex w-fit max-w-full shrink-0 items-center rounded-full font-medium tracking-normal whitespace-nowrap transition-colors',
|
||||||
sizeMap[size ?? 'sm'],
|
sizeMap[size ?? 'sm'],
|
||||||
badgeSurfaceMap[computedVariant],
|
textColorMap[computedVariant],
|
||||||
pulse && 'animate-pulse',
|
pulse && 'animate-pulse',
|
||||||
copyable &&
|
copyable &&
|
||||||
'cursor-copy hover:brightness-95 active:scale-95 dark:hover:brightness-110',
|
'cursor-copy hover:brightness-95 active:scale-95 dark:hover:brightness-110',
|
||||||
@@ -168,7 +144,16 @@ export function StatusBadge({
|
|||||||
title={copyable ? `Click to copy: ${copyText || label || ''}` : undefined}
|
title={copyable ? `Click to copy: ${copyText || label || ''}` : undefined}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{Icon && <Icon className='size-3 shrink-0' />}
|
{showDot && (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'inline-block size-1.5 shrink-0 rounded-full',
|
||||||
|
dotColorMap[computedVariant]
|
||||||
|
)}
|
||||||
|
aria-hidden='true'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{Icon && <Icon className='size-3.5 shrink-0' />}
|
||||||
{content}
|
{content}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ export function useChannelsColumns(): ColumnDef<Channel>[] {
|
|||||||
const typeNameKey = getChannelTypeLabel(type)
|
const typeNameKey = getChannelTypeLabel(type)
|
||||||
const typeName = t(typeNameKey)
|
const typeName = t(typeNameKey)
|
||||||
const iconName = getChannelTypeIcon(type)
|
const iconName = getChannelTypeIcon(type)
|
||||||
const icon = getLobeIcon(`${iconName}.Color`, 20)
|
const icon = getLobeIcon(`${iconName}.Color`, 14)
|
||||||
const channel = row.original as Channel
|
const channel = row.original as Channel
|
||||||
const isMultiKey = isMultiKeyChannel(channel)
|
const isMultiKey = isMultiKeyChannel(channel)
|
||||||
const multiKeyMode = channel.channel_info?.multi_key_mode ?? 'random'
|
const multiKeyMode = channel.channel_info?.multi_key_mode ?? 'random'
|
||||||
@@ -633,31 +633,32 @@ export function useChannelsColumns(): ColumnDef<Channel>[] {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<div className='flex items-center gap-1.5'>
|
{isMultiKey && (
|
||||||
{isMultiKey && (
|
<TooltipProvider delay={100}>
|
||||||
<TooltipProvider delay={100}>
|
<Tooltip>
|
||||||
<Tooltip>
|
<TooltipTrigger
|
||||||
<TooltipTrigger
|
render={
|
||||||
render={
|
<span className='border-border bg-muted text-primary inline-flex h-5 w-5 items-center justify-center rounded-md border shrink-0' />
|
||||||
<span className='border-border bg-muted text-primary inline-flex h-6 w-6 items-center justify-center rounded-md border' />
|
}
|
||||||
}
|
>
|
||||||
>
|
<MultiKeyModeIcon className='h-3 w-3' />
|
||||||
<MultiKeyModeIcon className='h-3.5 w-3.5' />
|
</TooltipTrigger>
|
||||||
</TooltipTrigger>
|
<TooltipContent side='top'>
|
||||||
<TooltipContent side='top'>
|
{multiKeyTooltip}
|
||||||
{multiKeyTooltip}
|
</TooltipContent>
|
||||||
</TooltipContent>
|
</Tooltip>
|
||||||
</Tooltip>
|
</TooltipProvider>
|
||||||
</TooltipProvider>
|
)}
|
||||||
)}
|
|
||||||
{icon}
|
|
||||||
</div>
|
|
||||||
<StatusBadge
|
<StatusBadge
|
||||||
label={typeName}
|
|
||||||
autoColor={typeName}
|
autoColor={typeName}
|
||||||
size='sm'
|
size='sm'
|
||||||
copyable={false}
|
copyable={false}
|
||||||
/>
|
showDot={false}
|
||||||
|
className='pl-1 gap-1'
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
<span className='truncate'>{typeName}</span>
|
||||||
|
</StatusBadge>
|
||||||
{isIonet && (
|
{isIonet && (
|
||||||
<TooltipProvider delay={100}>
|
<TooltipProvider delay={100}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
|
|||||||
+2
-2
@@ -137,11 +137,11 @@ export const CHANNEL_STATUS_CONFIG = {
|
|||||||
label: 'Enabled',
|
label: 'Enabled',
|
||||||
},
|
},
|
||||||
[CHANNEL_STATUS.MANUAL_DISABLED]: {
|
[CHANNEL_STATUS.MANUAL_DISABLED]: {
|
||||||
variant: 'neutral' as const,
|
variant: 'danger' as const,
|
||||||
label: 'Disabled',
|
label: 'Disabled',
|
||||||
},
|
},
|
||||||
[CHANNEL_STATUS.AUTO_DISABLED]: {
|
[CHANNEL_STATUS.AUTO_DISABLED]: {
|
||||||
variant: 'danger' as const,
|
variant: 'warning' as const,
|
||||||
label: 'Auto Disabled',
|
label: 'Auto Disabled',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user