Skip to content

Commit a6304e3

Browse files
committed
improvement(insights): brand-aligned, colorblind-validated chart palette
1 parent bf96b23 commit a6304e3

3 files changed

Lines changed: 35 additions & 13 deletions

File tree

‎apps/sim/ee/organization-usage/components/activity-summary.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ import {
77
ChartFrame,
88
ChartLegend,
99
type ChartLegendItem,
10+
cn,
1011
DashboardMetric,
1112
formatChartLatency,
1213
} from '@sim/emcn'
1314
import type { OrganizationActivitySummary } from '@/lib/api/contracts/organization-activity'
1415
import { SettingsSection } from '@/app/workspace/[workspaceId]/settings/components/settings-section/settings-section'
15-
import { USAGE_CHAT_COLOR } from '@/ee/organization-usage/constants'
16+
import {
17+
USAGE_CHAT_COLOR,
18+
USAGE_OTHER_COLOR,
19+
USAGE_PALETTE_CLASS,
20+
} from '@/ee/organization-usage/constants'
1621
import { useLegendHighlight } from '@/ee/organization-usage/hooks/use-legend-highlight'
1722
import { useOrganizationActivitySummary } from '@/hooks/queries/organization-activity'
1823
import type { OrganizationUsageWindowKey } from '@/hooks/queries/utils/organization-usage-keys'
@@ -21,12 +26,13 @@ const CHART_HEIGHT = 180
2126

2227
/**
2328
* Outcome layers, bottom-up. Failed is the status red and sits on the stack where a
24-
* spike reads at a glance; Other (cancelled, paused, unfinished) stays neutral.
29+
* spike reads at a glance; Other (cancelled, paused, unfinished) stays neutral, in a
30+
* gray whose lightness keeps it apart from the red for color-vision deficiency.
2531
*/
2632
const OUTCOMES = [
2733
{ id: 'completed', label: 'Completed', color: 'var(--brand-blue)' },
2834
{ id: 'failed', label: 'Failed', color: 'var(--text-error)' },
29-
{ id: 'other', label: 'Other', color: 'var(--text-muted)' },
35+
{ id: 'other', label: 'Other', color: USAGE_OTHER_COLOR },
3036
] as const
3137

3238
const OUTCOME_LEGEND: ChartLegendItem[] = [...OUTCOMES]
@@ -113,7 +119,7 @@ export function ActivitySummary({ summary, loading, error, onRetry }: ActivitySu
113119
const chartState = { loading, error: error ? "Couldn't load activity." : undefined, onRetry }
114120

115121
return (
116-
<div className='flex flex-col gap-5'>
122+
<div className={cn('flex flex-col gap-5', USAGE_PALETTE_CLASS)}>
117123
<div className='grid grid-cols-[repeat(auto-fit,minmax(min(120px,100%),1fr))] gap-4'>
118124
{metrics.map((metric) => (
119125
<DashboardMetric

‎apps/sim/ee/organization-usage/components/usage-credits.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@sim/emcn'
1414
import type { OrganizationUsageOverview } from '@/lib/api/contracts/organization-usage'
1515
import {
16+
USAGE_PALETTE_CLASS,
1617
USAGE_SOURCE_CATEGORIES,
1718
USAGE_SOURCE_CATEGORY,
1819
type UsageSourceCategoryId,
@@ -110,7 +111,9 @@ export function UsageCredits({
110111
const highlight = useLegendHighlight(legend.map((item) => item.id))
111112

112113
return (
113-
<div className={cn('flex flex-col gap-4', isPlaceholderData && 'opacity-50')}>
114+
<div
115+
className={cn('flex flex-col gap-4', USAGE_PALETTE_CLASS, isPlaceholderData && 'opacity-50')}
116+
>
114117
<div className='flex flex-col gap-1.5'>
115118
<div className='flex h-7 items-baseline gap-2 whitespace-nowrap'>
116119
<span className='text-[var(--text-body)] text-lg tabular-nums'>

‎apps/sim/ee/organization-usage/constants.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,39 @@ export const EXPANDED_ROW_COUNT = ORGANIZATION_USAGE_BREAKDOWN_MAX_LIMIT
9595
export const DEFAULT_USAGE_PRESET = '30d' as const
9696
export const DEFAULT_USAGE_TAB = USAGE_OVERVIEW_TAB
9797

98+
/**
99+
* The Insights chart palette, declared on each chart's root so a layer, its legend
100+
* dot, and its tooltip swatch resolve to one color. Each hue is its source's color
101+
* elsewhere in the app — Sim green for Chat, the Enrichment block's purple, the
102+
* Knowledge block's teal, the agent violet — stepped to the lightness a filled mark
103+
* needs in each mode; badge text tokens are too pale in dark mode to fill a bar.
104+
*/
105+
export const USAGE_PALETTE_CLASS =
106+
'[--usage-chat:#1f9d63] [--usage-enrichment:#c026d3] [--usage-knowledge:#0e9f9f] [--usage-agent:#6f3dfa] [--usage-other:var(--text-secondary)] dark:[--usage-chat:#2dac72] dark:[--usage-enrichment:#d946ef] dark:[--usage-agent:#8b5cf6] dark:[--usage-other:#8a8a8a]'
107+
98108
/** Sim Chat's color, shared by its credit layer and the chat-runs chart. */
99-
export const USAGE_CHAT_COLOR = 'var(--badge-orange-text)'
109+
export const USAGE_CHAT_COLOR = 'var(--usage-chat)'
110+
111+
/** The neutral remainder, shared by the credit and outcome stacks. */
112+
export const USAGE_OTHER_COLOR = 'var(--usage-other)'
100113

101114
/**
102115
* The credit chart's layers, bottom-up. Each one owns a fixed color, so a layer keeps
103116
* its color when a quieter period drops its neighbours — color follows the source,
104117
* never its rank.
105118
*
106119
* Five hues plus a neutral `Other`: the palette is validated for adjacent-pair
107-
* separation (including color-vision deficiency) in exactly this order, so reorder
108-
* or extend it only by re-running that validation. A sixth distinct source belongs
109-
* in `Other`, not in a generated hue.
120+
* separation (including color-vision deficiency) in both modes in exactly this order,
121+
* so reorder or extend it only by re-running that validation. A sixth distinct source
122+
* belongs in `Other`, not in a generated hue.
110123
*/
111124
export const USAGE_SOURCE_CATEGORIES = [
112125
{ id: 'workflow', label: 'Workflows', color: 'var(--brand-blue)' },
113126
{ id: 'chat', label: 'Sim Chat', color: USAGE_CHAT_COLOR },
114-
{ id: 'agent', label: 'Agent block', color: 'var(--badge-purple-text)' },
115-
{ id: 'knowledge', label: 'Knowledge Base', color: 'var(--badge-amber-text)' },
116-
{ id: 'enrichment', label: 'Enrichment', color: 'var(--badge-pink-text)' },
117-
{ id: 'other', label: 'Other', color: 'var(--text-muted)' },
127+
{ id: 'enrichment', label: 'Enrichment', color: 'var(--usage-enrichment)' },
128+
{ id: 'knowledge', label: 'Knowledge Base', color: 'var(--usage-knowledge)' },
129+
{ id: 'agent', label: 'Agent block', color: 'var(--usage-agent)' },
130+
{ id: 'other', label: 'Other', color: USAGE_OTHER_COLOR },
118131
] as const
119132

120133
export type UsageSourceCategoryId = (typeof USAGE_SOURCE_CATEGORIES)[number]['id']

0 commit comments

Comments
 (0)