@flamingo-stack/openframe-frontend-core 0.0.627 → 0.0.628-2170.6181.1
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-25UWKNII.js → chunk-2E543KJD.js} +8 -10
- package/dist/{chunk-25UWKNII.js.map → chunk-2E543KJD.js.map} +1 -1
- package/dist/{chunk-RAPPN6MN.cjs → chunk-2MMEPNSX.cjs} +3 -3
- package/dist/{chunk-RAPPN6MN.cjs.map → chunk-2MMEPNSX.cjs.map} +1 -1
- package/dist/{chunk-P7UT2YSC.cjs → chunk-3IXDZI3R.cjs} +3 -3
- package/dist/{chunk-P7UT2YSC.cjs.map → chunk-3IXDZI3R.cjs.map} +1 -1
- package/dist/{chunk-JRYS4VMV.js → chunk-5LIDR7HL.js} +79 -4
- package/dist/{chunk-JRYS4VMV.js.map → chunk-5LIDR7HL.js.map} +1 -1
- package/dist/{chunk-4PIHIFJM.js → chunk-6AFJQOT2.js} +4 -4
- package/dist/{chunk-BC726XIQ.cjs → chunk-6QLOSGE7.cjs} +47 -49
- package/dist/chunk-6QLOSGE7.cjs.map +1 -0
- package/dist/{chunk-BJGAFPG5.cjs → chunk-BND25SXU.cjs} +42 -42
- package/dist/{chunk-BJGAFPG5.cjs.map → chunk-BND25SXU.cjs.map} +1 -1
- package/dist/{chunk-ZOMGXH7C.js → chunk-BVQEU5JB.js} +2 -2
- package/dist/{chunk-VUAEDAUN.cjs → chunk-C3DDNRJG.cjs} +6 -6
- package/dist/{chunk-VUAEDAUN.cjs.map → chunk-C3DDNRJG.cjs.map} +1 -1
- package/dist/{chunk-VOZZQ6HQ.cjs → chunk-CCWI3622.cjs} +4 -4
- package/dist/{chunk-VOZZQ6HQ.cjs.map → chunk-CCWI3622.cjs.map} +1 -1
- package/dist/{chunk-GQ7267OV.cjs → chunk-E523WX5V.cjs} +5 -5
- package/dist/{chunk-GQ7267OV.cjs.map → chunk-E523WX5V.cjs.map} +1 -1
- package/dist/{chunk-4E7XCEV3.cjs → chunk-EHAYNUOL.cjs} +2 -77
- package/dist/chunk-EHAYNUOL.cjs.map +1 -0
- package/dist/{chunk-X5NN4NJM.js → chunk-F2KBCLUG.js} +2 -2
- package/dist/{chunk-USIRWQJ3.js → chunk-FKBM6U43.js} +1 -76
- package/dist/{chunk-USIRWQJ3.js.map → chunk-FKBM6U43.js.map} +1 -1
- package/dist/{chunk-ZCQVUIPH.cjs → chunk-GH4WLDPS.cjs} +18 -18
- package/dist/{chunk-ZCQVUIPH.cjs.map → chunk-GH4WLDPS.cjs.map} +1 -1
- package/dist/{chunk-WZ6CUZMM.js → chunk-HLZKMYST.js} +4 -4
- package/dist/{chunk-PKSH6PAK.js → chunk-HNNR5CGX.js} +8 -10
- package/dist/{chunk-PKSH6PAK.js.map → chunk-HNNR5CGX.js.map} +1 -1
- package/dist/{chunk-QIVX7F3N.cjs → chunk-JJUV7Z4L.cjs} +27 -27
- package/dist/{chunk-QIVX7F3N.cjs.map → chunk-JJUV7Z4L.cjs.map} +1 -1
- package/dist/{chunk-53ARMJHM.cjs → chunk-JONR3BDJ.cjs} +37 -37
- package/dist/{chunk-53ARMJHM.cjs.map → chunk-JONR3BDJ.cjs.map} +1 -1
- package/dist/{chunk-NLADJ4IX.js → chunk-JVLLA3Z7.js} +6 -6
- package/dist/{chunk-CAQ5MNLJ.js → chunk-JWXEEZKD.js} +3 -3
- package/dist/{chunk-HIZAMJPT.js → chunk-K43T7N7O.js} +12 -12
- package/dist/{chunk-N6XNJX25.cjs → chunk-KT47FRJC.cjs} +15 -15
- package/dist/{chunk-N6XNJX25.cjs.map → chunk-KT47FRJC.cjs.map} +1 -1
- package/dist/{chunk-VZQ3VVFH.cjs → chunk-KTBZJP5J.cjs} +20 -22
- package/dist/chunk-KTBZJP5J.cjs.map +1 -0
- package/dist/{chunk-4SXZT7JP.cjs → chunk-L6GJV7E7.cjs} +83 -83
- package/dist/{chunk-4SXZT7JP.cjs.map → chunk-L6GJV7E7.cjs.map} +1 -1
- package/dist/{chunk-DH3YH3TV.js → chunk-LCMXGM2P.js} +8 -8
- package/dist/{chunk-KXDYBRRR.js → chunk-LLSX5T7X.js} +7 -7
- package/dist/{chunk-G47XRVZA.js → chunk-MB4IEWLH.js} +3 -3
- package/dist/{chunk-L5FEAOGJ.js → chunk-ON7663OW.js} +354 -8
- package/dist/chunk-ON7663OW.js.map +1 -0
- package/dist/{chunk-55X46LKR.cjs → chunk-OQHFHKUG.cjs} +100 -450
- package/dist/chunk-OQHFHKUG.cjs.map +1 -0
- package/dist/{chunk-SLT5C3PQ.cjs → chunk-Q544C4Z7.cjs} +25 -25
- package/dist/{chunk-SLT5C3PQ.cjs.map → chunk-Q544C4Z7.cjs.map} +1 -1
- package/dist/{chunk-2J7EFH4V.js → chunk-QS2QCXBH.js} +30 -380
- package/dist/chunk-QS2QCXBH.js.map +1 -0
- package/dist/{chunk-76HB456V.js → chunk-S6WBBSII.js} +5 -5
- package/dist/{chunk-FR6EDA3P.cjs → chunk-SWJ6QLD7.cjs} +105 -105
- package/dist/{chunk-FR6EDA3P.cjs.map → chunk-SWJ6QLD7.cjs.map} +1 -1
- package/dist/{chunk-G46NJNTL.cjs → chunk-TDKOW2C5.cjs} +26 -28
- package/dist/chunk-TDKOW2C5.cjs.map +1 -0
- package/dist/{chunk-ZGZ7YAJH.js → chunk-TUUSLED7.js} +8 -10
- package/dist/{chunk-ZGZ7YAJH.js.map → chunk-TUUSLED7.js.map} +1 -1
- package/dist/{chunk-CK2CPZXB.js → chunk-U4UNC3RP.js} +12 -12
- package/dist/{chunk-6I3KNDBF.cjs → chunk-U7TTQV4N.cjs} +3 -3
- package/dist/{chunk-6I3KNDBF.cjs.map → chunk-U7TTQV4N.cjs.map} +1 -1
- package/dist/{chunk-R3SJ6PMI.cjs → chunk-UBX3ATG5.cjs} +292 -280
- package/dist/chunk-UBX3ATG5.cjs.map +1 -0
- package/dist/{chunk-ZYDNPUSH.cjs → chunk-UNI3POHU.cjs} +625 -279
- package/dist/chunk-UNI3POHU.cjs.map +1 -0
- package/dist/{chunk-4E3UZZ2J.cjs → chunk-VCY2KHOE.cjs} +34 -34
- package/dist/{chunk-4E3UZZ2J.cjs.map → chunk-VCY2KHOE.cjs.map} +1 -1
- package/dist/{chunk-J6ATJUEE.js → chunk-WBZ4HP7D.js} +4 -4
- package/dist/{chunk-QCSWM3VU.cjs → chunk-WIP5JO2O.cjs} +9 -9
- package/dist/{chunk-QCSWM3VU.cjs.map → chunk-WIP5JO2O.cjs.map} +1 -1
- package/dist/{chunk-32P6KUZP.js → chunk-X3LC6R37.js} +2 -2
- package/dist/{chunk-5E55S5SI.js → chunk-XQ4II4BK.js} +4 -4
- package/dist/{chunk-OAXASIVG.cjs → chunk-Y5QXDVPP.cjs} +7 -7
- package/dist/{chunk-OAXASIVG.cjs.map → chunk-Y5QXDVPP.cjs.map} +1 -1
- package/dist/{chunk-CMUNJZWN.js → chunk-YQCA4ZEJ.js} +2 -2
- package/dist/{chunk-ZI27ALYX.cjs → chunk-YXWGSDK4.cjs} +80 -5
- package/dist/chunk-YXWGSDK4.cjs.map +1 -0
- package/dist/{chunk-PTP5LSYM.js → chunk-YZJL6WGP.js} +28 -16
- package/dist/{chunk-PTP5LSYM.js.map → chunk-YZJL6WGP.js.map} +1 -1
- package/dist/{chunk-Y3MIFC5M.js → chunk-ZRCWXJDW.js} +4 -4
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +8 -8
- 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 +69 -71
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +24 -26
- 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/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 +5 -4
- package/dist/components/ui/color-preset-select.d.ts.map +1 -1
- package/dist/components/ui/department-badge.d.ts +3 -3
- package/dist/components/ui/index.cjs +8 -10
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +7 -9
- package/dist/components/ui/palette-badge.d.ts +6 -8
- package/dist/components/ui/palette-badge.d.ts.map +1 -1
- package/dist/components/ui/status-badge.d.ts +1 -1
- package/dist/components/ui/status-badge.d.ts.map +1 -1
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.js +4 -4
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -46
- package/dist/types/department.d.ts +1 -1
- 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 +21 -24
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -22
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ui/.department-badge.md +2 -2
- package/src/components/ui/.palette-badge.md +2 -2
- package/src/components/ui/.status-badge.md +2 -2
- package/src/components/ui/__tests__/department-badge.test.tsx +23 -21
- package/src/components/ui/color-preset-select.tsx +21 -5
- package/src/components/ui/department-badge.tsx +3 -3
- package/src/components/ui/palette-badge.tsx +8 -13
- package/src/components/ui/status-badge.tsx +5 -0
- package/src/types/department.ts +1 -1
- package/src/utils/.badge-palette.md +2 -0
- package/src/utils/badge-palette.ts +38 -0
- package/src/utils/index.ts +2 -1
- package/dist/chunk-2J7EFH4V.js.map +0 -1
- package/dist/chunk-4E7XCEV3.cjs.map +0 -1
- package/dist/chunk-55X46LKR.cjs.map +0 -1
- package/dist/chunk-BC726XIQ.cjs.map +0 -1
- package/dist/chunk-G46NJNTL.cjs.map +0 -1
- package/dist/chunk-L5FEAOGJ.js.map +0 -1
- package/dist/chunk-R3SJ6PMI.cjs.map +0 -1
- package/dist/chunk-VZQ3VVFH.cjs.map +0 -1
- package/dist/chunk-ZI27ALYX.cjs.map +0 -1
- package/dist/chunk-ZYDNPUSH.cjs.map +0 -1
- package/dist/utils/color-presets.d.ts +0 -24
- package/dist/utils/color-presets.d.ts.map +0 -1
- package/src/utils/.color-presets.md +0 -2
- package/src/utils/color-presets.ts +0 -48
- /package/dist/{chunk-4PIHIFJM.js.map → chunk-6AFJQOT2.js.map} +0 -0
- /package/dist/{chunk-ZOMGXH7C.js.map → chunk-BVQEU5JB.js.map} +0 -0
- /package/dist/{chunk-X5NN4NJM.js.map → chunk-F2KBCLUG.js.map} +0 -0
- /package/dist/{chunk-WZ6CUZMM.js.map → chunk-HLZKMYST.js.map} +0 -0
- /package/dist/{chunk-NLADJ4IX.js.map → chunk-JVLLA3Z7.js.map} +0 -0
- /package/dist/{chunk-CAQ5MNLJ.js.map → chunk-JWXEEZKD.js.map} +0 -0
- /package/dist/{chunk-HIZAMJPT.js.map → chunk-K43T7N7O.js.map} +0 -0
- /package/dist/{chunk-DH3YH3TV.js.map → chunk-LCMXGM2P.js.map} +0 -0
- /package/dist/{chunk-KXDYBRRR.js.map → chunk-LLSX5T7X.js.map} +0 -0
- /package/dist/{chunk-G47XRVZA.js.map → chunk-MB4IEWLH.js.map} +0 -0
- /package/dist/{chunk-76HB456V.js.map → chunk-S6WBBSII.js.map} +0 -0
- /package/dist/{chunk-CK2CPZXB.js.map → chunk-U4UNC3RP.js.map} +0 -0
- /package/dist/{chunk-J6ATJUEE.js.map → chunk-WBZ4HP7D.js.map} +0 -0
- /package/dist/{chunk-32P6KUZP.js.map → chunk-X3LC6R37.js.map} +0 -0
- /package/dist/{chunk-5E55S5SI.js.map → chunk-XQ4II4BK.js.map} +0 -0
- /package/dist/{chunk-CMUNJZWN.js.map → chunk-YQCA4ZEJ.js.map} +0 -0
- /package/dist/{chunk-Y3MIFC5M.js.map → chunk-ZRCWXJDW.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
2
|
-
THE department badge: PaletteBadge in the department's stored palette colour (departments.color,
|
|
1
|
+
<!-- source-hash: 7d5aadc1cc3d528b8ddb57fc63628042 -->
|
|
2
|
+
THE department badge: PaletteBadge in the department's stored ODS palette colour (departments.color, a BADGE_PALETTE key picked with pickBadgePaletteColor on creation).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
2
|
-
PaletteBadge: the standard StatusBadge
|
|
1
|
+
<!-- source-hash: e631c25c4d08ffc91fe9f0ded1af8e52 -->
|
|
2
|
+
PaletteBadge: the standard StatusBadge in a BADGE_PALETTE colour scheme (ODS tokens only). Anything outside the palette, a hex included, renders the unfilled default badge.
|
|
@@ -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.
|
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import {
|
|
3
|
+
import { BADGE_PALETTE, pickBadgePaletteColor } from '../../../utils/badge-palette';
|
|
4
4
|
import { DepartmentBadge } from '../department-badge';
|
|
5
5
|
import { PaletteBadge } from '../palette-badge';
|
|
6
|
+
import { statusBadgeVariants } from '../status-badge';
|
|
6
7
|
|
|
7
8
|
describe('PaletteBadge', () => {
|
|
8
|
-
it('
|
|
9
|
-
render(<PaletteBadge text="Teal" color="
|
|
10
|
-
|
|
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');
|
|
11
14
|
});
|
|
12
15
|
|
|
13
|
-
it('renders the unfilled default badge for
|
|
14
|
-
const { rerender } = render(<PaletteBadge text="Other" color="
|
|
15
|
-
expect(screen.getByText('Other')).
|
|
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');
|
|
16
19
|
rerender(<PaletteBadge text="Other" color={null} />);
|
|
20
|
+
expect(screen.getByText('Other')).toHaveClass('bg-ods-bg-surface');
|
|
17
21
|
expect(screen.getByText('Other')).not.toHaveAttribute('style');
|
|
18
22
|
});
|
|
19
23
|
|
|
20
|
-
it('
|
|
21
|
-
|
|
22
|
-
expect(
|
|
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);
|
|
23
28
|
});
|
|
24
29
|
});
|
|
25
30
|
|
|
26
31
|
describe('DepartmentBadge', () => {
|
|
27
32
|
it("uses the department's stored palette colour, and the empty label without a department", () => {
|
|
28
|
-
const { rerender } = render(<DepartmentBadge department={{ name: 'Marketing', color: '
|
|
29
|
-
expect(screen.getByText('Marketing')).
|
|
33
|
+
const { rerender } = render(<DepartmentBadge department={{ name: 'Marketing', color: 'pink' }} />);
|
|
34
|
+
expect(screen.getByText('Marketing')).toHaveClass('bg-ods-flamingo-pink');
|
|
30
35
|
rerender(<DepartmentBadge department={null} emptyLabel="Unassigned" />);
|
|
31
|
-
expect(screen.getByText('Unassigned')).
|
|
36
|
+
expect(screen.getByText('Unassigned')).toHaveClass('bg-ods-bg-surface');
|
|
32
37
|
});
|
|
33
38
|
});
|
|
34
39
|
|
|
35
|
-
describe('
|
|
36
|
-
it('picks a palette key that is not taken
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
for (let run = 0; run < 10; run++) expect(pickPresetColor({ avoid: taken })).toBe('teal');
|
|
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);
|
|
40
44
|
});
|
|
41
45
|
|
|
42
46
|
it('repeats a colour only once every colour is taken', () => {
|
|
43
|
-
|
|
44
|
-
expect(everything).toContain(pickPresetColor({ avoid: everything }));
|
|
45
|
-
expect(pickPresetColor({ avoid: everything })).not.toBe('neutral');
|
|
47
|
+
expect(BADGE_PALETTE).toContain(pickBadgePaletteColor({ avoid: [...BADGE_PALETTE], random: () => 0.5 }));
|
|
46
48
|
});
|
|
47
49
|
});
|
|
@@ -3,7 +3,6 @@
|
|
|
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';
|
|
7
6
|
import { HEX_PATTERN, hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from '../../utils/ods-color-utils';
|
|
8
7
|
import { Chevron02DownIcon } from '../icons-v2-generated/arrows/chevron-02-down-icon';
|
|
9
8
|
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
@@ -12,10 +11,27 @@ import { ColorSwatch } from './color-swatch';
|
|
|
12
11
|
import { Input } from './input';
|
|
13
12
|
import { InputTrigger } from './input-trigger';
|
|
14
13
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export interface ColorPreset {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
color: string;
|
|
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
|
+
];
|
|
19
35
|
|
|
20
36
|
export const CUSTOM_PRESET_KEY = 'custom';
|
|
21
37
|
export const DEFAULT_CUSTOM_STATUS_COLOR = '#888888';
|
|
@@ -14,9 +14,9 @@ export interface DepartmentBadgeProps {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* THE department badge: the shared `PaletteBadge` in the department's own colour.
|
|
17
|
-
* The colour is data, `departments.color`, a `
|
|
18
|
-
* (`
|
|
19
|
-
* is listed in code.
|
|
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
20
|
*/
|
|
21
21
|
export function DepartmentBadge({
|
|
22
22
|
department,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { HEX_PATTERN, getReadableTextColor } from '../../utils/ods-color-utils';
|
|
3
|
+
import { isBadgePaletteKey } from '../../utils/badge-palette';
|
|
5
4
|
import { StatusBadge, type StatusBadgeProps } from './status-badge';
|
|
6
5
|
|
|
7
6
|
export interface PaletteBadgeProps {
|
|
8
7
|
text: string;
|
|
9
8
|
/**
|
|
10
|
-
* A `
|
|
11
|
-
*
|
|
12
|
-
* `neutral` preset's fill, so an uncoloured row looks like every other plain badge.
|
|
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.
|
|
13
11
|
*/
|
|
14
12
|
color?: string | null;
|
|
15
13
|
className?: string;
|
|
@@ -18,22 +16,19 @@ export interface PaletteBadgeProps {
|
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* THE badge for anything that carries its own colour
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* height of every other badge.
|
|
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.
|
|
26
23
|
*/
|
|
27
24
|
export function PaletteBadge({ text, color, className, variant = 'button' }: PaletteBadgeProps) {
|
|
28
|
-
const fill = colorPreset(color)?.color ?? (color && HEX_PATTERN.test(color) ? color : null);
|
|
29
25
|
return (
|
|
30
26
|
<StatusBadge
|
|
31
27
|
text={text}
|
|
32
|
-
colorScheme=
|
|
28
|
+
colorScheme={isBadgePaletteKey(color) ? color : 'default'}
|
|
33
29
|
variant={variant}
|
|
34
30
|
singleLine
|
|
35
31
|
className={className}
|
|
36
|
-
style={fill ? { backgroundColor: fill, color: getReadableTextColor(fill) } : undefined}
|
|
37
32
|
/>
|
|
38
33
|
);
|
|
39
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,7 +20,7 @@ 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 `
|
|
23
|
+
/** The department's badge colour: a `BADGE_PALETTE` key (an ODS colour scheme) picked at random (`pickBadgePaletteColor`) when the row is created. */
|
|
24
24
|
color: string | null;
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -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,4 +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
|
-
|
|
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';
|