@multiplatform.one/components 10.1.1 → 10.1.3
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/cjs/MiddleEllipsisText/index.native.cjs +5 -1
- package/dist/cjs/MiddleEllipsisText/index.native.js +5 -1
- package/dist/cjs/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/cjs/Tabs/index.cjs +3 -2
- package/dist/cjs/Tabs/index.native.cjs +3 -2
- package/dist/cjs/Tabs/index.native.js +3 -2
- package/dist/cjs/Tabs/index.native.js.map +1 -1
- package/dist/cjs/layouts/timeline.cjs +0 -1
- package/dist/cjs/layouts/timeline.native.cjs +0 -1
- package/dist/cjs/layouts/timeline.native.js +0 -1
- package/dist/cjs/layouts/timeline.native.js.map +1 -1
- package/dist/cjs/views/Calendar.cjs +54 -76
- package/dist/cjs/views/Calendar.native.cjs +54 -76
- package/dist/cjs/views/Calendar.native.js +54 -76
- package/dist/cjs/views/Calendar.native.js.map +1 -1
- package/dist/cjs/views/Gantt.cjs +185 -69
- package/dist/cjs/views/Gantt.native.cjs +190 -72
- package/dist/cjs/views/Gantt.native.js +190 -72
- package/dist/cjs/views/Gantt.native.js.map +1 -1
- package/dist/cjs/views/GanttDateGrip.cjs +20 -14
- package/dist/cjs/views/GanttDateGrip.native.cjs +24 -14
- package/dist/cjs/views/GanttDateGrip.native.js +24 -14
- package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
- package/dist/cjs/views/GanttGripDot.cjs +43 -0
- package/dist/cjs/views/GanttGripDot.native.cjs +46 -0
- package/dist/cjs/views/GanttGripDot.native.js +48 -0
- package/dist/cjs/views/GanttGripDot.native.js.map +1 -0
- package/dist/cjs/views/eventTint.cjs +242 -0
- package/dist/cjs/views/eventTint.native.cjs +346 -0
- package/dist/cjs/views/eventTint.native.js +348 -0
- package/dist/cjs/views/eventTint.native.js.map +1 -0
- package/dist/esm/MiddleEllipsisText/index.native.js +2 -1
- package/dist/esm/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/esm/Tabs/index.mjs +3 -2
- package/dist/esm/Tabs/index.mjs.map +1 -1
- package/dist/esm/Tabs/index.native.js +3 -2
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/layouts/timeline.mjs +0 -1
- package/dist/esm/layouts/timeline.mjs.map +1 -1
- package/dist/esm/layouts/timeline.native.js +0 -1
- package/dist/esm/layouts/timeline.native.js.map +1 -1
- package/dist/esm/views/Calendar.mjs +53 -75
- package/dist/esm/views/Calendar.mjs.map +1 -1
- package/dist/esm/views/Calendar.native.js +53 -75
- package/dist/esm/views/Calendar.native.js.map +1 -1
- package/dist/esm/views/Gantt.mjs +186 -70
- package/dist/esm/views/Gantt.mjs.map +1 -1
- package/dist/esm/views/Gantt.native.js +191 -73
- package/dist/esm/views/Gantt.native.js.map +1 -1
- package/dist/esm/views/GanttDateGrip.mjs +21 -15
- package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
- package/dist/esm/views/GanttDateGrip.native.js +25 -15
- package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
- package/dist/esm/views/GanttGripDot.mjs +24 -0
- package/dist/esm/views/GanttGripDot.mjs.map +1 -0
- package/dist/esm/views/GanttGripDot.native.js +25 -0
- package/dist/esm/views/GanttGripDot.native.js.map +1 -0
- package/dist/esm/views/eventTint.mjs +196 -0
- package/dist/esm/views/eventTint.mjs.map +1 -0
- package/dist/esm/views/eventTint.native.js +298 -0
- package/dist/esm/views/eventTint.native.js.map +1 -0
- package/dist/jsx/MiddleEllipsisText/index.native.cjs +5 -1
- package/dist/jsx/MiddleEllipsisText/index.native.js +5 -1
- package/dist/jsx/MiddleEllipsisText/index.native.js.map +1 -1
- package/dist/jsx/Tabs/index.mjs +3 -2
- package/dist/jsx/Tabs/index.mjs.map +1 -1
- package/dist/jsx/Tabs/index.native.cjs +3 -2
- package/dist/jsx/Tabs/index.native.js +3 -2
- package/dist/jsx/Tabs/index.native.js.map +1 -1
- package/dist/jsx/layouts/timeline.mjs +0 -1
- package/dist/jsx/layouts/timeline.mjs.map +1 -1
- package/dist/jsx/layouts/timeline.native.cjs +0 -1
- package/dist/jsx/layouts/timeline.native.js +0 -1
- package/dist/jsx/layouts/timeline.native.js.map +1 -1
- package/dist/jsx/views/Calendar.mjs +53 -75
- package/dist/jsx/views/Calendar.mjs.map +1 -1
- package/dist/jsx/views/Calendar.native.cjs +54 -76
- package/dist/jsx/views/Calendar.native.js +54 -76
- package/dist/jsx/views/Calendar.native.js.map +1 -1
- package/dist/jsx/views/Gantt.mjs +186 -70
- package/dist/jsx/views/Gantt.mjs.map +1 -1
- package/dist/jsx/views/Gantt.native.cjs +190 -72
- package/dist/jsx/views/Gantt.native.js +190 -72
- package/dist/jsx/views/Gantt.native.js.map +1 -1
- package/dist/jsx/views/GanttDateGrip.mjs +21 -15
- package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
- package/dist/jsx/views/GanttDateGrip.native.cjs +24 -14
- package/dist/jsx/views/GanttDateGrip.native.js +24 -14
- package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
- package/dist/jsx/views/GanttGripDot.mjs +24 -0
- package/dist/jsx/views/GanttGripDot.mjs.map +1 -0
- package/dist/jsx/views/GanttGripDot.native.cjs +46 -0
- package/dist/jsx/views/GanttGripDot.native.js +48 -0
- package/dist/jsx/views/GanttGripDot.native.js.map +1 -0
- package/dist/jsx/views/eventTint.mjs +196 -0
- package/dist/jsx/views/eventTint.mjs.map +1 -0
- package/dist/jsx/views/eventTint.native.cjs +346 -0
- package/dist/jsx/views/eventTint.native.js +348 -0
- package/dist/jsx/views/eventTint.native.js.map +1 -0
- package/package.json +7 -7
- package/src/MiddleEllipsisText/MiddleEllipsisText.native.spec.tsx +9 -0
- package/src/MiddleEllipsisText/index.native.tsx +1 -0
- package/src/Tabs/Tabs.measurement.spec.tsx +40 -1
- package/src/Tabs/index.tsx +3 -2
- package/src/hoverTouchPath.coarse.spec.tsx +28 -4
- package/src/layouts/timeline.replyInset.spec.tsx +72 -22
- package/src/layouts/timeline.tsx +0 -1
- package/src/views/Calendar.eventFill.spec.tsx +44 -9
- package/src/views/Calendar.tsx +23 -31
- package/src/views/Gantt.barInk.spec.tsx +257 -0
- package/src/views/Gantt.grips.spec.tsx +226 -0
- package/src/views/Gantt.tint.palette.spec.ts +288 -0
- package/src/views/Gantt.tsx +224 -65
- package/src/views/GanttDateGrip.native.spec.tsx +8 -0
- package/src/views/GanttDateGrip.tsx +28 -17
- package/src/views/GanttGripDot.tsx +36 -0
- package/src/views/dataIdentity.spec.tsx +29 -13
- package/src/views/eventTint.ts +305 -0
- package/types/MiddleEllipsisText/index.native.d.ts +1 -0
- package/types/MiddleEllipsisText/index.native.d.ts.map +1 -1
- package/types/Tabs/index.d.ts.map +1 -1
- package/types/layouts/timeline.d.ts.map +1 -1
- package/types/views/Calendar.d.ts.map +1 -1
- package/types/views/Gantt.d.ts.map +1 -1
- package/types/views/GanttDateGrip.d.ts +7 -0
- package/types/views/GanttDateGrip.d.ts.map +1 -1
- package/types/views/GanttGripDot.d.ts +9 -0
- package/types/views/GanttGripDot.d.ts.map +1 -0
- package/types/views/eventTint.d.ts +72 -0
- package/types/views/eventTint.d.ts.map +1 -0
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* FZ-
|
|
2
|
+
* FZ-11153. The Reply control's geometry is the house Button's recipe, never a
|
|
3
|
+
* hand pin.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
* `dark-dense` and `dark-slate`, which is rule B of `pnpm verify:theme-matrix`
|
|
12
|
-
* (a preset may move pixels, never off the scale).
|
|
5
|
+
* FZ-10849 pinned its vertical inset to `$1` while it was a raw Tamagui Button,
|
|
6
|
+
* whose size variant picked the half step `$0.75` off the space scale by index:
|
|
7
|
+
* 2px on the default scale, 1px under the dense and slate presets, which no
|
|
8
|
+
* padding role the constraint audit accepts. It now renders the house Button
|
|
9
|
+
* (`@multiplatform.one/forms`), whose frame is the control recipe's `height`
|
|
10
|
+
* and `paddingHorizontal` with no vertical inset, so a preset's scale restyles
|
|
11
|
+
* it (LC-18) and a pin on top of that is the drift this spec catches.
|
|
13
12
|
*/
|
|
14
13
|
import { cleanup, screen } from "@testing-library/react";
|
|
15
14
|
import { atomicStyle, renderWithProviders } from "@multiplatform.one/test-utils";
|
|
16
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_SCALE_ID,
|
|
17
|
+
MIN_PRESS_TARGET,
|
|
18
|
+
applyThemeScale,
|
|
19
|
+
createDefaultThemeConfig,
|
|
20
|
+
densePreset,
|
|
21
|
+
sizeRecipeForToken,
|
|
22
|
+
} from "@multiplatform.one/theme";
|
|
17
23
|
import * as React from "react";
|
|
18
24
|
import { afterEach, describe, expect, it } from "vitest";
|
|
19
25
|
import { Timeline, type TimelineEntry } from "./timeline";
|
|
@@ -30,27 +36,71 @@ const entries: TimelineEntry[] = [
|
|
|
30
36
|
},
|
|
31
37
|
];
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const verticalInsets = [
|
|
40
|
+
"padding",
|
|
41
|
+
"paddingTop",
|
|
42
|
+
"paddingBottom",
|
|
43
|
+
"paddingBlock",
|
|
44
|
+
"paddingBlockStart",
|
|
45
|
+
"paddingBlockEnd",
|
|
46
|
+
] as const;
|
|
37
47
|
|
|
38
48
|
function replyControl(): HTMLElement {
|
|
39
49
|
renderWithProviders(<Timeline entries={entries} onCommentSubmit={() => {}} />);
|
|
40
50
|
return screen.getByRole("button", { name: "Reply Alice" });
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
function recipeGeometry(el: HTMLElement) {
|
|
54
|
+
const painted = atomicStyle(el);
|
|
55
|
+
return {
|
|
56
|
+
sizeToken: el.getAttribute("data-size-token"),
|
|
57
|
+
height: el.getAttribute("data-mp-button-height"),
|
|
58
|
+
paddingInline: painted.paddingInline ?? painted.paddingLeft,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function expectedGeometry(token: string) {
|
|
63
|
+
const recipe = sizeRecipeForToken(token);
|
|
64
|
+
return {
|
|
65
|
+
sizeToken: token,
|
|
66
|
+
height: String(recipe.height),
|
|
67
|
+
paddingInline: `${recipe.paddingHorizontal}px`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
describe("FZ-11153: the Reply control takes its geometry from the house Button recipe", () => {
|
|
72
|
+
it("declares no vertical inset of its own", () => {
|
|
45
73
|
const painted = atomicStyle(replyControl());
|
|
46
|
-
for (const side of
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
for (const side of verticalInsets) {
|
|
75
|
+
expect(painted[side], `the Reply control pins ${side}`).toBeUndefined();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("paints the installed scale's control recipe, and a denser scale restyles it", () => {
|
|
80
|
+
const themeConfig = createDefaultThemeConfig({ presets: { dense: densePreset } });
|
|
81
|
+
const dense = themeConfig.scales?.dense;
|
|
82
|
+
const defaults = themeConfig.scales?.[DEFAULT_SCALE_ID];
|
|
83
|
+
if (!dense || !defaults) throw new Error("scales missing");
|
|
84
|
+
|
|
85
|
+
const onDefault = recipeGeometry(replyControl());
|
|
86
|
+
expect(onDefault).toEqual(expectedGeometry("2"));
|
|
87
|
+
cleanup();
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
applyThemeScale(dense);
|
|
91
|
+
const onDense = recipeGeometry(replyControl());
|
|
92
|
+
expect(onDense).toEqual(expectedGeometry("2"));
|
|
93
|
+
expect(onDense.height).not.toBe(onDefault.height);
|
|
94
|
+
const painted = atomicStyle(screen.getByRole("button", { name: "Reply Alice" }));
|
|
95
|
+
for (const side of verticalInsets) {
|
|
96
|
+
expect(painted[side], `the Reply control pins ${side} on dense`).toBeUndefined();
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
applyThemeScale(defaults);
|
|
50
100
|
}
|
|
51
101
|
});
|
|
52
102
|
|
|
53
|
-
it("keeps the LC-54 press floor
|
|
103
|
+
it("keeps the LC-54 press floor", () => {
|
|
54
104
|
const painted = atomicStyle(replyControl());
|
|
55
105
|
expect(painted.minHeight).toBe(`${MIN_PRESS_TARGET}px`);
|
|
56
106
|
expect(painted.minWidth).toBe(`${MIN_PRESS_TARGET}px`);
|
package/src/layouts/timeline.tsx
CHANGED
|
@@ -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
|
|
67
|
-
expect(tint).not.toBeNull();
|
|
68
|
+
const tint = block;
|
|
68
69
|
expect(fiberProps(block, "position").position).toBe("relative");
|
|
69
|
-
expect(
|
|
70
|
-
expect(fiberProps(tint, "backgroundColor").
|
|
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
|
|
80
|
-
const rest = chip("Review")
|
|
81
|
-
expect(
|
|
82
|
-
|
|
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!.
|
|
138
|
+
expect(node!.getAttribute("data-calendar-event-tint")).toBe("rest");
|
|
104
139
|
expect(fiberProps(text, "color").color).toBe("color-12");
|
|
105
140
|
});
|
|
106
141
|
|
package/src/views/Calendar.tsx
CHANGED
|
@@ -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 =
|
|
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=
|
|
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
|
|
2106
|
-
const
|
|
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
|
+
});
|