diff --git a/.changeset/notification-severity.md b/.changeset/notification-severity.md new file mode 100644 index 0000000..a8e4c34 --- /dev/null +++ b/.changeset/notification-severity.md @@ -0,0 +1,6 @@ +--- +"@chimely/client": minor +"@chimely/react": minor +--- + +First-class notification severity (frontend slice). `WellKnownPayload` gains an optional `severity: 'high' | 'medium' | 'low'`, and the default item renders a left accent tinted by the new `colorSeverityHigh` / `colorSeverityMedium` / `colorSeverityLow` appearance variables. Any other value renders no accent. Tabs can already filter on `severity` via their `filter` predicate. diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index 31d1c3f..a75bbe7 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -30,6 +30,12 @@ export interface WellKnownPayload { action_url?: string; /** Leading icon/avatar in the default rendering. */ icon_url?: string; + /** + * Relative importance. The default item shows a matching severity accent + * tinted by the `colorSeverity*` appearance variables. Any other value + * renders no accent. + */ + severity?: 'high' | 'medium' | 'low'; [custom: string]: unknown; } diff --git a/packages/react/src/appearance.ts b/packages/react/src/appearance.ts index 6cf1cf6..39a7742 100644 --- a/packages/react/src/appearance.ts +++ b/packages/react/src/appearance.ts @@ -43,6 +43,12 @@ export interface InboxAppearance { colorBadgeForeground?: string; /** Popover and pill box-shadow. Default 0 8px 24px rgba(0, 0, 0, 0.12). */ shadow?: string; + /** Accent on `severity: 'high'` items. Default #dc2626. */ + colorSeverityHigh?: string; + /** Accent on `severity: 'medium'` items. Default #d97706. */ + colorSeverityMedium?: string; + /** Accent on `severity: 'low'` items. Default #2563eb. */ + colorSeverityLow?: string; /** Extension point: forwarded as `--chimely-` verbatim. */ [customProperty: string]: string | undefined; }; diff --git a/packages/react/src/components/DefaultItem.tsx b/packages/react/src/components/DefaultItem.tsx index c048b1c..33076bc 100644 --- a/packages/react/src/components/DefaultItem.tsx +++ b/packages/react/src/components/DefaultItem.tsx @@ -25,8 +25,19 @@ export function DefaultItem( ): ReactNode { const { item, className, style, formatTimestamp, onClick } = props; const payload = item.payload as Partial; + // Payloads pass through verbatim, so guard against values outside the union. + const severity = + payload.severity === 'high' || payload.severity === 'medium' || payload.severity === 'low' + ? payload.severity + : undefined; return (