@flamingo-stack/openframe-frontend-core 0.0.625 → 0.0.626-snapshot.20260914041231
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-IYQRUTJI.js → chunk-25UWKNII.js} +10 -8
- package/dist/{chunk-IYQRUTJI.js.map → chunk-25UWKNII.js.map} +1 -1
- package/dist/{chunk-EW6PYGB3.js → chunk-2J7EFH4V.js} +819 -396
- package/dist/chunk-2J7EFH4V.js.map +1 -0
- package/dist/{chunk-X3LC6R37.js → chunk-32P6KUZP.js} +2 -2
- package/dist/{chunk-YSCRM2AG.cjs → chunk-4E3UZZ2J.cjs} +34 -34
- package/dist/{chunk-YSCRM2AG.cjs.map → chunk-4E3UZZ2J.cjs.map} +1 -1
- package/dist/{chunk-EHAYNUOL.cjs → chunk-4E7XCEV3.cjs} +77 -2
- package/dist/chunk-4E7XCEV3.cjs.map +1 -0
- package/dist/{chunk-2RTH6JR5.js → chunk-4PIHIFJM.js} +4 -4
- package/dist/{chunk-ELU7SGM6.cjs → chunk-4SXZT7JP.cjs} +83 -83
- package/dist/{chunk-ELU7SGM6.cjs.map → chunk-4SXZT7JP.cjs.map} +1 -1
- package/dist/{chunk-ISXADEGT.cjs → chunk-53ARMJHM.cjs} +38 -38
- package/dist/chunk-53ARMJHM.cjs.map +1 -0
- package/dist/{chunk-MP2K44EK.cjs → chunk-55X46LKR.cjs} +514 -91
- package/dist/chunk-55X46LKR.cjs.map +1 -0
- package/dist/{chunk-VGZ7WZ7F.js → chunk-5E55S5SI.js} +4 -4
- package/dist/{chunk-U7TTQV4N.cjs → chunk-6I3KNDBF.cjs} +3 -3
- package/dist/{chunk-U7TTQV4N.cjs.map → chunk-6I3KNDBF.cjs.map} +1 -1
- package/dist/{chunk-S6WBBSII.js → chunk-76HB456V.js} +5 -5
- package/dist/{chunk-QAYRZTFU.cjs → chunk-BC726XIQ.cjs} +49 -47
- package/dist/chunk-BC726XIQ.cjs.map +1 -0
- package/dist/{chunk-F7UZDBZZ.cjs → chunk-BJGAFPG5.cjs} +42 -42
- package/dist/{chunk-F7UZDBZZ.cjs.map → chunk-BJGAFPG5.cjs.map} +1 -1
- package/dist/{chunk-HOASBISN.js → chunk-CAQ5MNLJ.js} +3 -3
- package/dist/{chunk-PSANPD64.js → chunk-CK2CPZXB.js} +12 -12
- package/dist/{chunk-YQCA4ZEJ.js → chunk-CMUNJZWN.js} +2 -2
- package/dist/{chunk-7LH2LC6N.js → chunk-DH3YH3TV.js} +8 -8
- package/dist/{chunk-CXTOKOMK.cjs → chunk-FR6EDA3P.cjs} +105 -105
- package/dist/{chunk-CXTOKOMK.cjs.map → chunk-FR6EDA3P.cjs.map} +1 -1
- package/dist/{chunk-VOKLGRHX.cjs → chunk-G46NJNTL.cjs} +28 -26
- package/dist/chunk-G46NJNTL.cjs.map +1 -0
- package/dist/{chunk-P52MUJTG.js → chunk-G47XRVZA.js} +3 -3
- package/dist/{chunk-7VOLW4WX.cjs → chunk-GQ7267OV.cjs} +5 -5
- package/dist/{chunk-7VOLW4WX.cjs.map → chunk-GQ7267OV.cjs.map} +1 -1
- package/dist/{chunk-YCO4UA62.js → chunk-HIZAMJPT.js} +12 -12
- package/dist/{chunk-YWFMYZ4G.js → chunk-J6ATJUEE.js} +5 -5
- package/dist/{chunk-YWFMYZ4G.js.map → chunk-J6ATJUEE.js.map} +1 -1
- package/dist/{chunk-5LIDR7HL.js → chunk-JRYS4VMV.js} +4 -79
- package/dist/{chunk-5LIDR7HL.js.map → chunk-JRYS4VMV.js.map} +1 -1
- package/dist/{chunk-FDE52ADN.js → chunk-KXDYBRRR.js} +7 -7
- package/dist/{chunk-NCY7J6YZ.js → chunk-L5FEAOGJ.js} +14 -360
- package/dist/chunk-L5FEAOGJ.js.map +1 -0
- package/dist/{chunk-BNH76PZH.cjs → chunk-N6XNJX25.cjs} +15 -15
- package/dist/{chunk-BNH76PZH.cjs.map → chunk-N6XNJX25.cjs.map} +1 -1
- package/dist/{chunk-DKNDJNSW.js → chunk-NLADJ4IX.js} +6 -6
- package/dist/{chunk-ETH2WO6U.cjs → chunk-OAXASIVG.cjs} +7 -7
- package/dist/{chunk-ETH2WO6U.cjs.map → chunk-OAXASIVG.cjs.map} +1 -1
- package/dist/{chunk-3IXDZI3R.cjs → chunk-P7UT2YSC.cjs} +3 -3
- package/dist/{chunk-3IXDZI3R.cjs.map → chunk-P7UT2YSC.cjs.map} +1 -1
- package/dist/{chunk-RSJMF2YO.js → chunk-PKSH6PAK.js} +10 -8
- package/dist/{chunk-RSJMF2YO.js.map → chunk-PKSH6PAK.js.map} +1 -1
- package/dist/{chunk-35JUSLEJ.js → chunk-PTP5LSYM.js} +16 -28
- package/dist/{chunk-35JUSLEJ.js.map → chunk-PTP5LSYM.js.map} +1 -1
- package/dist/{chunk-AT44NN6G.cjs → chunk-QCSWM3VU.cjs} +9 -9
- package/dist/{chunk-AT44NN6G.cjs.map → chunk-QCSWM3VU.cjs.map} +1 -1
- package/dist/{chunk-JJUV7Z4L.cjs → chunk-QIVX7F3N.cjs} +27 -27
- package/dist/{chunk-JJUV7Z4L.cjs.map → chunk-QIVX7F3N.cjs.map} +1 -1
- package/dist/{chunk-CP5QJZGS.cjs → chunk-R3SJ6PMI.cjs} +280 -292
- package/dist/chunk-R3SJ6PMI.cjs.map +1 -0
- package/dist/{chunk-2MMEPNSX.cjs → chunk-RAPPN6MN.cjs} +3 -3
- package/dist/{chunk-2MMEPNSX.cjs.map → chunk-RAPPN6MN.cjs.map} +1 -1
- package/dist/{chunk-7H2H6HYE.cjs → chunk-SLT5C3PQ.cjs} +25 -25
- package/dist/{chunk-7H2H6HYE.cjs.map → chunk-SLT5C3PQ.cjs.map} +1 -1
- package/dist/{chunk-FKBM6U43.js → chunk-USIRWQJ3.js} +76 -1
- package/dist/{chunk-FKBM6U43.js.map → chunk-USIRWQJ3.js.map} +1 -1
- package/dist/{chunk-CCWI3622.cjs → chunk-VOZZQ6HQ.cjs} +4 -4
- package/dist/{chunk-CCWI3622.cjs.map → chunk-VOZZQ6HQ.cjs.map} +1 -1
- package/dist/{chunk-CWK7BQTZ.cjs → chunk-VUAEDAUN.cjs} +6 -6
- package/dist/{chunk-CWK7BQTZ.cjs.map → chunk-VUAEDAUN.cjs.map} +1 -1
- package/dist/{chunk-OFRCNA6N.cjs → chunk-VZQ3VVFH.cjs} +22 -20
- package/dist/chunk-VZQ3VVFH.cjs.map +1 -0
- package/dist/{chunk-627V5GNY.js → chunk-WZ6CUZMM.js} +4 -4
- package/dist/{chunk-F2KBCLUG.js → chunk-X5NN4NJM.js} +2 -2
- package/dist/{chunk-C2E3TDRF.js → chunk-Y3MIFC5M.js} +4 -4
- package/dist/{chunk-NDUNUXS2.cjs → chunk-ZCQVUIPH.cjs} +18 -18
- package/dist/{chunk-NDUNUXS2.cjs.map → chunk-ZCQVUIPH.cjs.map} +1 -1
- package/dist/{chunk-UQWJWIEK.js → chunk-ZGZ7YAJH.js} +10 -8
- package/dist/{chunk-UQWJWIEK.js.map → chunk-ZGZ7YAJH.js.map} +1 -1
- package/dist/{chunk-YXWGSDK4.cjs → chunk-ZI27ALYX.cjs} +5 -80
- package/dist/chunk-ZI27ALYX.cjs.map +1 -0
- package/dist/{chunk-BVQEU5JB.js → chunk-ZOMGXH7C.js} +2 -2
- package/dist/{chunk-XOREK735.cjs → chunk-ZYDNPUSH.cjs} +285 -631
- package/dist/chunk-ZYDNPUSH.cjs.map +1 -0
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/entity-cards/admin-content-card-grid.d.ts +8 -5
- package/dist/components/chat/entity-cards/admin-content-card-grid.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/admin-content-card.d.ts +8 -1
- package/dist/components/chat/entity-cards/admin-content-card.d.ts.map +1 -1
- 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 +5 -5
- package/dist/components/chat/index.js +4 -4
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +31 -31
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +75 -69
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +30 -24
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +49 -49
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/card-registry.d.ts.map +1 -1
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/color-preset-select.d.ts +4 -5
- package/dist/components/ui/color-preset-select.d.ts.map +1 -1
- 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 +14 -8
- 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 +13 -7
- package/dist/components/ui/palette-badge.d.ts +22 -0
- package/dist/components/ui/palette-badge.d.ts.map +1 -0
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.js +4 -4
- package/dist/index.cjs +28 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -40
- 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/color-presets.d.ts +24 -0
- package/dist/utils/color-presets.d.ts.map +1 -0
- package/dist/utils/index.cjs +32 -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 +30 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/entity-cards/__tests__/admin-content-card-grid.test.tsx +14 -1
- package/src/components/chat/entity-cards/admin-content-card-grid.tsx +15 -12
- package/src/components/chat/entity-cards/admin-content-card.tsx +24 -6
- 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/__tests__/department-badge.test.tsx +47 -0
- package/src/components/ui/color-preset-select.tsx +5 -21
- package/src/components/ui/department-badge.tsx +35 -0
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/palette-badge.tsx +39 -0
- package/src/types/department.ts +4 -0
- package/src/utils/.color-presets.md +2 -0
- package/src/utils/color-presets.ts +48 -0
- package/src/utils/index.ts +1 -0
- package/dist/chunk-CP5QJZGS.cjs.map +0 -1
- package/dist/chunk-EHAYNUOL.cjs.map +0 -1
- package/dist/chunk-EW6PYGB3.js.map +0 -1
- package/dist/chunk-ISXADEGT.cjs.map +0 -1
- package/dist/chunk-MP2K44EK.cjs.map +0 -1
- package/dist/chunk-NCY7J6YZ.js.map +0 -1
- package/dist/chunk-OFRCNA6N.cjs.map +0 -1
- package/dist/chunk-QAYRZTFU.cjs.map +0 -1
- package/dist/chunk-VOKLGRHX.cjs.map +0 -1
- package/dist/chunk-XOREK735.cjs.map +0 -1
- package/dist/chunk-YXWGSDK4.cjs.map +0 -1
- /package/dist/{chunk-X3LC6R37.js.map → chunk-32P6KUZP.js.map} +0 -0
- /package/dist/{chunk-2RTH6JR5.js.map → chunk-4PIHIFJM.js.map} +0 -0
- /package/dist/{chunk-VGZ7WZ7F.js.map → chunk-5E55S5SI.js.map} +0 -0
- /package/dist/{chunk-S6WBBSII.js.map → chunk-76HB456V.js.map} +0 -0
- /package/dist/{chunk-HOASBISN.js.map → chunk-CAQ5MNLJ.js.map} +0 -0
- /package/dist/{chunk-PSANPD64.js.map → chunk-CK2CPZXB.js.map} +0 -0
- /package/dist/{chunk-YQCA4ZEJ.js.map → chunk-CMUNJZWN.js.map} +0 -0
- /package/dist/{chunk-7LH2LC6N.js.map → chunk-DH3YH3TV.js.map} +0 -0
- /package/dist/{chunk-P52MUJTG.js.map → chunk-G47XRVZA.js.map} +0 -0
- /package/dist/{chunk-YCO4UA62.js.map → chunk-HIZAMJPT.js.map} +0 -0
- /package/dist/{chunk-FDE52ADN.js.map → chunk-KXDYBRRR.js.map} +0 -0
- /package/dist/{chunk-DKNDJNSW.js.map → chunk-NLADJ4IX.js.map} +0 -0
- /package/dist/{chunk-627V5GNY.js.map → chunk-WZ6CUZMM.js.map} +0 -0
- /package/dist/{chunk-F2KBCLUG.js.map → chunk-X5NN4NJM.js.map} +0 -0
- /package/dist/{chunk-C2E3TDRF.js.map → chunk-Y3MIFC5M.js.map} +0 -0
- /package/dist/{chunk-BVQEU5JB.js.map → chunk-ZOMGXH7C.js.map} +0 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { render, screen } from '@testing-library/react';
|
|
13
13
|
import { describe, expect, it } from 'vitest';
|
|
14
|
+
import { AdminContentCard } from '../admin-content-card';
|
|
14
15
|
import { AdminContentCardGrid } from '../admin-content-card-grid';
|
|
15
16
|
|
|
16
17
|
type Row = { id: number; name: string };
|
|
@@ -27,7 +28,7 @@ const base = {
|
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const skeletons = () => screen.queryAllByTestId('skeleton');
|
|
30
|
-
const invisible = () => skeletons().filter(
|
|
31
|
+
const invisible = () => skeletons().filter(el => el.className.includes('invisible'));
|
|
31
32
|
|
|
32
33
|
describe('AdminContentCardGrid', () => {
|
|
33
34
|
it('renders pageSize visible skeletons while loading', () => {
|
|
@@ -55,4 +56,16 @@ describe('AdminContentCardGrid', () => {
|
|
|
55
56
|
expect(screen.getByText('Row 6')).toBeTruthy();
|
|
56
57
|
expect(skeletons()).toHaveLength(0);
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
it('AdminContentCard reserveRows holds the title, subtitle and summary rows at their reserved heights', () => {
|
|
61
|
+
const { unmount } = render(<AdminContentCard title="Short" subtitle="Acme" summary="One line." reserveRows />);
|
|
62
|
+
expect(screen.getByRole('heading', { name: 'Short' }).className).toContain('min-h-[2lh]');
|
|
63
|
+
expect(screen.getByText('Acme').className).toContain('min-h-[1lh]');
|
|
64
|
+
expect(screen.getByText('One line.').className).toContain('min-h-[2lh]');
|
|
65
|
+
unmount();
|
|
66
|
+
render(<AdminContentCard title="Loose" subtitle="Acme" summary="One line." />);
|
|
67
|
+
expect(screen.getByRole('heading', { name: 'Loose' }).className).not.toContain('min-h-[2lh]');
|
|
68
|
+
expect(screen.getByText('Acme').className).not.toContain('min-h-[1lh]');
|
|
69
|
+
expect(screen.getByText('One line.').className).not.toContain('min-h-[2lh]');
|
|
70
|
+
});
|
|
58
71
|
});
|
|
@@ -8,30 +8,31 @@ export const ADMIN_CONTENT_CARD_GRID_CLASS =
|
|
|
8
8
|
'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[var(--spacing-system-lf)]';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* One `AdminContentCard`-shaped placeholder. It mirrors
|
|
12
|
-
* cover, then a `gap-3 p-5` column: two-line title, subtitle
|
|
13
|
-
* badges row, meta
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* One `AdminContentCard reserveRows`-shaped placeholder. It mirrors that card box
|
|
12
|
+
* for box (3:2 cover, then a `gap-3 p-5` column: two-line title, subtitle line,
|
|
13
|
+
* two-line summary, 28px badges row, meta line, bordered actions row), each text
|
|
14
|
+
* row sized in its own typography's line height, so a skeleton, a real card and a
|
|
15
|
+
* reserved slot are the same height at every breakpoint. `p-5` has no ODS token
|
|
16
|
+
* (20px); it is the card's own padding and must match it exactly.
|
|
16
17
|
*/
|
|
17
18
|
export function AdminContentCardSkeleton({ className }: { className?: string }) {
|
|
18
19
|
return (
|
|
19
20
|
<div
|
|
20
21
|
className={cn(
|
|
21
|
-
'flex h-full flex-col overflow-hidden rounded-2xl border border-ods-border bg-ods-card
|
|
22
|
+
'flex h-full animate-pulse flex-col overflow-hidden rounded-2xl border border-ods-border bg-ods-card',
|
|
22
23
|
className,
|
|
23
24
|
)}
|
|
24
25
|
>
|
|
25
26
|
<div className="aspect-[3/2] w-full shrink-0 bg-ods-border/20" />
|
|
26
27
|
<div className="flex flex-1 flex-col gap-[var(--spacing-system-sf)] p-5">
|
|
27
|
-
<div className="h-
|
|
28
|
-
<div className="h-
|
|
29
|
-
<div className="h-
|
|
30
|
-
<div className="flex items-center gap-[var(--spacing-system-xsf)]">
|
|
28
|
+
<div className="h-[2lh] w-full rounded bg-ods-border text-h3" />
|
|
29
|
+
<div className="h-[1lh] w-1/2 rounded bg-ods-border text-h6" />
|
|
30
|
+
<div className="h-[2lh] w-full rounded bg-ods-border text-h6" />
|
|
31
|
+
<div className="flex h-7 items-center gap-[var(--spacing-system-xsf)]">
|
|
31
32
|
<div className="h-5 w-20 rounded-full bg-ods-border" />
|
|
32
33
|
<div className="h-5 w-24 rounded-full bg-ods-border" />
|
|
33
34
|
</div>
|
|
34
|
-
<div className="h-
|
|
35
|
+
<div className="h-[1lh] w-32 rounded bg-ods-border text-h6" />
|
|
35
36
|
<div className="mt-auto flex items-center justify-between border-t border-ods-border pt-[var(--spacing-system-sf)]">
|
|
36
37
|
<div className="h-10 w-24 rounded bg-ods-border" />
|
|
37
38
|
<div className="flex gap-[var(--spacing-system-xsf)]">
|
|
@@ -65,6 +66,8 @@ export interface AdminContentCardGridProps<T> {
|
|
|
65
66
|
/**
|
|
66
67
|
* A paginated card grid that is ONE height in every state: the card-grid
|
|
67
68
|
* counterpart of the admin `Table`'s `skeletonRows` + `keepHeightWhenEmpty`.
|
|
69
|
+
* `AdminContentCard`s rendered in it pass `reserveRows`, so a full page is the
|
|
70
|
+
* height of the reserved one.
|
|
68
71
|
*
|
|
69
72
|
* - loading: `pageSize` skeleton cards;
|
|
70
73
|
* - a short page: the cards, then invisible skeleton-shaped slots up to `pageSize`;
|
|
@@ -112,7 +115,7 @@ export function AdminContentCardGrid<T>({
|
|
|
112
115
|
|
|
113
116
|
return (
|
|
114
117
|
<div className={gridClass} data-state="items">
|
|
115
|
-
{items.map(
|
|
118
|
+
{items.map(item => (
|
|
116
119
|
<div key={itemKey(item)} className="h-full">
|
|
117
120
|
{renderCard(item)}
|
|
118
121
|
</div>
|
|
@@ -35,6 +35,13 @@ interface AdminContentCardProps {
|
|
|
35
35
|
meta?: React.ReactNode;
|
|
36
36
|
/** Action buttons row */
|
|
37
37
|
actions?: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Keep every row's space even when its content is short or absent: a two-line
|
|
40
|
+
* title, the subtitle line, a two-line summary, a 28px badges row and the meta
|
|
41
|
+
* line. Every card in a grid is then the same height, which is what
|
|
42
|
+
* `AdminContentCardGrid` and `AdminContentCardSkeleton` reserve. Default false.
|
|
43
|
+
*/
|
|
44
|
+
reserveRows?: boolean;
|
|
38
45
|
/** Additional class names */
|
|
39
46
|
className?: string;
|
|
40
47
|
}
|
|
@@ -49,6 +56,7 @@ export function AdminContentCard({
|
|
|
49
56
|
badges,
|
|
50
57
|
meta,
|
|
51
58
|
actions,
|
|
59
|
+
reserveRows = false,
|
|
52
60
|
className,
|
|
53
61
|
}: AdminContentCardProps) {
|
|
54
62
|
const [imageError, setImageError] = useState(false);
|
|
@@ -103,17 +111,23 @@ export function AdminContentCard({
|
|
|
103
111
|
{/* Content */}
|
|
104
112
|
<div className="flex flex-1 flex-col gap-3 p-5">
|
|
105
113
|
{/* Title */}
|
|
106
|
-
<h3 className=
|
|
114
|
+
<h3 className={cn('line-clamp-2 break-words text-ods-text-primary text-h3', reserveRows && 'min-h-[2lh]')}>
|
|
115
|
+
{title}
|
|
116
|
+
</h3>
|
|
107
117
|
|
|
108
118
|
{/* Subtitle (optional) */}
|
|
109
|
-
{subtitle
|
|
119
|
+
{(subtitle || reserveRows) && (
|
|
120
|
+
<p className={cn('truncate text-ods-text-secondary text-h6', reserveRows && 'min-h-[1lh]')}>{subtitle}</p>
|
|
121
|
+
)}
|
|
110
122
|
|
|
111
123
|
{/* Summary */}
|
|
112
|
-
{summary
|
|
124
|
+
{(summary || reserveRows) && (
|
|
125
|
+
<p className={cn('line-clamp-2 text-ods-text-secondary text-h6', reserveRows && 'min-h-[2lh]')}>{summary}</p>
|
|
126
|
+
)}
|
|
113
127
|
|
|
114
128
|
{/* Badges row */}
|
|
115
|
-
{(Number(platforms?.length) > 0 || badges) && (
|
|
116
|
-
<div className=
|
|
129
|
+
{(Number(platforms?.length) > 0 || badges || reserveRows) && (
|
|
130
|
+
<div className={cn('flex flex-wrap items-center gap-2', reserveRows && 'min-h-7')}>
|
|
117
131
|
{platforms?.map(p => (
|
|
118
132
|
<PlatformBadge
|
|
119
133
|
key={p.platform_id || p.id}
|
|
@@ -126,7 +140,11 @@ export function AdminContentCard({
|
|
|
126
140
|
)}
|
|
127
141
|
|
|
128
142
|
{/* Meta row */}
|
|
129
|
-
{meta
|
|
143
|
+
{(meta || reserveRows) && (
|
|
144
|
+
<div className={cn('flex items-center gap-3 text-ods-text-secondary text-h6', reserveRows && 'min-h-[1lh]')}>
|
|
145
|
+
{meta}
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
130
148
|
|
|
131
149
|
{/* Actions — pushed to bottom */}
|
|
132
150
|
{actions && (
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<!-- source-hash: 8197c1b05f1f83fd9acaa4ee9318ca11 -->
|
|
2
|
+
PaletteBadge: the standard StatusBadge stamp filled with a COLOR_PRESETS colour (or custom hex) and a contrast-picked label. The shared badge for any row whose colour is data. An unknown or missing colour renders the unfilled default badge; the neutral preset fills grey only when named.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { COLOR_PRESETS, pickPresetColor } from '../../../utils/color-presets';
|
|
4
|
+
import { DepartmentBadge } from '../department-badge';
|
|
5
|
+
import { PaletteBadge } from '../palette-badge';
|
|
6
|
+
|
|
7
|
+
describe('PaletteBadge', () => {
|
|
8
|
+
it('fills the badge with the palette colour a key names', () => {
|
|
9
|
+
render(<PaletteBadge text="Teal" color="teal" />);
|
|
10
|
+
expect(screen.getByText('Teal')).toHaveStyle({ backgroundColor: 'rgb(77, 182, 172)' });
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('renders the unfilled default badge for an unknown or missing colour', () => {
|
|
14
|
+
const { rerender } = render(<PaletteBadge text="Other" color="not-a-colour" />);
|
|
15
|
+
expect(screen.getByText('Other')).not.toHaveAttribute('style');
|
|
16
|
+
rerender(<PaletteBadge text="Other" color={null} />);
|
|
17
|
+
expect(screen.getByText('Other')).not.toHaveAttribute('style');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('fills the neutral preset like any other key', () => {
|
|
21
|
+
render(<PaletteBadge text="Grey" color="neutral" />);
|
|
22
|
+
expect(screen.getByText('Grey')).toHaveStyle({ backgroundColor: 'rgb(176, 176, 176)' });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('DepartmentBadge', () => {
|
|
27
|
+
it("uses the department's stored palette colour, and the empty label without a department", () => {
|
|
28
|
+
const { rerender } = render(<DepartmentBadge department={{ name: 'Marketing', color: 'sky' }} />);
|
|
29
|
+
expect(screen.getByText('Marketing')).toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
|
|
30
|
+
rerender(<DepartmentBadge department={null} emptyLabel="Unassigned" />);
|
|
31
|
+
expect(screen.getByText('Unassigned')).not.toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('pickPresetColor', () => {
|
|
36
|
+
it('picks a palette key that is not taken, and never neutral', () => {
|
|
37
|
+
const keys = COLOR_PRESETS.map(preset => preset.key);
|
|
38
|
+
const taken = keys.filter(key => key !== 'teal' && key !== 'neutral');
|
|
39
|
+
for (let run = 0; run < 10; run++) expect(pickPresetColor({ avoid: taken })).toBe('teal');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('repeats a colour only once every colour is taken', () => {
|
|
43
|
+
const everything = COLOR_PRESETS.map(preset => preset.key);
|
|
44
|
+
expect(everything).toContain(pickPresetColor({ avoid: everything }));
|
|
45
|
+
expect(pickPresetColor({ avoid: everything })).not.toBe('neutral');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { HexColorPicker } from 'react-colorful';
|
|
5
5
|
import { cn } from '../../utils/cn';
|
|
6
|
+
import { COLOR_PRESETS, type ColorPreset } from '../../utils/color-presets';
|
|
6
7
|
import { HEX_PATTERN, hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from '../../utils/ods-color-utils';
|
|
7
8
|
import { Chevron02DownIcon } from '../icons-v2-generated/arrows/chevron-02-down-icon';
|
|
8
9
|
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
@@ -11,27 +12,10 @@ import { ColorSwatch } from './color-swatch';
|
|
|
11
12
|
import { Input } from './input';
|
|
12
13
|
import { InputTrigger } from './input-trigger';
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Ticket-status palette.
|
|
21
|
-
export const TICKET_STATUS_COLOR_PRESETS: readonly ColorPreset[] = [
|
|
22
|
-
{ key: 'green', label: 'Green', color: '#5ea62e' },
|
|
23
|
-
{ key: 'lime', label: 'Lime', color: '#8bc34a' },
|
|
24
|
-
{ key: 'teal', label: 'Teal', color: '#4db6ac' },
|
|
25
|
-
{ key: 'sky', label: 'Sky', color: '#4fc3f7' },
|
|
26
|
-
{ key: 'periwinkle', label: 'Periwinkle', color: '#7e9cd8' },
|
|
27
|
-
{ key: 'lavender', label: 'Lavender', color: '#b39ddb' },
|
|
28
|
-
{ key: 'yellow', label: 'Yellow', color: '#e1b32f' },
|
|
29
|
-
{ key: 'sand', label: 'Sand', color: '#f0c674' },
|
|
30
|
-
{ key: 'peach', label: 'Peach', color: '#f39c7a' },
|
|
31
|
-
{ key: 'red', label: 'Red', color: '#f36666' },
|
|
32
|
-
{ key: 'pink', label: 'Pink', color: '#e988a8' },
|
|
33
|
-
{ key: 'neutral', label: 'Neutral', color: '#b0b0b0' },
|
|
34
|
-
];
|
|
15
|
+
export type { ColorPreset } from '../../utils/color-presets';
|
|
16
|
+
export { COLOR_PRESETS } from '../../utils/color-presets';
|
|
17
|
+
/** The palette ticket statuses pick from: the shared `COLOR_PRESETS`. */
|
|
18
|
+
export const TICKET_STATUS_COLOR_PRESETS = COLOR_PRESETS;
|
|
35
19
|
|
|
36
20
|
export const CUSTOM_PRESET_KEY = 'custom';
|
|
37
21
|
export const DEFAULT_CUSTOM_STATUS_COLOR = '#888888';
|
|
@@ -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 `COLOR_PRESETS` key picked at random
|
|
18
|
+
* (`pickPresetColor`) when the department is created, so no department or colour
|
|
19
|
+
* is listed in code.
|
|
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,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { colorPreset } from '../../utils/color-presets';
|
|
4
|
+
import { HEX_PATTERN, getReadableTextColor } from '../../utils/ods-color-utils';
|
|
5
|
+
import { StatusBadge, type StatusBadgeProps } from './status-badge';
|
|
6
|
+
|
|
7
|
+
export interface PaletteBadgeProps {
|
|
8
|
+
text: string;
|
|
9
|
+
/**
|
|
10
|
+
* A `COLOR_PRESETS` key (the `neutral` key included) or a `#rrggbb` custom colour.
|
|
11
|
+
* Unknown or missing renders the standard unfilled `default` badge, not the
|
|
12
|
+
* `neutral` preset's fill, so an uncoloured row looks like every other plain badge.
|
|
13
|
+
*/
|
|
14
|
+
color?: string | null;
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Defaults to the dense `button` stamp, the size every inline badge beside it uses. */
|
|
17
|
+
variant?: StatusBadgeProps['variant'];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* THE badge for anything that carries its own colour from the shared palette
|
|
22
|
+
* (`COLOR_PRESETS`): a department, a custom ticket status, any row whose colour
|
|
23
|
+
* is data. It is the standard `StatusBadge` stamp filled with the colour, with the
|
|
24
|
+
* label colour picked for contrast, so it matches the size, weight, casing and
|
|
25
|
+
* height of every other badge.
|
|
26
|
+
*/
|
|
27
|
+
export function PaletteBadge({ text, color, className, variant = 'button' }: PaletteBadgeProps) {
|
|
28
|
+
const fill = colorPreset(color)?.color ?? (color && HEX_PATTERN.test(color) ? color : null);
|
|
29
|
+
return (
|
|
30
|
+
<StatusBadge
|
|
31
|
+
text={text}
|
|
32
|
+
colorScheme="default"
|
|
33
|
+
variant={variant}
|
|
34
|
+
singleLine
|
|
35
|
+
className={className}
|
|
36
|
+
style={fill ? { backgroundColor: fill, color: getReadableTextColor(fill) } : undefined}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
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 `COLOR_PRESETS` key picked at random (`pickPresetColor`) 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,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE colour palette for data that carries its own colour: ticket statuses picked
|
|
3
|
+
* in `ColorPresetSelect`, a department's badge, any future row with an identity
|
|
4
|
+
* colour. One list, so every coloured badge in the product reads from the same
|
|
5
|
+
* design-system swatches.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ColorPreset {
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
color: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const COLOR_PRESETS: readonly ColorPreset[] = [
|
|
15
|
+
{ key: 'green', label: 'Green', color: '#5ea62e' },
|
|
16
|
+
{ key: 'lime', label: 'Lime', color: '#8bc34a' },
|
|
17
|
+
{ key: 'teal', label: 'Teal', color: '#4db6ac' },
|
|
18
|
+
{ key: 'sky', label: 'Sky', color: '#4fc3f7' },
|
|
19
|
+
{ key: 'periwinkle', label: 'Periwinkle', color: '#7e9cd8' },
|
|
20
|
+
{ key: 'lavender', label: 'Lavender', color: '#b39ddb' },
|
|
21
|
+
{ key: 'yellow', label: 'Yellow', color: '#e1b32f' },
|
|
22
|
+
{ key: 'sand', label: 'Sand', color: '#f0c674' },
|
|
23
|
+
{ key: 'peach', label: 'Peach', color: '#f39c7a' },
|
|
24
|
+
{ key: 'red', label: 'Red', color: '#f36666' },
|
|
25
|
+
{ key: 'pink', label: 'Pink', color: '#e988a8' },
|
|
26
|
+
{ key: 'neutral', label: 'Neutral', color: '#b0b0b0' },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/** The preset a key names, or `undefined`. */
|
|
30
|
+
export function colorPreset(key: string | null | undefined): ColorPreset | undefined {
|
|
31
|
+
return key ? COLOR_PRESETS.find(preset => preset.key === key) : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A random preset key for a new row that needs an identity colour. Prefers a
|
|
36
|
+
* preset nobody in `avoid` uses yet (neutral is never picked: it reads as "no
|
|
37
|
+
* colour"); once every colour is taken, any colour may repeat.
|
|
38
|
+
*/
|
|
39
|
+
export function pickPresetColor({
|
|
40
|
+
avoid = [],
|
|
41
|
+
random = Math.random,
|
|
42
|
+
}: { avoid?: ReadonlyArray<string | null | undefined>; random?: () => number } = {}): string {
|
|
43
|
+
const colours = COLOR_PRESETS.filter(preset => preset.key !== 'neutral');
|
|
44
|
+
const used = new Set(avoid);
|
|
45
|
+
const free = colours.filter(preset => !used.has(preset.key));
|
|
46
|
+
const pool = free.length > 0 ? free : colours;
|
|
47
|
+
return pool[Math.floor(random() * pool.length) % pool.length].key;
|
|
48
|
+
}
|
package/src/utils/index.ts
CHANGED