@multiplatform.one/components 10.1.2 → 10.1.4

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 (102) hide show
  1. package/dist/cjs/layouts/timeline.cjs +0 -1
  2. package/dist/cjs/layouts/timeline.native.cjs +0 -1
  3. package/dist/cjs/layouts/timeline.native.js +0 -1
  4. package/dist/cjs/layouts/timeline.native.js.map +1 -1
  5. package/dist/cjs/views/Calendar.cjs +54 -76
  6. package/dist/cjs/views/Calendar.native.cjs +54 -76
  7. package/dist/cjs/views/Calendar.native.js +54 -76
  8. package/dist/cjs/views/Calendar.native.js.map +1 -1
  9. package/dist/cjs/views/Gantt.cjs +185 -69
  10. package/dist/cjs/views/Gantt.native.cjs +190 -72
  11. package/dist/cjs/views/Gantt.native.js +190 -72
  12. package/dist/cjs/views/Gantt.native.js.map +1 -1
  13. package/dist/cjs/views/GanttDateGrip.cjs +20 -14
  14. package/dist/cjs/views/GanttDateGrip.native.cjs +24 -14
  15. package/dist/cjs/views/GanttDateGrip.native.js +24 -14
  16. package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
  17. package/dist/cjs/views/GanttGripDot.cjs +43 -0
  18. package/dist/cjs/views/GanttGripDot.native.cjs +46 -0
  19. package/dist/cjs/views/GanttGripDot.native.js +48 -0
  20. package/dist/cjs/views/GanttGripDot.native.js.map +1 -0
  21. package/dist/cjs/views/eventTint.cjs +242 -0
  22. package/dist/cjs/views/eventTint.native.cjs +346 -0
  23. package/dist/cjs/views/eventTint.native.js +348 -0
  24. package/dist/cjs/views/eventTint.native.js.map +1 -0
  25. package/dist/esm/layouts/timeline.mjs +0 -1
  26. package/dist/esm/layouts/timeline.mjs.map +1 -1
  27. package/dist/esm/layouts/timeline.native.js +0 -1
  28. package/dist/esm/layouts/timeline.native.js.map +1 -1
  29. package/dist/esm/views/Calendar.mjs +53 -75
  30. package/dist/esm/views/Calendar.mjs.map +1 -1
  31. package/dist/esm/views/Calendar.native.js +53 -75
  32. package/dist/esm/views/Calendar.native.js.map +1 -1
  33. package/dist/esm/views/Gantt.mjs +186 -70
  34. package/dist/esm/views/Gantt.mjs.map +1 -1
  35. package/dist/esm/views/Gantt.native.js +191 -73
  36. package/dist/esm/views/Gantt.native.js.map +1 -1
  37. package/dist/esm/views/GanttDateGrip.mjs +21 -15
  38. package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
  39. package/dist/esm/views/GanttDateGrip.native.js +25 -15
  40. package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
  41. package/dist/esm/views/GanttGripDot.mjs +24 -0
  42. package/dist/esm/views/GanttGripDot.mjs.map +1 -0
  43. package/dist/esm/views/GanttGripDot.native.js +25 -0
  44. package/dist/esm/views/GanttGripDot.native.js.map +1 -0
  45. package/dist/esm/views/eventTint.mjs +196 -0
  46. package/dist/esm/views/eventTint.mjs.map +1 -0
  47. package/dist/esm/views/eventTint.native.js +298 -0
  48. package/dist/esm/views/eventTint.native.js.map +1 -0
  49. package/dist/jsx/layouts/timeline.mjs +0 -1
  50. package/dist/jsx/layouts/timeline.mjs.map +1 -1
  51. package/dist/jsx/layouts/timeline.native.cjs +0 -1
  52. package/dist/jsx/layouts/timeline.native.js +0 -1
  53. package/dist/jsx/layouts/timeline.native.js.map +1 -1
  54. package/dist/jsx/views/Calendar.mjs +53 -75
  55. package/dist/jsx/views/Calendar.mjs.map +1 -1
  56. package/dist/jsx/views/Calendar.native.cjs +54 -76
  57. package/dist/jsx/views/Calendar.native.js +54 -76
  58. package/dist/jsx/views/Calendar.native.js.map +1 -1
  59. package/dist/jsx/views/Gantt.mjs +186 -70
  60. package/dist/jsx/views/Gantt.mjs.map +1 -1
  61. package/dist/jsx/views/Gantt.native.cjs +190 -72
  62. package/dist/jsx/views/Gantt.native.js +190 -72
  63. package/dist/jsx/views/Gantt.native.js.map +1 -1
  64. package/dist/jsx/views/GanttDateGrip.mjs +21 -15
  65. package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
  66. package/dist/jsx/views/GanttDateGrip.native.cjs +24 -14
  67. package/dist/jsx/views/GanttDateGrip.native.js +24 -14
  68. package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
  69. package/dist/jsx/views/GanttGripDot.mjs +24 -0
  70. package/dist/jsx/views/GanttGripDot.mjs.map +1 -0
  71. package/dist/jsx/views/GanttGripDot.native.cjs +46 -0
  72. package/dist/jsx/views/GanttGripDot.native.js +48 -0
  73. package/dist/jsx/views/GanttGripDot.native.js.map +1 -0
  74. package/dist/jsx/views/eventTint.mjs +196 -0
  75. package/dist/jsx/views/eventTint.mjs.map +1 -0
  76. package/dist/jsx/views/eventTint.native.cjs +346 -0
  77. package/dist/jsx/views/eventTint.native.js +348 -0
  78. package/dist/jsx/views/eventTint.native.js.map +1 -0
  79. package/package.json +7 -7
  80. package/src/hoverTouchPath.coarse.spec.tsx +28 -4
  81. package/src/layouts/timeline.replyInset.spec.tsx +72 -22
  82. package/src/layouts/timeline.tsx +0 -1
  83. package/src/views/Calendar.eventFill.spec.tsx +44 -9
  84. package/src/views/Calendar.tsx +23 -31
  85. package/src/views/Gantt.barInk.spec.tsx +257 -0
  86. package/src/views/Gantt.grips.spec.tsx +226 -0
  87. package/src/views/Gantt.tint.palette.spec.ts +288 -0
  88. package/src/views/Gantt.tsx +224 -65
  89. package/src/views/GanttDateGrip.native.spec.tsx +8 -0
  90. package/src/views/GanttDateGrip.tsx +28 -17
  91. package/src/views/GanttGripDot.tsx +36 -0
  92. package/src/views/dataIdentity.spec.tsx +29 -13
  93. package/src/views/eventTint.ts +305 -0
  94. package/types/layouts/timeline.d.ts.map +1 -1
  95. package/types/views/Calendar.d.ts.map +1 -1
  96. package/types/views/Gantt.d.ts.map +1 -1
  97. package/types/views/GanttDateGrip.d.ts +7 -0
  98. package/types/views/GanttDateGrip.d.ts.map +1 -1
  99. package/types/views/GanttGripDot.d.ts +9 -0
  100. package/types/views/GanttGripDot.d.ts.map +1 -0
  101. package/types/views/eventTint.d.ts +72 -0
  102. package/types/views/eventTint.d.ts.map +1 -0
