@flamingo-stack/openframe-frontend-core 0.0.626 → 0.0.627-snapshot.20260914044017
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2CCIF5QV.js → chunk-2E543KJD.js} +4 -4
- package/dist/{chunk-KK7YEVTQ.js → chunk-6AFJQOT2.js} +3 -3
- package/dist/{chunk-Z42VU7HF.cjs → chunk-6QLOSGE7.cjs} +33 -33
- package/dist/{chunk-Z42VU7HF.cjs.map → chunk-6QLOSGE7.cjs.map} +1 -1
- package/dist/{chunk-LJ7KMQRM.cjs → chunk-BND25SXU.cjs} +29 -29
- package/dist/{chunk-LJ7KMQRM.cjs.map → chunk-BND25SXU.cjs.map} +1 -1
- package/dist/{chunk-3POP5WWC.cjs → chunk-C3DDNRJG.cjs} +6 -6
- package/dist/{chunk-3POP5WWC.cjs.map → chunk-C3DDNRJG.cjs.map} +1 -1
- package/dist/{chunk-QJ6BCSFQ.cjs → chunk-E523WX5V.cjs} +3 -3
- package/dist/{chunk-QJ6BCSFQ.cjs.map → chunk-E523WX5V.cjs.map} +1 -1
- package/dist/{chunk-63F2UQDW.cjs → chunk-GH4WLDPS.cjs} +15 -15
- package/dist/{chunk-63F2UQDW.cjs.map → chunk-GH4WLDPS.cjs.map} +1 -1
- package/dist/{chunk-ZIEYC6ZB.js → chunk-HLZKMYST.js} +3 -3
- package/dist/{chunk-P7KIFYZI.js → chunk-HNNR5CGX.js} +3 -3
- package/dist/{chunk-ESSHEVZQ.cjs → chunk-JONR3BDJ.cjs} +33 -33
- package/dist/chunk-JONR3BDJ.cjs.map +1 -0
- package/dist/{chunk-WEDSYUSR.js → chunk-JVLLA3Z7.js} +4 -4
- package/dist/{chunk-F4TAUCHQ.js → chunk-JWXEEZKD.js} +2 -2
- package/dist/{chunk-RVK3CL5S.js → chunk-K43T7N7O.js} +6 -6
- package/dist/{chunk-L54LFB6V.cjs → chunk-KT47FRJC.cjs} +11 -11
- package/dist/{chunk-L54LFB6V.cjs.map → chunk-KT47FRJC.cjs.map} +1 -1
- package/dist/{chunk-34GEH24Y.cjs → chunk-KTBZJP5J.cjs} +10 -10
- package/dist/{chunk-34GEH24Y.cjs.map → chunk-KTBZJP5J.cjs.map} +1 -1
- package/dist/{chunk-VOBOO7EF.cjs → chunk-L6GJV7E7.cjs} +59 -59
- package/dist/{chunk-VOBOO7EF.cjs.map → chunk-L6GJV7E7.cjs.map} +1 -1
- package/dist/{chunk-H7KQM3VI.js → chunk-LCMXGM2P.js} +6 -6
- package/dist/{chunk-RGMUA4XB.js → chunk-LLSX5T7X.js} +5 -5
- package/dist/{chunk-RQQAPCOU.js → chunk-MB4IEWLH.js} +3 -3
- package/dist/{chunk-IJYP2DMW.js → chunk-ON7663OW.js} +2 -2
- package/dist/{chunk-Q5XGBLT5.cjs → chunk-OQHFHKUG.cjs} +146 -74
- package/dist/chunk-OQHFHKUG.cjs.map +1 -0
- package/dist/{chunk-S43SLJIN.cjs → chunk-Q544C4Z7.cjs} +22 -22
- package/dist/{chunk-S43SLJIN.cjs.map → chunk-Q544C4Z7.cjs.map} +1 -1
- package/dist/{chunk-BVCWBA2U.js → chunk-QS2QCXBH.js} +466 -394
- package/dist/chunk-QS2QCXBH.js.map +1 -0
- package/dist/{chunk-E7YNDGRN.cjs → chunk-SWJ6QLD7.cjs} +81 -81
- package/dist/{chunk-E7YNDGRN.cjs.map → chunk-SWJ6QLD7.cjs.map} +1 -1
- package/dist/{chunk-QPQCQWAW.cjs → chunk-TDKOW2C5.cjs} +20 -20
- package/dist/{chunk-QPQCQWAW.cjs.map → chunk-TDKOW2C5.cjs.map} +1 -1
- package/dist/{chunk-NLVBO3IR.js → chunk-TUUSLED7.js} +5 -5
- package/dist/{chunk-QR2FJE2C.js → chunk-U4UNC3RP.js} +7 -7
- package/dist/{chunk-NZJNXGU2.cjs → chunk-UBX3ATG5.cjs} +198 -198
- package/dist/{chunk-NZJNXGU2.cjs.map → chunk-UBX3ATG5.cjs.map} +1 -1
- package/dist/{chunk-MSVEZB5D.cjs → chunk-UNI3POHU.cjs} +145 -145
- package/dist/{chunk-MSVEZB5D.cjs.map → chunk-UNI3POHU.cjs.map} +1 -1
- package/dist/{chunk-3LKJ6JWZ.cjs → chunk-VCY2KHOE.cjs} +28 -28
- package/dist/{chunk-3LKJ6JWZ.cjs.map → chunk-VCY2KHOE.cjs.map} +1 -1
- package/dist/{chunk-DZ7CEES3.js → chunk-WBZ4HP7D.js} +3 -3
- package/dist/{chunk-DZ7CEES3.js.map → chunk-WBZ4HP7D.js.map} +1 -1
- package/dist/{chunk-CPO5KPW6.cjs → chunk-WIP5JO2O.cjs} +6 -6
- package/dist/{chunk-CPO5KPW6.cjs.map → chunk-WIP5JO2O.cjs.map} +1 -1
- package/dist/{chunk-DLZFFGQ7.js → chunk-XQ4II4BK.js} +3 -3
- package/dist/{chunk-HTIDXF43.cjs → chunk-Y5QXDVPP.cjs} +5 -5
- package/dist/{chunk-HTIDXF43.cjs.map → chunk-Y5QXDVPP.cjs.map} +1 -1
- package/dist/{chunk-MZWSJPDZ.js → chunk-YZJL6WGP.js} +3 -3
- package/dist/{chunk-IZG3VYDV.js → chunk-ZRCWXJDW.js} +3 -3
- package/dist/components/case-studies/index.cjs +10 -10
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/entity-cards/ai-prompt-card.d.ts +2 -1
- package/dist/components/chat/entity-cards/ai-prompt-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/employee-entry-card.d.ts +3 -3
- package/dist/components/chat/entity-cards/employee-entry-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/entity-author-card.d.ts +8 -6
- package/dist/components/chat/entity-cards/entity-author-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +3 -3
- package/dist/components/chat/index.js +2 -2
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +24 -24
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +57 -53
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +19 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +34 -34
- package/dist/components/meeting-scheduler/index.js +3 -3
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/card-registry.d.ts.map +1 -1
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/department-badge.d.ts +21 -0
- package/dist/components/ui/department-badge.d.ts.map +1 -0
- package/dist/components/ui/index.cjs +8 -4
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +7 -3
- package/dist/components/ui/palette-badge.d.ts +20 -0
- package/dist/components/ui/palette-badge.d.ts.map +1 -0
- package/dist/components/ui/status-badge.d.ts +1 -1
- package/dist/components/ui/status-badge.d.ts.map +1 -1
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/types/department.d.ts +4 -0
- package/dist/types/department.d.ts.map +1 -1
- package/dist/utils/badge-palette.d.ts +18 -0
- package/dist/utils/badge-palette.d.ts.map +1 -0
- package/dist/utils/index.cjs +29 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +27 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/entity-cards/ai-prompt-card.tsx +7 -4
- package/src/components/chat/entity-cards/employee-entry-card.tsx +21 -24
- package/src/components/chat/entity-cards/entity-author-card.tsx +10 -4
- package/src/components/related-content/card-registry.tsx +3 -1
- package/src/components/ui/.department-badge.md +2 -0
- package/src/components/ui/.palette-badge.md +2 -0
- package/src/components/ui/.status-badge.md +2 -2
- package/src/components/ui/__tests__/department-badge.test.tsx +49 -0
- package/src/components/ui/department-badge.tsx +35 -0
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/palette-badge.tsx +34 -0
- package/src/components/ui/status-badge.tsx +5 -0
- package/src/types/department.ts +4 -0
- package/src/utils/.badge-palette.md +2 -0
- package/src/utils/badge-palette.ts +38 -0
- package/src/utils/index.ts +2 -0
- package/dist/chunk-BVCWBA2U.js.map +0 -1
- package/dist/chunk-ESSHEVZQ.cjs.map +0 -1
- package/dist/chunk-Q5XGBLT5.cjs.map +0 -1
- /package/dist/{chunk-2CCIF5QV.js.map → chunk-2E543KJD.js.map} +0 -0
- /package/dist/{chunk-KK7YEVTQ.js.map → chunk-6AFJQOT2.js.map} +0 -0
- /package/dist/{chunk-ZIEYC6ZB.js.map → chunk-HLZKMYST.js.map} +0 -0
- /package/dist/{chunk-P7KIFYZI.js.map → chunk-HNNR5CGX.js.map} +0 -0
- /package/dist/{chunk-WEDSYUSR.js.map → chunk-JVLLA3Z7.js.map} +0 -0
- /package/dist/{chunk-F4TAUCHQ.js.map → chunk-JWXEEZKD.js.map} +0 -0
- /package/dist/{chunk-RVK3CL5S.js.map → chunk-K43T7N7O.js.map} +0 -0
- /package/dist/{chunk-H7KQM3VI.js.map → chunk-LCMXGM2P.js.map} +0 -0
- /package/dist/{chunk-RGMUA4XB.js.map → chunk-LLSX5T7X.js.map} +0 -0
- /package/dist/{chunk-RQQAPCOU.js.map → chunk-MB4IEWLH.js.map} +0 -0
- /package/dist/{chunk-IJYP2DMW.js.map → chunk-ON7663OW.js.map} +0 -0
- /package/dist/{chunk-NLVBO3IR.js.map → chunk-TUUSLED7.js.map} +0 -0
- /package/dist/{chunk-QR2FJE2C.js.map → chunk-U4UNC3RP.js.map} +0 -0
- /package/dist/{chunk-DLZFFGQ7.js.map → chunk-XQ4II4BK.js.map} +0 -0
- /package/dist/{chunk-MZWSJPDZ.js.map → chunk-YZJL6WGP.js.map} +0 -0
- /package/dist/{chunk-IZG3VYDV.js.map → chunk-ZRCWXJDW.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { formatDateUTC } from '../../../utils/format';
|
|
3
|
+
import { DepartmentBadge } from '../../ui/department-badge';
|
|
3
4
|
import {
|
|
4
5
|
EmployeeEntryBadge,
|
|
5
6
|
EmployeeEntryCard,
|
|
@@ -11,8 +12,8 @@ import {
|
|
|
11
12
|
* related-content hydrated row satisfy it structurally. */
|
|
12
13
|
export interface AiPromptCardData extends EmployeeEntryCardData {
|
|
13
14
|
published_at?: string | null;
|
|
14
|
-
/** The department the prompt is for, surfaced as
|
|
15
|
-
department?: { name?: string | null } | null;
|
|
15
|
+
/** The department the prompt is for, surfaced as THE department badge (the library's filter axis). */
|
|
16
|
+
department?: { name?: string | null; color?: string | null } | null;
|
|
16
17
|
/** How many steps the prompt has. A chain (more than one) is badged. */
|
|
17
18
|
step_count?: number | null;
|
|
18
19
|
}
|
|
@@ -37,7 +38,7 @@ export interface AiPromptCardProps {
|
|
|
37
38
|
* related-content rail (with `anchorProps`), so the card cannot drift between them.
|
|
38
39
|
*/
|
|
39
40
|
export function AiPromptCard({ entry, placeholderUrl, actions, anchorProps, className }: AiPromptCardProps) {
|
|
40
|
-
const
|
|
41
|
+
const departmentName = entry.department?.name?.trim();
|
|
41
42
|
const steps = typeof entry.step_count === 'number' ? entry.step_count : 0;
|
|
42
43
|
return (
|
|
43
44
|
<EmployeeEntryCard
|
|
@@ -45,7 +46,9 @@ export function AiPromptCard({ entry, placeholderUrl, actions, anchorProps, clas
|
|
|
45
46
|
dateLabel={entry.published_at ? formatDateUTC(entry.published_at, { fallback: '' }) || null : null}
|
|
46
47
|
extraBadges={
|
|
47
48
|
<>
|
|
48
|
-
{
|
|
49
|
+
{departmentName ? (
|
|
50
|
+
<DepartmentBadge department={{ name: departmentName, color: entry.department?.color ?? null }} />
|
|
51
|
+
) : null}
|
|
49
52
|
{steps > 1 ? <EmployeeEntryBadge>{`${steps} steps`}</EmployeeEntryBadge> : null}
|
|
50
53
|
</>
|
|
51
54
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import Image from '../../../embed-shims/next-image';
|
|
3
3
|
import { getProxiedImageUrl } from '../../../utils/image-proxy-stub';
|
|
4
|
+
import { StatusBadge, type StatusBadgeProps } from '../../ui/status-badge';
|
|
4
5
|
import { AdminContentCard } from './admin-content-card';
|
|
5
6
|
|
|
6
7
|
/** The fields every people-hub employee entry shares. Entity-specific bindings
|
|
@@ -35,26 +36,23 @@ export interface EmployeeEntryCardProps {
|
|
|
35
36
|
className?: string;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/** Entry lifecycle → the standard badge colour scheme (the same ODS pairs every status badge uses). */
|
|
40
|
+
const STATUS_BADGE_SCHEME: Record<string, NonNullable<StatusBadgeProps['colorScheme']>> = {
|
|
41
|
+
published: 'success',
|
|
42
|
+
draft: 'warning',
|
|
43
|
+
archived: 'default',
|
|
42
44
|
// Design-doc lifecycle (product-hub) — same ODS pairs, no new palette.
|
|
43
|
-
in_review: '
|
|
44
|
-
approved: '
|
|
45
|
-
building: '
|
|
46
|
-
shipped: '
|
|
47
|
-
abandoned: '
|
|
45
|
+
in_review: 'warning',
|
|
46
|
+
approved: 'success',
|
|
47
|
+
building: 'success',
|
|
48
|
+
shipped: 'success',
|
|
49
|
+
abandoned: 'default',
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
export function EmployeeEntryBadge({ children }: { children:
|
|
53
|
-
return
|
|
54
|
-
<span className="rounded border border-ods-border bg-ods-card px-2 py-1 text-xs font-medium text-ods-text-secondary">
|
|
55
|
-
{children}
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
52
|
+
/** An entity's own badge (discipline, level, step count): the standard `StatusBadge`
|
|
53
|
+
* stamp, so it sits at exactly the size and height of the status badge beside it. */
|
|
54
|
+
export function EmployeeEntryBadge({ children }: { children: string }) {
|
|
55
|
+
return <StatusBadge text={children} colorScheme="default" variant="button" singleLine />;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
/**
|
|
@@ -86,13 +84,12 @@ export function EmployeeEntryCard({
|
|
|
86
84
|
entry.status || extraBadges ? (
|
|
87
85
|
<>
|
|
88
86
|
{entry.status ? (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</span>
|
|
87
|
+
<StatusBadge
|
|
88
|
+
text={entry.status}
|
|
89
|
+
colorScheme={STATUS_BADGE_SCHEME[entry.status] ?? 'default'}
|
|
90
|
+
variant="button"
|
|
91
|
+
singleLine
|
|
92
|
+
/>
|
|
96
93
|
) : null}
|
|
97
94
|
{extraBadges}
|
|
98
95
|
</>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import Link from '../../../embed-shims/next-link';
|
|
2
3
|
import type { EntityAuthor } from '../../../types/entity-author';
|
|
3
4
|
import { formatDate, nameInitials } from '../../../utils/format';
|
|
@@ -60,7 +61,7 @@ export interface EntityAuthorCardProps {
|
|
|
60
61
|
* webinar host, customer-interview customer). The grid auto-sizes via
|
|
61
62
|
* `grid-cols-N`.
|
|
62
63
|
*/
|
|
63
|
-
extraCells?: Array<{ value:
|
|
64
|
+
extraCells?: Array<{ value: React.ReactNode; label: string; uppercase?: boolean }>;
|
|
64
65
|
/** When true, render the author cell even when `author?.full_name` is
|
|
65
66
|
* missing — using the `EMPTY_AUTHOR_PLACEHOLDER` shape above. Used by
|
|
66
67
|
* catalog grids that must keep a fixed shape so skeleton alignment
|
|
@@ -71,7 +72,8 @@ export interface EntityAuthorCardProps {
|
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
* Single value cell — top: large `text-h4` value (uppercase), bottom: small
|
|
74
|
-
* `DM_Sans` 14px secondary label.
|
|
75
|
+
* `DM_Sans` 14px secondary label. A non-text value (a `DepartmentBadge`) renders
|
|
76
|
+
* as given in the value slot.
|
|
75
77
|
*/
|
|
76
78
|
export function EntityMetadataValueCell({
|
|
77
79
|
value,
|
|
@@ -79,7 +81,7 @@ export function EntityMetadataValueCell({
|
|
|
79
81
|
className,
|
|
80
82
|
uppercase = true,
|
|
81
83
|
}: {
|
|
82
|
-
value:
|
|
84
|
+
value: React.ReactNode;
|
|
83
85
|
label: string;
|
|
84
86
|
className?: string;
|
|
85
87
|
uppercase?: boolean;
|
|
@@ -87,7 +89,11 @@ export function EntityMetadataValueCell({
|
|
|
87
89
|
return (
|
|
88
90
|
<div className={`flex flex-col gap-3 bg-ods-card p-4 ${className ?? ''}`}>
|
|
89
91
|
<div className="flex flex-col gap-0">
|
|
90
|
-
|
|
92
|
+
{typeof value === 'string' ? (
|
|
93
|
+
<p className="text-ods-text-primary text-h4">{uppercase ? value.toLocaleUpperCase() : value}</p>
|
|
94
|
+
) : (
|
|
95
|
+
<div className="flex min-h-6 items-center">{value}</div>
|
|
96
|
+
)}
|
|
91
97
|
<p className="text-ods-text-secondary text-h6">{label}</p>
|
|
92
98
|
</div>
|
|
93
99
|
</div>
|
|
@@ -527,7 +527,9 @@ function decodeEmployeeEntryRow(row: unknown): WhatIShippedCardData & HowIWorkCa
|
|
|
527
527
|
session_date: strOrNull(record, 'session_date'),
|
|
528
528
|
discipline: strOrNull(record, 'discipline'),
|
|
529
529
|
published_at: strOrNull(record, 'published_at'),
|
|
530
|
-
department: record.department
|
|
530
|
+
department: record.department
|
|
531
|
+
? { name: strOrNull(department, 'name'), color: strOrNull(department, 'color') }
|
|
532
|
+
: null,
|
|
531
533
|
step_count: typeof stepCount === 'number' ? stepCount : null,
|
|
532
534
|
};
|
|
533
535
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: fcab461ab76111f1dcac54b7b297775a -->
|
|
2
2
|
Reusable status badge component implementing the OpenFrame Design System (ODS) badge specifications, with support for multiple color schemes, density variants, and a dedicated OpenFrame generation mode.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
@@ -9,7 +9,7 @@ A polymorphic `<span>`-based badge component built with `class-variance-authorit
|
|
|
9
9
|
### `statusBadgeVariants`
|
|
10
10
|
CVA variant configuration exposing two axes:
|
|
11
11
|
- **`variant`**: `card` (standalone, full ODS caption composite) | `button` (dense inline stamp, 10px scale)
|
|
12
|
-
- **`colorScheme`**: `cyan` | `pink` | `yellow` | `green` | `purple` | `success` | `error` | `warning` | `default` | `accentBorder` | `errorBorder` | `whiteBorder`
|
|
12
|
+
- **`colorScheme`**: `cyan` | `pink` | `yellow` | `green` | `purple` | `cyanSoft` | `pinkSoft` | `openYellow` | `red` | `success` | `error` | `warning` | `default` | `accentBorder` | `errorBorder` | `whiteBorder`. Ten of them form `BADGE_PALETTE` (`utils/badge-palette`), the ODS colours a department badge picks from.
|
|
13
13
|
|
|
14
14
|
### `genBadgeBgOpacity(gen: number): number`
|
|
15
15
|
Returns the accent background opacity (%) for a given OpenFrame generation tier. Gen 1 is strongest (30%), fading progressively for later generations.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { BADGE_PALETTE, pickBadgePaletteColor } from '../../../utils/badge-palette';
|
|
4
|
+
import { DepartmentBadge } from '../department-badge';
|
|
5
|
+
import { PaletteBadge } from '../palette-badge';
|
|
6
|
+
import { statusBadgeVariants } from '../status-badge';
|
|
7
|
+
|
|
8
|
+
describe('PaletteBadge', () => {
|
|
9
|
+
it('renders a palette key as its ODS colour scheme, with no inline colour', () => {
|
|
10
|
+
render(<PaletteBadge text="Teal" color="cyanSoft" />);
|
|
11
|
+
const badge = screen.getByText('Teal');
|
|
12
|
+
expect(badge).toHaveClass('bg-ods-flamingo-cyan-secondary', 'text-ods-flamingo-cyan');
|
|
13
|
+
expect(badge).not.toHaveAttribute('style');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders the unfilled default badge for anything outside the palette, a hex included', () => {
|
|
17
|
+
const { rerender } = render(<PaletteBadge text="Other" color="#ff0000" />);
|
|
18
|
+
expect(screen.getByText('Other')).toHaveClass('bg-ods-bg-surface');
|
|
19
|
+
rerender(<PaletteBadge text="Other" color={null} />);
|
|
20
|
+
expect(screen.getByText('Other')).toHaveClass('bg-ods-bg-surface');
|
|
21
|
+
expect(screen.getByText('Other')).not.toHaveAttribute('style');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('gives every palette key a distinct ODS colour scheme', () => {
|
|
25
|
+
const classes = BADGE_PALETTE.map(key => statusBadgeVariants({ colorScheme: key, variant: 'button' }));
|
|
26
|
+
expect(new Set(classes).size).toBe(BADGE_PALETTE.length);
|
|
27
|
+
for (const c of classes) expect(c).not.toMatch(/#[0-9a-f]{3,6}/i);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('DepartmentBadge', () => {
|
|
32
|
+
it("uses the department's stored palette colour, and the empty label without a department", () => {
|
|
33
|
+
const { rerender } = render(<DepartmentBadge department={{ name: 'Marketing', color: 'pink' }} />);
|
|
34
|
+
expect(screen.getByText('Marketing')).toHaveClass('bg-ods-flamingo-pink');
|
|
35
|
+
rerender(<DepartmentBadge department={null} emptyLabel="Unassigned" />);
|
|
36
|
+
expect(screen.getByText('Unassigned')).toHaveClass('bg-ods-bg-surface');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('pickBadgePaletteColor', () => {
|
|
41
|
+
it('picks a palette key that is not taken', () => {
|
|
42
|
+
const [free, ...taken] = BADGE_PALETTE;
|
|
43
|
+
expect(pickBadgePaletteColor({ avoid: taken, random: () => 0.99 })).toBe(free);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('repeats a colour only once every colour is taken', () => {
|
|
47
|
+
expect(BADGE_PALETTE).toContain(pickBadgePaletteColor({ avoid: [...BADGE_PALETTE], random: () => 0.5 }));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { DepartmentRef } from '../../types/department';
|
|
4
|
+
import { PaletteBadge, type PaletteBadgeProps } from './palette-badge';
|
|
5
|
+
|
|
6
|
+
export interface DepartmentBadgeProps {
|
|
7
|
+
/** A department reference; its stored `color` (a palette key) fills the badge. */
|
|
8
|
+
department: { name: DepartmentRef['name']; color?: DepartmentRef['color'] } | null | undefined;
|
|
9
|
+
/** Text when there is no department. */
|
|
10
|
+
emptyLabel?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
variant?: PaletteBadgeProps['variant'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* THE department badge: the shared `PaletteBadge` in the department's own colour.
|
|
17
|
+
* The colour is data, `departments.color`, a `BADGE_PALETTE` key picked at random
|
|
18
|
+
* (`pickBadgePaletteColor`) when the department is created, so no department or
|
|
19
|
+
* colour is listed in code, and every colour is an ODS token.
|
|
20
|
+
*/
|
|
21
|
+
export function DepartmentBadge({
|
|
22
|
+
department,
|
|
23
|
+
emptyLabel = 'No department',
|
|
24
|
+
className,
|
|
25
|
+
variant,
|
|
26
|
+
}: DepartmentBadgeProps) {
|
|
27
|
+
return (
|
|
28
|
+
<PaletteBadge
|
|
29
|
+
text={department?.name || emptyLabel}
|
|
30
|
+
color={department?.name ? department.color : null}
|
|
31
|
+
className={className}
|
|
32
|
+
variant={variant}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -67,6 +67,8 @@ export * from './release-changelog-section';
|
|
|
67
67
|
export * from './stacked-rows-panel';
|
|
68
68
|
export * from './slack-channel-chip';
|
|
69
69
|
export * from './status-badge';
|
|
70
|
+
export * from './palette-badge';
|
|
71
|
+
export * from './department-badge';
|
|
70
72
|
export * from './status-indicator';
|
|
71
73
|
export * from './toaster';
|
|
72
74
|
// TODO: Add other UI components as they are moved to ui-kit
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { isBadgePaletteKey } from '../../utils/badge-palette';
|
|
4
|
+
import { StatusBadge, type StatusBadgeProps } from './status-badge';
|
|
5
|
+
|
|
6
|
+
export interface PaletteBadgeProps {
|
|
7
|
+
text: string;
|
|
8
|
+
/**
|
|
9
|
+
* A `BADGE_PALETTE` key. Anything else (unknown, missing, a hex) renders the
|
|
10
|
+
* standard unfilled `default` badge: colours come only from the ODS palette.
|
|
11
|
+
*/
|
|
12
|
+
color?: string | null;
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Defaults to the dense `button` stamp, the size every inline badge beside it uses. */
|
|
15
|
+
variant?: StatusBadgeProps['variant'];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* THE badge for anything that carries its own colour as data (a department). It
|
|
20
|
+
* is the standard `StatusBadge` in one of the ODS palette colour schemes, so it
|
|
21
|
+
* matches the size, weight, casing and height of every other badge and uses ODS
|
|
22
|
+
* tokens only.
|
|
23
|
+
*/
|
|
24
|
+
export function PaletteBadge({ text, color, className, variant = 'button' }: PaletteBadgeProps) {
|
|
25
|
+
return (
|
|
26
|
+
<StatusBadge
|
|
27
|
+
text={text}
|
|
28
|
+
colorScheme={isBadgePaletteKey(color) ? color : 'default'}
|
|
29
|
+
variant={variant}
|
|
30
|
+
singleLine
|
|
31
|
+
className={className}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -26,6 +26,11 @@ const statusBadgeVariants = cva('inline-flex items-center justify-center rounded
|
|
|
26
26
|
yellow: 'border border-ods-border bg-ods-accent text-ods-text-on-accent',
|
|
27
27
|
green: 'bg-ods-success text-ods-text-on-accent',
|
|
28
28
|
purple: 'bg-ods-flamingo-pink text-ods-text-on-accent',
|
|
29
|
+
// Solid and soft ODS palette fills (`BADGE_PALETTE`): tokens only, no hex.
|
|
30
|
+
cyanSoft: 'bg-ods-flamingo-cyan-secondary text-ods-flamingo-cyan',
|
|
31
|
+
pinkSoft: 'bg-ods-flamingo-pink-secondary text-ods-flamingo-pink',
|
|
32
|
+
openYellow: 'bg-ods-open-yellow text-ods-text-on-accent',
|
|
33
|
+
red: 'bg-ods-error text-ods-text-on-accent',
|
|
29
34
|
success: 'bg-ods-success-secondary text-ods-success',
|
|
30
35
|
error: 'bg-ods-error-secondary text-ods-error',
|
|
31
36
|
warning: 'bg-ods-warning-secondary text-ods-warning',
|
package/src/types/department.ts
CHANGED
|
@@ -20,11 +20,14 @@ export interface Department {
|
|
|
20
20
|
parent_department_id?: string | null;
|
|
21
21
|
display_order: number;
|
|
22
22
|
is_active: boolean;
|
|
23
|
+
/** The department's badge colour: a `BADGE_PALETTE` key (an ODS colour scheme) picked at random (`pickBadgePaletteColor`) when the row is created. */
|
|
24
|
+
color: string | null;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/** The embedded shape a reader gets through the `department:departments(…)` PostgREST embed. */
|
|
26
28
|
export type DepartmentRef = Pick<Department, 'id' | 'name' | 'slug'> & {
|
|
27
29
|
display_order?: number;
|
|
30
|
+
color?: string | null;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
/** `GET /api/admin/departments?counts=…` row — a department plus how many profiles carry it. */
|
|
@@ -32,6 +35,7 @@ export interface DepartmentSummary {
|
|
|
32
35
|
id: string;
|
|
33
36
|
name: string;
|
|
34
37
|
slug: string;
|
|
38
|
+
color?: string | null;
|
|
35
39
|
count: number;
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ODS badge palette: the `StatusBadge` colour schemes a row whose colour is
|
|
3
|
+
* DATA picks from (a department today). Every entry is built from ODS tokens
|
|
4
|
+
* only, five brand and attention hues, each as a solid and a soft fill, so no
|
|
5
|
+
* two entries look alike. A stored colour is one of these KEYS, never a hex.
|
|
6
|
+
*/
|
|
7
|
+
export const BADGE_PALETTE = [
|
|
8
|
+
'cyan',
|
|
9
|
+
'cyanSoft',
|
|
10
|
+
'pink',
|
|
11
|
+
'pinkSoft',
|
|
12
|
+
'openYellow',
|
|
13
|
+
'warning',
|
|
14
|
+
'green',
|
|
15
|
+
'success',
|
|
16
|
+
'red',
|
|
17
|
+
'error',
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export type BadgePaletteKey = (typeof BADGE_PALETTE)[number];
|
|
21
|
+
|
|
22
|
+
export function isBadgePaletteKey(value: unknown): value is BadgePaletteKey {
|
|
23
|
+
return typeof value === 'string' && (BADGE_PALETTE as readonly string[]).includes(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A random palette key for a new row, preferring one no row in `avoid` uses yet.
|
|
28
|
+
* Repeats a colour only once every colour is taken. `random` is injectable for tests.
|
|
29
|
+
*/
|
|
30
|
+
export function pickBadgePaletteColor({
|
|
31
|
+
avoid = [],
|
|
32
|
+
random = Math.random,
|
|
33
|
+
}: { avoid?: ReadonlyArray<string | null | undefined>; random?: () => number } = {}): BadgePaletteKey {
|
|
34
|
+
const used = new Set(avoid);
|
|
35
|
+
const free = BADGE_PALETTE.filter(key => !used.has(key));
|
|
36
|
+
const pool = free.length > 0 ? free : BADGE_PALETTE;
|
|
37
|
+
return pool[Math.floor(random() * pool.length) % pool.length];
|
|
38
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -391,3 +391,5 @@ export * from './ods-spacing';
|
|
|
391
391
|
export * from './csv';
|
|
392
392
|
// Social platform vocabulary, host table, link type, picker.
|
|
393
393
|
export * from './social-platforms';
|
|
394
|
+
// The ODS badge palette a row whose colour is data picks from (departments).
|
|
395
|
+
export { BADGE_PALETTE, isBadgePaletteKey, pickBadgePaletteColor, type BadgePaletteKey } from './badge-palette';
|