@flamingo-stack/openframe-frontend-core 0.0.629-2171.6182.1 → 0.0.629

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.
Files changed (182) hide show
  1. package/dist/{chunk-RAPPN6MN.cjs → chunk-2MMEPNSX.cjs} +3 -3
  2. package/dist/{chunk-RAPPN6MN.cjs.map → chunk-2MMEPNSX.cjs.map} +1 -1
  3. package/dist/{chunk-NBM7ZB6T.js → chunk-2MXKO5BN.js} +12 -12
  4. package/dist/{chunk-R46TW4LX.cjs → chunk-2ZSGDKZI.cjs} +9 -9
  5. package/dist/{chunk-R46TW4LX.cjs.map → chunk-2ZSGDKZI.cjs.map} +1 -1
  6. package/dist/{chunk-P7UT2YSC.cjs → chunk-3IXDZI3R.cjs} +3 -3
  7. package/dist/{chunk-P7UT2YSC.cjs.map → chunk-3IXDZI3R.cjs.map} +1 -1
  8. package/dist/{chunk-FYC3W72E.cjs → chunk-3ZY4CE7N.cjs} +6 -6
  9. package/dist/{chunk-FYC3W72E.cjs.map → chunk-3ZY4CE7N.cjs.map} +1 -1
  10. package/dist/{chunk-HRRKZWFF.js → chunk-4NMVDTHA.js} +8 -10
  11. package/dist/{chunk-HRRKZWFF.js.map → chunk-4NMVDTHA.js.map} +1 -1
  12. package/dist/{chunk-MIOE7FYN.js → chunk-4VPCIREO.js} +3 -3
  13. package/dist/{chunk-FTWVYXNP.cjs → chunk-5JAB5LVO.cjs} +34 -34
  14. package/dist/{chunk-FTWVYXNP.cjs.map → chunk-5JAB5LVO.cjs.map} +1 -1
  15. package/dist/{chunk-JRYS4VMV.js → chunk-5LIDR7HL.js} +79 -4
  16. package/dist/{chunk-JRYS4VMV.js.map → chunk-5LIDR7HL.js.map} +1 -1
  17. package/dist/{chunk-DDUG42FK.cjs → chunk-5OMBSMRI.cjs} +26 -28
  18. package/dist/chunk-5OMBSMRI.cjs.map +1 -0
  19. package/dist/{chunk-CHRPZ5PV.cjs → chunk-7P6M5G3W.cjs} +25 -25
  20. package/dist/{chunk-CHRPZ5PV.cjs.map → chunk-7P6M5G3W.cjs.map} +1 -1
  21. package/dist/{chunk-ZOMGXH7C.js → chunk-BVQEU5JB.js} +2 -2
  22. package/dist/{chunk-VOZZQ6HQ.cjs → chunk-CCWI3622.cjs} +4 -4
  23. package/dist/{chunk-VOZZQ6HQ.cjs.map → chunk-CCWI3622.cjs.map} +1 -1
  24. package/dist/{chunk-GUCKPOPQ.cjs → chunk-CKMJQ46H.cjs} +42 -42
  25. package/dist/{chunk-GUCKPOPQ.cjs.map → chunk-CKMJQ46H.cjs.map} +1 -1
  26. package/dist/{chunk-JQSN7D7X.cjs → chunk-CV2SESZT.cjs} +7 -7
  27. package/dist/{chunk-JQSN7D7X.cjs.map → chunk-CV2SESZT.cjs.map} +1 -1
  28. package/dist/{chunk-LZB2UZJY.js → chunk-D5CKXMMC.js} +4 -4
  29. package/dist/{chunk-FENZRLVO.js → chunk-DGY4NVIB.js} +8 -10
  30. package/dist/{chunk-FENZRLVO.js.map → chunk-DGY4NVIB.js.map} +1 -1
  31. package/dist/{chunk-BQ6QZUZ6.cjs → chunk-DLHGJYYA.cjs} +83 -83
  32. package/dist/{chunk-BQ6QZUZ6.cjs.map → chunk-DLHGJYYA.cjs.map} +1 -1
  33. package/dist/{chunk-4E7XCEV3.cjs → chunk-EHAYNUOL.cjs} +2 -77
  34. package/dist/chunk-EHAYNUOL.cjs.map +1 -0
  35. package/dist/{chunk-X5NN4NJM.js → chunk-F2KBCLUG.js} +2 -2
  36. package/dist/{chunk-USIRWQJ3.js → chunk-FKBM6U43.js} +1 -76
  37. package/dist/{chunk-USIRWQJ3.js.map → chunk-FKBM6U43.js.map} +1 -1
  38. package/dist/{chunk-5BUEB2WQ.js → chunk-GR3WOOM7.js} +12 -12
  39. package/dist/{chunk-TV6NXNKO.cjs → chunk-HVWNOPDV.cjs} +5 -5
  40. package/dist/{chunk-TV6NXNKO.cjs.map → chunk-HVWNOPDV.cjs.map} +1 -1
  41. package/dist/{chunk-QIVX7F3N.cjs → chunk-JJUV7Z4L.cjs} +27 -27
  42. package/dist/{chunk-QIVX7F3N.cjs.map → chunk-JJUV7Z4L.cjs.map} +1 -1
  43. package/dist/{chunk-53ARMJHM.cjs → chunk-JONR3BDJ.cjs} +37 -37
  44. package/dist/{chunk-53ARMJHM.cjs.map → chunk-JONR3BDJ.cjs.map} +1 -1
  45. package/dist/{chunk-G5FL4QTN.cjs → chunk-K7EJ7HYJ.cjs} +18 -18
  46. package/dist/{chunk-G5FL4QTN.cjs.map → chunk-K7EJ7HYJ.cjs.map} +1 -1
  47. package/dist/{chunk-KAG3SX3R.cjs → chunk-KO52PXL4.cjs} +20 -22
  48. package/dist/chunk-KO52PXL4.cjs.map +1 -0
  49. package/dist/{chunk-F4JGAGI3.cjs → chunk-LHYRLL64.cjs} +47 -49
  50. package/dist/chunk-LHYRLL64.cjs.map +1 -0
  51. package/dist/{chunk-65IVNHBS.js → chunk-LQLL4S4V.js} +4 -4
  52. package/dist/{chunk-CIRD5P4U.js → chunk-MOB5AA3X.js} +7 -7
  53. package/dist/{chunk-LUBIWC3N.js → chunk-MTLDYBXK.js} +8 -8
  54. package/dist/{chunk-L5FEAOGJ.js → chunk-ON7663OW.js} +354 -8
  55. package/dist/chunk-ON7663OW.js.map +1 -0
  56. package/dist/{chunk-55X46LKR.cjs → chunk-OQHFHKUG.cjs} +100 -450
  57. package/dist/chunk-OQHFHKUG.cjs.map +1 -0
  58. package/dist/{chunk-7ZDPJ6SW.js → chunk-OXTV63QO.js} +4 -4
  59. package/dist/{chunk-WYELOUP4.js → chunk-PFBMVQ5R.js} +6 -6
  60. package/dist/{chunk-SOUGXQJE.js → chunk-PJZYJDR7.js} +4 -4
  61. package/dist/{chunk-NDIPDU36.js → chunk-QGWBMPQY.js} +28 -16
  62. package/dist/{chunk-NDIPDU36.js.map → chunk-QGWBMPQY.js.map} +1 -1
  63. package/dist/{chunk-2J7EFH4V.js → chunk-QS2QCXBH.js} +30 -380
  64. package/dist/chunk-QS2QCXBH.js.map +1 -0
  65. package/dist/{chunk-76HB456V.js → chunk-S6WBBSII.js} +5 -5
  66. package/dist/{chunk-BS6ASI3D.js → chunk-SCPJ53CM.js} +3 -3
  67. package/dist/{chunk-D7VNHPJB.js → chunk-T46STYS2.js} +8 -10
  68. package/dist/{chunk-D7VNHPJB.js.map → chunk-T46STYS2.js.map} +1 -1
  69. package/dist/{chunk-6I3KNDBF.cjs → chunk-U7TTQV4N.cjs} +3 -3
  70. package/dist/{chunk-6I3KNDBF.cjs.map → chunk-U7TTQV4N.cjs.map} +1 -1
  71. package/dist/{chunk-ZYDNPUSH.cjs → chunk-UNI3POHU.cjs} +625 -279
  72. package/dist/chunk-UNI3POHU.cjs.map +1 -0
  73. package/dist/{chunk-Y2ZRUCYH.cjs → chunk-W523NIJ6.cjs} +15 -15
  74. package/dist/{chunk-Y2ZRUCYH.cjs.map → chunk-W523NIJ6.cjs.map} +1 -1
  75. package/dist/{chunk-J6ATJUEE.js → chunk-WBZ4HP7D.js} +4 -4
  76. package/dist/{chunk-CP3R4GRA.cjs → chunk-WR67VM2J.cjs} +293 -281
  77. package/dist/chunk-WR67VM2J.cjs.map +1 -0
  78. package/dist/{chunk-32P6KUZP.js → chunk-X3LC6R37.js} +2 -2
  79. package/dist/{chunk-ELKTBTGR.cjs → chunk-XNC37UQP.cjs} +105 -105
  80. package/dist/{chunk-ELKTBTGR.cjs.map → chunk-XNC37UQP.cjs.map} +1 -1
  81. package/dist/{chunk-CMUNJZWN.js → chunk-YQCA4ZEJ.js} +2 -2
  82. package/dist/{chunk-ZI27ALYX.cjs → chunk-YXWGSDK4.cjs} +80 -5
  83. package/dist/chunk-YXWGSDK4.cjs.map +1 -0
  84. package/dist/components/case-studies/index.cjs +14 -14
  85. package/dist/components/case-studies/index.js +8 -8
  86. package/dist/components/chat/index.cjs +5 -5
  87. package/dist/components/chat/index.js +4 -4
  88. package/dist/components/contact/index.cjs +9 -9
  89. package/dist/components/contact/index.js +8 -8
  90. package/dist/components/docs/index.cjs +12 -12
  91. package/dist/components/docs/index.js +11 -11
  92. package/dist/components/embeds/index.cjs +9 -9
  93. package/dist/components/embeds/index.js +8 -8
  94. package/dist/components/faq/index.cjs +10 -10
  95. package/dist/components/faq/index.js +9 -9
  96. package/dist/components/features/index.cjs +8 -8
  97. package/dist/components/features/index.js +7 -7
  98. package/dist/components/help-center-pages/index.cjs +31 -31
  99. package/dist/components/help-center-pages/index.js +22 -22
  100. package/dist/components/index.cjs +69 -71
  101. package/dist/components/index.cjs.map +1 -1
  102. package/dist/components/index.js +24 -26
  103. package/dist/components/index.js.map +1 -1
  104. package/dist/components/meeting-scheduler/index.cjs +49 -49
  105. package/dist/components/meeting-scheduler/index.js +9 -9
  106. package/dist/components/navigation/index.cjs +11 -11
  107. package/dist/components/navigation/index.js +10 -10
  108. package/dist/components/onboarding-guides/index.cjs +12 -12
  109. package/dist/components/onboarding-guides/index.js +11 -11
  110. package/dist/components/related-content/index.cjs +6 -6
  111. package/dist/components/related-content/index.js +5 -5
  112. package/dist/components/tickets/index.cjs +13 -13
  113. package/dist/components/tickets/index.js +12 -12
  114. package/dist/components/ui/color-preset-select.d.ts +5 -4
  115. package/dist/components/ui/color-preset-select.d.ts.map +1 -1
  116. package/dist/components/ui/department-badge.d.ts +3 -3
  117. package/dist/components/ui/index.cjs +8 -10
  118. package/dist/components/ui/index.cjs.map +1 -1
  119. package/dist/components/ui/index.js +7 -9
  120. package/dist/components/ui/palette-badge.d.ts +6 -8
  121. package/dist/components/ui/palette-badge.d.ts.map +1 -1
  122. package/dist/components/ui/status-badge.d.ts +1 -1
  123. package/dist/components/ui/status-badge.d.ts.map +1 -1
  124. package/dist/hooks/index.cjs +5 -5
  125. package/dist/hooks/index.js +4 -4
  126. package/dist/index.cjs +18 -18
  127. package/dist/index.cjs.map +1 -1
  128. package/dist/index.js +46 -46
  129. package/dist/types/department.d.ts +1 -1
  130. package/dist/types/department.d.ts.map +1 -1
  131. package/dist/utils/badge-palette.d.ts +18 -0
  132. package/dist/utils/badge-palette.d.ts.map +1 -0
  133. package/dist/utils/index.cjs +21 -24
  134. package/dist/utils/index.cjs.map +1 -1
  135. package/dist/utils/index.d.ts +1 -1
  136. package/dist/utils/index.d.ts.map +1 -1
  137. package/dist/utils/index.js +19 -22
  138. package/dist/utils/index.js.map +1 -1
  139. package/package.json +1 -1
  140. package/src/components/ui/.department-badge.md +2 -2
  141. package/src/components/ui/.palette-badge.md +2 -2
  142. package/src/components/ui/.status-badge.md +2 -2
  143. package/src/components/ui/__tests__/department-badge.test.tsx +23 -21
  144. package/src/components/ui/color-preset-select.tsx +21 -5
  145. package/src/components/ui/department-badge.tsx +3 -3
  146. package/src/components/ui/palette-badge.tsx +8 -13
  147. package/src/components/ui/status-badge.tsx +5 -0
  148. package/src/types/department.ts +1 -1
  149. package/src/utils/.badge-palette.md +2 -0
  150. package/src/utils/badge-palette.ts +38 -0
  151. package/src/utils/index.ts +2 -1
  152. package/dist/chunk-2J7EFH4V.js.map +0 -1
  153. package/dist/chunk-4E7XCEV3.cjs.map +0 -1
  154. package/dist/chunk-55X46LKR.cjs.map +0 -1
  155. package/dist/chunk-CP3R4GRA.cjs.map +0 -1
  156. package/dist/chunk-DDUG42FK.cjs.map +0 -1
  157. package/dist/chunk-F4JGAGI3.cjs.map +0 -1
  158. package/dist/chunk-KAG3SX3R.cjs.map +0 -1
  159. package/dist/chunk-L5FEAOGJ.js.map +0 -1
  160. package/dist/chunk-ZI27ALYX.cjs.map +0 -1
  161. package/dist/chunk-ZYDNPUSH.cjs.map +0 -1
  162. package/dist/utils/color-presets.d.ts +0 -24
  163. package/dist/utils/color-presets.d.ts.map +0 -1
  164. package/src/utils/.color-presets.md +0 -2
  165. package/src/utils/color-presets.ts +0 -48
  166. /package/dist/{chunk-NBM7ZB6T.js.map → chunk-2MXKO5BN.js.map} +0 -0
  167. /package/dist/{chunk-MIOE7FYN.js.map → chunk-4VPCIREO.js.map} +0 -0
  168. /package/dist/{chunk-ZOMGXH7C.js.map → chunk-BVQEU5JB.js.map} +0 -0
  169. /package/dist/{chunk-LZB2UZJY.js.map → chunk-D5CKXMMC.js.map} +0 -0
  170. /package/dist/{chunk-X5NN4NJM.js.map → chunk-F2KBCLUG.js.map} +0 -0
  171. /package/dist/{chunk-5BUEB2WQ.js.map → chunk-GR3WOOM7.js.map} +0 -0
  172. /package/dist/{chunk-65IVNHBS.js.map → chunk-LQLL4S4V.js.map} +0 -0
  173. /package/dist/{chunk-CIRD5P4U.js.map → chunk-MOB5AA3X.js.map} +0 -0
  174. /package/dist/{chunk-LUBIWC3N.js.map → chunk-MTLDYBXK.js.map} +0 -0
  175. /package/dist/{chunk-7ZDPJ6SW.js.map → chunk-OXTV63QO.js.map} +0 -0
  176. /package/dist/{chunk-WYELOUP4.js.map → chunk-PFBMVQ5R.js.map} +0 -0
  177. /package/dist/{chunk-SOUGXQJE.js.map → chunk-PJZYJDR7.js.map} +0 -0
  178. /package/dist/{chunk-76HB456V.js.map → chunk-S6WBBSII.js.map} +0 -0
  179. /package/dist/{chunk-BS6ASI3D.js.map → chunk-SCPJ53CM.js.map} +0 -0
  180. /package/dist/{chunk-J6ATJUEE.js.map → chunk-WBZ4HP7D.js.map} +0 -0
  181. /package/dist/{chunk-32P6KUZP.js.map → chunk-X3LC6R37.js.map} +0 -0
  182. /package/dist/{chunk-CMUNJZWN.js.map → chunk-YQCA4ZEJ.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flamingo-stack/openframe-frontend-core",
3
- "version": "0.0.629-2171.6182.1",
3
+ "version": "0.0.629",
4
4
  "description": "Shared design system and components for all Flamingo platforms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,2 +1,2 @@
1
- <!-- source-hash: dfe20cd7ef027c93962000f5d153468c -->
2
- THE department badge: PaletteBadge in the department's stored palette colour (departments.color, picked at random with pickPresetColor on creation).
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: 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.
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: 0935f3d6a806783b496a5b5cb096c40a -->
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 { COLOR_PRESETS, pickPresetColor } from '../../../utils/color-presets';
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('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)' });
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 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
+ 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('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)' });
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: 'sky' }} />);
29
- expect(screen.getByText('Marketing')).toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
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')).not.toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
36
+ expect(screen.getByText('Unassigned')).toHaveClass('bg-ods-bg-surface');
32
37
  });
33
38
  });
34
39
 
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
+ 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
- const everything = COLOR_PRESETS.map(preset => preset.key);
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 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;
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 `COLOR_PRESETS` key picked at random
18
- * (`pickPresetColor`) when the department is created, so no department or colour
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 { colorPreset } from '../../utils/color-presets';
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 `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.
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 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.
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="default"
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',
@@ -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 `COLOR_PRESETS` key picked at random (`pickPresetColor`) when the row is created. */
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,2 @@
1
+ <!-- source-hash: 98232318cb5d2ba33c74f50a43c66363 -->
2
+ BADGE_PALETTE: the ODS StatusBadge colour schemes (five hues, solid and soft) a row whose colour is data picks from, plus isBadgePaletteKey and pickBadgePaletteColor (random, prefers an unused key).
@@ -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
+ }
@@ -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
- export { COLOR_PRESETS, colorPreset, pickPresetColor, type ColorPreset } from './color-presets';
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';