@@ -1,4 +1,6 @@
1
1
  import { act, cleanup } from "@testing-library/react";
2
+ import * as Colors from "@tamagui/colors";
3
+ import { normalizeToHex } from "@multiplatform.one/theme";
2
4
  import { atomicStyle, renderWithProviders } from "@multiplatform.one/test-utils";
3
5
  import { afterEach, describe, expect, it, vi } from "vitest";
4
6
  import { Calendar, type CalendarEvent } from "./Calendar";
@@ -63,23 +65,56 @@ describe("Calendar time-grid event fill (FZ-9216, LC-297)", () => {
63
65
  it("an unselected event is a tint of its colour with a solid leading bar and primary ink", () => {
64
66
  const { title, chip } = setup(null);
65
67
  const block = chip("Standup");
66
- const tint = block.querySelector("[data-calendar-event-tint]")!;
67
- expect(tint).not.toBeNull();
68
+ const tint = block;
68
69
  expect(fiberProps(block, "position").position).toBe("relative");
69
- expect(fiberProps(tint, "opacity").opacity).toBeLessThan(0.3);
70
- expect(fiberProps(tint, "backgroundColor").backgroundColor).toBe(amber);
70
+ expect(tint.getAttribute("data-calendar-event-tint")).toBe("rest");
71
+ expect(fiberProps(tint, "backgroundColor").opacity).toBe(1);
72
+ expect(fiberProps(tint, "backgroundColor").backgroundColor).toMatch(/^#[0-9a-f]{6}$/);
73
+ expect(fiberProps(tint, "backgroundColor").backgroundColor).not.toBe(amber);
71
74
  const bar = block.querySelector("[data-calendar-event-bar]")!;
72
75
  expect(fiberProps(bar, "backgroundColor").backgroundColor).toBe(amber);
73
76
  expect(fiberProps(title("Standup"), "color").color).toBe("color-12");
74
77
  });
75
78
 
79
+ it("in light a ramp colour's title takes that hue's 12 and its time the 11 where it reads", () => {
80
+ const gold = Colors.amber.amber9;
81
+ const view = renderWithProviders(
82
+ <Calendar
83
+ events={[{ ...standup, color: gold }]}
84
+ viewType="day"
85
+ initialDate={march10}
86
+ height={600}
87
+ />,
88
+ );
89
+ const primary = normalizeToHex(Colors.amber.amber12);
90
+ expect(fiberProps(view.getByText("Standup"), "color").color).toBe(primary);
91
+ expect(fiberProps(view.getByText(/^9:00/), "color").color).not.toBe(primary);
92
+ });
93
+
94
+ it("a time stays dimmer than its title even where the hue's 11 fails AA on the fill", () => {
95
+ const view = renderWithProviders(
96
+ <Calendar
97
+ events={[{ ...standup, color: Colors.green.green9 }]}
98
+ viewType="day"
99
+ initialDate={march10}
100
+ height={600}
101
+ />,
102
+ );
103
+ const title = fiberProps(view.getByText("Standup"), "color").color;
104
+ const time = fiberProps(view.getByText(/^9:00/), "color").color;
105
+ expect(title).toBe(normalizeToHex(Colors.green.green12));
106
+ expect(time).not.toBe(title);
107
+ expect(time).not.toBe(normalizeToHex(Colors.green.green11));
108
+ });
109
+
76
110
  it("the selected event keeps its tint, deepened, with a ring in its colour and primary ink", () => {
77
111
  const { title, chip } = setup("ev-1");
78
112
  const block = chip("Standup");
79
- const tint = block.querySelector("[data-calendar-event-tint]")!;
80
- const rest = chip("Review").querySelector("[data-calendar-event-tint]")!;
81
- expect(fiberProps(tint, "opacity").opacity).toBeGreaterThan(
82
- fiberProps(rest, "opacity").opacity,
113
+ const tint = block;
114
+ const rest = chip("Review");
115
+ expect(tint.getAttribute("data-calendar-event-tint")).toBe("selected");
116
+ expect(fiberProps(tint, "backgroundColor").backgroundColor).not.toBe(
117
+ fiberProps(rest, "backgroundColor").backgroundColor,
83
118
  );
84
119
  expect(fiberProps(block, "borderColor").borderColor).toBe(amber);
85
120
  expect(fiberProps(title("Standup"), "color").color).toBe("color-12");
@@ -100,7 +135,7 @@ describe("Calendar time-grid event fill (FZ-9216, LC-297)", () => {
100
135
  while (node && !node.querySelector("[data-calendar-event-bar]")) node = node.parentElement;
101
136
  expect(node).not.toBeNull();
102
137
  expect(fiberProps(node!, "position").position).toBe("relative");
103
- expect(node!.querySelector("[data-calendar-event-tint]")).not.toBeNull();
138
+ expect(node!.getAttribute("data-calendar-event-tint")).toBe("rest");
104
139
  expect(fiberProps(text, "color").color).toBe("color-12");
105
140
  });
106
141
 
@@ -56,9 +56,18 @@ import {
56
56
  YStack,
57
57
  isWeb,
58
58
  styled,
59
+ useTheme,
59
60
  type YStackProps,
60
61
  } from "tamagui";
61
62
  import { ScrollView } from "../ScrollView";
63
+ import {
64
+ EVENT_BAR_PX,
65
+ EVENT_GRIP_DOT_PX,
66
+ eventLabelInk,
67
+ eventPaint,
68
+ useEventDark,
69
+ type EventThemeValues,
70
+ } from "./eventTint";
62
71
  import { useDirection } from "../hooks/useDirection";
63
72
  import { Text } from "../Text";
64
73
 
@@ -412,10 +421,7 @@ const TOUCH_SLOP_PX = 8;
412
421
  const MIN_BLOCK_PX = 18;
413
422
  /** Resize handle hit zone (Axiom 12 touch-target floor). */
414
423
  const RESIZE_ZONE_PX = MIN_PRESS_TARGET;
415
- const GRIP_DOT_PX = 10;
416
- const EVENT_TINT_OPACITY = 0.22;
417
- const EVENT_SELECTED_TINT_OPACITY = 0.38;
418
- const EVENT_BAR_PX = 3;
424
+ const GRIP_DOT_PX = EVENT_GRIP_DOT_PX;
419
425
  const GRIP_DOT_INSET_PX = 6;
420
426
  /** Month-view chip visual floor (hit slop fills the 44px target, DG-LAY-04). */
421
427
  const MONTH_CHIP_MIN_PX = 24;
@@ -799,6 +805,8 @@ export function Calendar({
799
805
  const { knobProps: nestedKnobs } = useResolvedKnobs();
800
806
  const { px: nestedPx, hitSlop: nestedHitSlop, ...nestedBox } = nestedKnobs.nestedControl;
801
807
  const identity = useChartPalette().single;
808
+ const theme = useTheme() as unknown as EventThemeValues;
809
+ const dark = useEventDark();
802
810
  const onIdentity = useReadableTextOn(identity);
803
811
  const onMark = useReadableTextOn(componentColors.indicator.mark);
804
812
  const calendarId = useId();
@@ -1793,13 +1801,15 @@ export function Calendar({
1793
1801
  </YStack>
1794
1802
  );
1795
1803
  }
1804
+ const chipPaint = eventPaint(theme, event.color || identity, "rest", { dark });
1796
1805
  return (
1797
1806
  <YStack
1798
1807
  key={event.id}
1799
1808
  {...knobProps.borderRadius}
1800
1809
  position="relative"
1801
- backgroundColor="background"
1810
+ backgroundColor={(chipPaint ?? "background") as any}
1802
1811
  overflow="hidden"
1812
+ data-calendar-event-tint="rest"
1803
1813
  padding={`${compact ? "1" : "2"}`}
1804
1814
  paddingInlineStart={EVENT_BAR_PX + 4}
1805
1815
  // DG-LAY-04: month-view chips measured 23px tall — floor the visual
@@ -1823,17 +1833,6 @@ export function Calendar({
1823
1833
  }
1824
1834
  }
1825
1835
  >
1826
- <YStack
1827
- position="absolute"
1828
- top={0}
1829
- bottom={0}
1830
- left={0}
1831
- right={0}
1832
- backgroundColor={(event.color || identity) as any}
1833
- opacity={EVENT_TINT_OPACITY}
1834
- pointerEvents="none"
1835
- {...{ "data-calendar-event-tint": "true" }}
1836
- />
1837
1836
  <YStack
1838
1837
  position="absolute"
1839
1838
  top={0}
@@ -1848,7 +1847,7 @@ export function Calendar({
1848
1847
  {...knobProps.body}
1849
1848
  fontSize={`${compact ? "1" : "2"}`}
1850
1849
  numberOfLines={compact ? 1 : 2}
1851
- color="color-12"
1850
+ color={eventLabelInk(theme, event.color || identity, [chipPaint], dark) as any}
1852
1851
  >
1853
1852
  {event.title}
1854
1853
  </TamaguiText>
@@ -1867,6 +1866,8 @@ export function Calendar({
1867
1866
  draggingEventId,
1868
1867
  identity,
1869
1868
  isRTL,
1869
+ theme,
1870
+ dark,
1870
1871
  ],
1871
1872
  );
1872
1873
 
@@ -2102,8 +2103,9 @@ export function Calendar({
2102
2103
  const selected = selectedId === event.id;
2103
2104
  const gripsShown = selected || focusedEventId === event.id;
2104
2105
  const fill = (event.color || identity) as any;
2105
- const titleInk = "color-12";
2106
- const timeInk = "color-11";
2106
+ const paint = eventPaint(theme, fill, selected ? "selected" : "rest", { dark });
2107
+ const titleInk = eventLabelInk(theme, fill, [paint], dark);
2108
+ const timeInk = eventLabelInk(theme, fill, [paint], dark, "secondary");
2107
2109
  const gripDot = (
2108
2110
  <YStack
2109
2111
  width={GRIP_DOT_PX}
@@ -2138,7 +2140,7 @@ export function Calendar({
2138
2140
  flex={1}
2139
2141
  {...knobProps.borderRadius}
2140
2142
  position="relative"
2141
- backgroundColor="background"
2143
+ backgroundColor={(paint ?? "background") as any}
2142
2144
  padding="1"
2143
2145
  paddingInlineStart={EVENT_BAR_PX + 4}
2144
2146
  overflow="hidden"
@@ -2181,18 +2183,8 @@ export function Calendar({
2181
2183
  {...(hold.holding && holdCueId === event.id ? { scale: 0.97 } : {})}
2182
2184
  {...{ "data-hold": hold.holding && holdCueId === event.id ? "progress" : undefined }}
2183
2185
  {...{ "data-calendar-selected": selected ? "true" : undefined }}
2186
+ {...{ "data-calendar-event-tint": selected ? "selected" : "rest" }}
2184
2187
  >
2185
- <YStack
2186
- position="absolute"
2187
- top={0}
2188
- bottom={0}
2189
- left={0}
2190
- right={0}
2191
- backgroundColor={fill}
2192
- opacity={selected ? EVENT_SELECTED_TINT_OPACITY : EVENT_TINT_OPACITY}
2193
- pointerEvents="none"
2194
- {...{ "data-calendar-event-tint": "true" }}
2195
- />
2196
2188
  <YStack
2197
2189
  position="absolute"
2198
2190
  top={0}
@@ -0,0 +1,257 @@
1
+ import { act, cleanup } from "@testing-library/react";
2
+ import { atomicStyle, renderWithProviders } from "@multiplatform.one/test-utils";
3
+ import {
4
+ Intent,
5
+ aaTextContrastRatio,
6
+ apcaContrast,
7
+ contrastRatio,
8
+ fillLabelLc,
9
+ normalizeToHex,
10
+ relativeLuminance,
11
+ resolveChartPalette,
12
+ } from "@multiplatform.one/theme";
13
+ import type { ReactNode } from "react";
14
+ import { Theme, useTheme } from "tamagui";
15
+ import { afterEach, describe, expect, it, vi } from "vitest";
16
+ import { GanttView, type GanttTask } from "./Gantt";
17
+ import {
18
+ EVENT_BAR_PX,
19
+ EVENT_STRIP_FLOOR,
20
+ EVENT_STRIP_STEP,
21
+ eventPaint,
22
+ eventRamp,
23
+ eventSolid,
24
+ type EventState,
25
+ } from "./eventTint";
26
+
27
+ afterEach(cleanup);
28
+
29
+ const day = (n: number) => new Date(2026, 2, n);
30
+ const [, blue] = resolveChartPalette({ scheme: "light" }).categorical;
31
+ const intents = ["accent", "success", "warning", "error"] as const;
32
+
33
+ const tasks: GanttTask[] = [
34
+ { id: "identity", title: "Identity bar", start: day(2), end: day(12), progress: 40 },
35
+ { id: "explicit", title: "Explicit bar", start: day(2), end: day(12), color: blue, progress: 70 },
36
+ { id: "open", title: "Open bar", start: day(2) },
37
+ ...intents.map((intent) => ({
38
+ id: intent,
39
+ title: `${intent} bar`,
40
+ start: day(2),
41
+ end: day(12),
42
+ intent,
43
+ progress: 50,
44
+ })),
45
+ ];
46
+
47
+ type Values = Record<string, { val?: unknown } | undefined>;
48
+
49
+ function Capture({ into, name }: { into: Record<string, Values>; name: string }) {
50
+ into[name] = useTheme() as unknown as Values;
51
+ return null;
52
+ }
53
+
54
+ function Scheme({ scheme, hue, children }: { scheme: string; hue?: string; children: ReactNode }) {
55
+ return (
56
+ <Theme name={scheme as any}>
57
+ {hue ? <Theme name={hue as any}>{children}</Theme> : children}
58
+ </Theme>
59
+ );
60
+ }
61
+
62
+ function hex(theme: Values, color: string): string {
63
+ const key = color.startsWith("$") ? color.slice(1) : color;
64
+ const raw = theme[key]?.val ?? (color.startsWith("$") ? undefined : color);
65
+ const out = typeof raw === "string" ? normalizeToHex(raw) : null;
66
+ if (!out) throw new Error(`unresolved ${color}`);
67
+ return out;
68
+ }
69
+
70
+ const lum = (h: string) => relativeLuminance(h);
71
+
72
+ function render(scheme: string, hue?: string) {
73
+ const themes: Record<string, Values> = {};
74
+ const view = renderWithProviders(
75
+ <Scheme scheme={scheme} hue={hue}>
76
+ <Capture into={themes} name="base" />
77
+ {intents
78
+ .filter((intent) => intent !== "accent")
79
+ .map((intent) => (
80
+ <Intent key={intent} name={intent}>
81
+ <Capture into={themes} name={intent} />
82
+ </Intent>
83
+ ))}
84
+ <GanttView tasks={tasks} initialDate={day(1)} onItemPress={vi.fn()} />
85
+ </Scheme>,
86
+ );
87
+ return { view, themes };
88
+ }
89
+
90
+ function fiberProps(node: Element, has: string): Record<string, any> {
91
+ const key = Object.keys(node).find((k) => k.startsWith("__reactFiber$"));
92
+ let fiber = key ? (node as any)[key] : null;
93
+ while (fiber && fiber.memoizedProps?.[has] === undefined) fiber = fiber.return;
94
+ return fiber?.memoizedProps ?? {};
95
+ }
96
+
97
+ function assertBar(
98
+ view: ReturnType<typeof render>["view"],
99
+ themes: Record<string, Values>,
100
+ task: GanttTask,
101
+ scheme: string,
102
+ state: EventState,
103
+ ) {
104
+ const bar = view.container.querySelector(`[data-gantt-bar="${task.id}"]`)!;
105
+ expect(bar, task.id).not.toBeNull();
106
+ const tint = bar.querySelector("[data-gantt-bar-state]") as HTMLElement | null;
107
+ expect(tint, `${task.id} paints`).not.toBeNull();
108
+ expect(tint!.getAttribute("data-gantt-bar-state"), `${task.id} state`).toBe(state);
109
+ expect(atomicStyle(tint!).opacity ?? "1", `${task.id} paints opaque`).toBe("1");
110
+ const solid = tint!.querySelector("[data-gantt-bar-fill]")!;
111
+ const theme = task.intent && task.intent !== "accent" ? themes[task.intent] : themes.base;
112
+ const fill = solid.getAttribute("data-gantt-bar-fill")!;
113
+ const dark = scheme === "dark";
114
+ const onSolid = dark ? null : eventSolid(theme, fill, state as "rest" | "selected")!;
115
+ const paint =
116
+ onSolid?.paint ??
117
+ eventPaint(theme, fill, state, { dark, surface: hex(themes.base, "$background") })!;
118
+ expect(tint!.getAttribute("data-gantt-bar-paint"), `${task.id} paint`).toBe(paint);
119
+ const label = bar.querySelector("[data-gantt-bar-ink]");
120
+ expect(label?.textContent, `${task.id} label`).toContain(task.title);
121
+ const ink = hex(theme, label!.getAttribute("data-gantt-bar-ink")!);
122
+ const progress = bar.querySelector("[data-gantt-progress]") as HTMLElement | null;
123
+ if (task.progress) {
124
+ expect(progress, `${task.id} progress strip`).not.toBeNull();
125
+ expect(atomicStyle(progress!).opacity ?? "1", `${task.id} progress opaque`).toBe("1");
126
+ expect(progress!.parentElement, `${task.id} progress clipped by the bar`).toBe(tint);
127
+ const { left, borderRadius } = fiberProps(progress!, "height");
128
+ expect(Number(left), `${task.id} strip clears the leading edge`).toBeGreaterThan(
129
+ dark ? EVENT_BAR_PX : 0,
130
+ );
131
+ expect(Number(borderRadius), `${task.id} strip ends round`).toBeGreaterThan(0);
132
+ const strip = progress!.getAttribute("data-gantt-progress-paint")!;
133
+ expect(
134
+ contrastRatio(lum(strip), lum(paint)),
135
+ `${task.id} strip ${strip} on ${paint}`,
136
+ ).toBeGreaterThanOrEqual(EVENT_STRIP_FLOOR);
137
+ if (onSolid) expect(strip, `${task.id} strip is the on-solid ink`).toBe(ink);
138
+ else {
139
+ const step = eventRamp(theme, fill, true)?.(EVENT_STRIP_STEP);
140
+ if (step) expect(strip, `${task.id} strip holds its step`).toBe(normalizeToHex(step));
141
+ expect(strip, `${task.id} strip is not the label ink`).not.toBe(ink);
142
+ }
143
+ }
144
+ if (onSolid) {
145
+ expect(ink, `light ${task.id} takes the on-solid ink`).toBe(onSolid.ink);
146
+ expect(
147
+ Math.abs(apcaContrast(ink, paint)),
148
+ `light ${task.id}: ${ink} on ${paint} APCA`,
149
+ ).toBeGreaterThanOrEqual(fillLabelLc);
150
+ if (task.intent !== "warning")
151
+ expect(lum(ink), `light ${task.id}: near-white on the solid`).toBeGreaterThan(lum(paint));
152
+ } else {
153
+ const hue12 = eventRamp(theme, fill, true)?.(12);
154
+ const primary = hue12 ? normalizeToHex(hue12)! : hex(theme, "$color-12");
155
+ if (contrastRatio(lum(primary), lum(paint)) >= aaTextContrastRatio)
156
+ expect(ink, `dark ${task.id} keeps ${hue12 ? "its hue's 12" : "$color-12"}`).toBe(primary);
157
+ }
158
+ expect(
159
+ contrastRatio(lum(ink), lum(paint)),
160
+ `${scheme} ${task.id}: ${ink} on ${paint}`,
161
+ ).toBeGreaterThanOrEqual(aaTextContrastRatio);
162
+ }
163
+
164
+ describe("Gantt bar labels read on their fill (FZ-9366)", () => {
165
+ for (const scheme of ["light", "dark"])
166
+ for (const hue of [undefined, "blue", "pink", "purple"])
167
+ it(`${scheme}${hue ? `_${hue}` : ""}: every bar fill, at rest and focused`, () => {
168
+ const { view, themes } = render(scheme, hue);
169
+ for (const task of tasks) assertBar(view, themes, task, scheme, "rest");
170
+ for (const task of tasks) {
171
+ const bar = view.container.querySelector(`[data-gantt-bar="${task.id}"]`) as HTMLElement;
172
+ act(() => bar.focus());
173
+ assertBar(view, themes, task, scheme, "selected");
174
+ }
175
+ });
176
+
177
+ it("a milestone too narrow for its title carries it outside, on the canvas", () => {
178
+ const view = renderWithProviders(
179
+ <GanttView
180
+ tasks={[{ id: "m", title: "Launch", start: day(5), end: day(5), intent: "error" }]}
181
+ initialDate={day(1)}
182
+ />,
183
+ );
184
+ const bar = view.container.querySelector('[data-gantt-bar="m"]')!;
185
+ expect(bar.querySelector("[data-gantt-bar-ink]")).toBeNull();
186
+ const outside = bar.querySelector("[data-gantt-bar-outside-label]");
187
+ expect(outside?.textContent).toBe("Launch");
188
+ expect(fiberProps(outside!.firstElementChild!, "color").color).toBe("$color");
189
+ expect(Number(fiberProps(outside!, "width").width)).toBeGreaterThan(44);
190
+ });
191
+
192
+ it("a proposed bar's label sits above its opaque tint in its hue's secondary ink", () => {
193
+ const view = renderWithProviders(
194
+ <GanttView
195
+ tasks={[
196
+ { id: "g", title: "Proposed", start: day(2), end: day(12), ghost: true, color: blue },
197
+ ]}
198
+ initialDate={day(1)}
199
+ />,
200
+ );
201
+ const ghost = view.container.querySelector('[data-gantt-ghost="true"]')!;
202
+ const label = ghost.querySelector("[data-gantt-ghost-label]") as HTMLElement;
203
+ expect(label?.textContent).toContain("Proposed");
204
+ expect(atomicStyle(label).zIndex).toBe("1");
205
+ const ramp = eventRamp({}, blue!, false)!;
206
+ const ink = label.getAttribute("data-gantt-bar-ink");
207
+ expect(ink).not.toBe(normalizeToHex(ramp(12)!));
208
+ expect(ink).toMatch(/^#[0-9a-f]{6}$/);
209
+ });
210
+
211
+ it("a bounded start on a dark tint carries a leading bar; a light solid needs none; an open start fades", () => {
212
+ const { view } = render("dark");
213
+ const bounded = view.container.querySelector('[data-gantt-bar="identity"]')!;
214
+ expect(bounded.querySelector("[data-gantt-bar-lead]")).not.toBeNull();
215
+ const open = view.container.querySelector('[data-gantt-bar="open"]')!;
216
+ expect(open.querySelector("[data-gantt-bar-lead]")).not.toBeNull();
217
+ cleanup();
218
+ const light = render("light").view;
219
+ expect(light.container.querySelector("[data-gantt-bar-lead]")).toBeNull();
220
+ const eternal = renderWithProviders(
221
+ <GanttView tasks={[{ id: "e", title: "Standing", end: day(9) }]} initialDate={day(1)} />,
222
+ );
223
+ const openStart = eternal.container.querySelector('[data-gantt-bar="e"]')!;
224
+ expect(openStart.querySelector("[data-gantt-bar-lead]")).toBeNull();
225
+ expect(openStart.querySelector('[data-gantt-open-fade="start"]')).not.toBeNull();
226
+ });
227
+
228
+ it("progress on a light solid runs over a faint track in the same ink; a dark tint has none", () => {
229
+ const light = render("light").view;
230
+ const bars = [...light.container.querySelectorAll("[data-gantt-progress]")];
231
+ expect(bars.length).toBeGreaterThan(0);
232
+ for (const strip of bars) {
233
+ const track = strip.parentElement!.querySelector("[data-gantt-progress-track]");
234
+ expect(track?.getAttribute("data-gantt-progress-track")).toBe(
235
+ strip.getAttribute("data-gantt-progress-paint"),
236
+ );
237
+ expect(track!.compareDocumentPosition(strip) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
238
+ }
239
+ cleanup();
240
+ const dark = render("dark").view;
241
+ expect(dark.container.querySelector("[data-gantt-progress-track]")).toBeNull();
242
+ });
243
+
244
+ it("the today line sits under the bars, so it never cuts a label", () => {
245
+ const now = new Date();
246
+ const at = (offset: number) =>
247
+ new Date(now.getFullYear(), now.getMonth(), now.getDate() + offset);
248
+ const view = renderWithProviders(
249
+ <GanttView tasks={[{ id: "t", title: "Spans today", start: at(-3), end: at(3) }]} />,
250
+ );
251
+ const line = view.container.querySelector('[data-gantt-today="true"]')!;
252
+ const row = view.container.querySelector('[data-gantt-row="t"]')!;
253
+ expect(line).not.toBeNull();
254
+ expect(line.compareDocumentPosition(row) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
255
+ expect(atomicStyle(line).zIndex).toBeUndefined();
256
+ });
257
+ });