@astryxdesign/lab 0.1.6-canary.e65bbd4 → 0.1.6-canary.e82deeb
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/Chart/ChartDotGLInteractive.d.ts.map +1 -1
- package/dist/Chart/ChartDotGLInteractive.js +5 -1
- package/dist/Chart/getChartColors.d.ts.map +1 -1
- package/dist/Chart/getChartColors.js +6 -18
- package/dist/Chart/webgl.d.ts +12 -4
- package/dist/Chart/webgl.d.ts.map +1 -1
- package/dist/Chart/webgl.js +3 -9
- package/dist/Schedule/shared.d.ts +43 -0
- package/dist/Schedule/shared.d.ts.map +1 -1
- package/dist/Schedule/shared.js +34 -0
- package/dist/ThreeD/ThreeDScatterGL.d.ts.map +1 -1
- package/dist/ThreeD/ThreeDScatterGL.js +6 -2
- package/package.json +3 -2
- package/src/Chart/ChartDotGLInteractive.tsx +5 -1
- package/src/Chart/getChartColors.ts +8 -13
- package/src/Chart/webgl.ts +3 -9
- package/src/Schedule/shared.tsx +44 -0
- package/src/ThreeD/ThreeDScatterGL.tsx +6 -2
- package/src/Chart/getChartColors.test.ts +0 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartDotGLInteractive.d.ts","sourceRoot":"","sources":["../../src/Chart/ChartDotGLInteractive.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChartDotGLInteractive.d.ts","sourceRoot":"","sources":["../../src/Chart/ChartDotGLInteractive.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,0BAA0B;IACzC,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;CAC9E;AAoHD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,KAAK,EACL,IAAQ,EACR,OAAa,EACb,aAAa,GACd,EAAE,0BAA0B,sCAyV5B"}
|
|
@@ -13,8 +13,12 @@
|
|
|
13
13
|
import { useRef, useEffect, useCallback, useState, useMemo } from 'react';
|
|
14
14
|
import { useChart } from "./ChartContext.js";
|
|
15
15
|
import { xPixel } from "./utils.js";
|
|
16
|
-
import { hexToGL } from "./webgl.js";
|
|
17
16
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
function hexToGL(hex) {
|
|
18
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
19
|
+
return [(n >> 16) / 255, (n >> 8 & 0xff) / 255, (n & 0xff) / 255];
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
/** Encode a point index as an RGB color (supports up to 16.7M points) */
|
|
19
23
|
function indexToColor(i) {
|
|
20
24
|
// Add 1 so index 0 isn't black (which is our clear color)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChartColors.d.ts","sourceRoot":"","sources":["../../src/Chart/getChartColors.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"getChartColors.d.ts","sourceRoot":"","sources":["../../src/Chart/getChartColors.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAM3D,kDAAkD;AAClD,MAAM,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AAY,EACnB,IAAI,GAAE,OAAO,GAAG,MAAgB,GAC/B,cAAc,CAsBhB"}
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* the full chart colors API. The useChartColors hook wraps this.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { parseHex, parseColor, formatColor } from '@astryxdesign/core/utils';
|
|
13
|
-
|
|
14
12
|
// =============================================================================
|
|
15
13
|
// Types
|
|
16
14
|
// =============================================================================
|
|
@@ -41,25 +39,15 @@ function pickFromRamp(stops, n) {
|
|
|
41
39
|
length: n
|
|
42
40
|
}, (_, i) => stops[Math.round(i * 4 / (n - 1))]);
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Apply an opacity to a concrete CSS color (hex — with or without the leading
|
|
47
|
-
* `#` — `rgb()`/`rgba()`, named). The `opacity` argument always wins over any
|
|
48
|
-
* alpha already in the color. Unparseable input (e.g. `var()`) is returned
|
|
49
|
-
* unchanged.
|
|
50
|
-
*/
|
|
51
42
|
function hexAlpha(hex, opacity) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const rgba = parseColor(hex) ?? parseHex(hex);
|
|
55
|
-
if (rgba === null) {
|
|
43
|
+
const match = hex.match(/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);
|
|
44
|
+
if (!match) {
|
|
56
45
|
return hex;
|
|
57
46
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
47
|
+
const r = parseInt(match[1], 16);
|
|
48
|
+
const g = parseInt(match[2], 16);
|
|
49
|
+
const b = parseInt(match[3], 16);
|
|
50
|
+
return `rgba(${r},${g},${b},${Math.max(0, Math.min(1, opacity))})`;
|
|
63
51
|
}
|
|
64
52
|
|
|
65
53
|
// =============================================================================
|
package/dist/Chart/webgl.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file webgl.ts
|
|
3
|
+
* @output Shared WebGL utilities for chart components
|
|
4
|
+
* @position Internal helpers; consumed by all GL mark components
|
|
5
|
+
*
|
|
6
|
+
* Provides:
|
|
7
|
+
* - Canvas mounting outside SVG (avoids foreignObject DPR blur)
|
|
8
|
+
* - Premultiplied alpha setup (correct compositing over page)
|
|
9
|
+
* - Shader compilation helpers
|
|
10
|
+
* - Smoothstep circle fragment for crisp point sprites
|
|
11
|
+
*/
|
|
1
12
|
/** Compile a WebGL shader, returns null on failure */
|
|
2
13
|
export declare function compileShader(gl: WebGLRenderingContext, type: number, src: string): WebGLShader | null;
|
|
3
14
|
/** Link a vertex + fragment shader into a program */
|
|
4
15
|
export declare function createProgram(gl: WebGLRenderingContext, vertSrc: string, fragSrc: string): WebGLProgram | null;
|
|
5
|
-
/**
|
|
6
|
-
* Parse a hex color (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) to [r, g, b]
|
|
7
|
-
* floats 0-1. Unparseable input returns a neutral fallback instead of NaN.
|
|
8
|
-
*/
|
|
16
|
+
/** Parse hex (#RRGGBB) to [r, g, b] floats 0-1 */
|
|
9
17
|
export declare function hexToGL(hex: string): [number, number, number];
|
|
10
18
|
/** DPR with supersampling for crisp circles */
|
|
11
19
|
export declare function getCanvasDPR(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl.d.ts","sourceRoot":"","sources":["../../src/Chart/webgl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl.d.ts","sourceRoot":"","sources":["../../src/Chart/webgl.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,sDAAsD;AACtD,wBAAgB,aAAa,CAC3B,EAAE,EAAE,qBAAqB,EACzB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,WAAW,GAAG,IAAI,CAYpB;AAED,qDAAqD;AACrD,wBAAgB,aAAa,CAC3B,EAAE,EAAE,qBAAqB,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,YAAY,GAAG,IAAI,CAkBrB;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAG7D;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,iBAAiB,GACxB,qBAAqB,GAAG,IAAI,CAM9B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,qBAAqB,GAAG,IAAI,CAK5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAwC1B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,iPAO5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAa,CAAC"}
|
package/dist/Chart/webgl.js
CHANGED
|
@@ -10,12 +10,8 @@
|
|
|
10
10
|
* - Premultiplied alpha setup (correct compositing over page)
|
|
11
11
|
* - Shader compilation helpers
|
|
12
12
|
* - Smoothstep circle fragment for crisp point sprites
|
|
13
|
-
* - Hex-to-GL color conversion via the shared @astryxdesign/core/utils/color
|
|
14
|
-
* parsers (fallback instead of NaN)
|
|
15
13
|
*/
|
|
16
14
|
|
|
17
|
-
import { parseHex, toGLFloats } from '@astryxdesign/core/utils';
|
|
18
|
-
|
|
19
15
|
/** Compile a WebGL shader, returns null on failure */
|
|
20
16
|
export function compileShader(gl, type, src) {
|
|
21
17
|
const s = gl.createShader(type);
|
|
@@ -52,12 +48,10 @@ export function createProgram(gl, vertSrc, fragSrc) {
|
|
|
52
48
|
return p;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
/**
|
|
56
|
-
* Parse a hex color (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) to [r, g, b]
|
|
57
|
-
* floats 0-1. Unparseable input returns a neutral fallback instead of NaN.
|
|
58
|
-
*/
|
|
51
|
+
/** Parse hex (#RRGGBB) to [r, g, b] floats 0-1 */
|
|
59
52
|
export function hexToGL(hex) {
|
|
60
|
-
|
|
53
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
54
|
+
return [(n >> 16) / 255, (n >> 8 & 0xff) / 255, (n & 0xff) / 255];
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
/** DPR with supersampling for crisp circles */
|
|
@@ -40,6 +40,47 @@ export declare function ListEventRow({ event, timezoneID, isPast, }: {
|
|
|
40
40
|
isPast?: boolean;
|
|
41
41
|
}): import("react").JSX.Element;
|
|
42
42
|
export declare function getEventCategory(event: CalendarEvent, categories: ReadonlyArray<ScheduleCategory>): ScheduleCategory;
|
|
43
|
+
export declare function eventColorStyle(color: ScheduleEventColor | undefined): Readonly<{
|
|
44
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#014975, #A1EEF9)">;
|
|
45
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#03A7D733, #03A7D733)">;
|
|
46
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#089DD0, #0171A4)">;
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#0A1317, #E7EAED)">;
|
|
49
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#0A131733, #666A724C)">;
|
|
50
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#647685, #748695)">;
|
|
51
|
+
}> | Readonly<{
|
|
52
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#09441F, #A5F690)">;
|
|
53
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#24BB5E33, #24BB5E33)">;
|
|
54
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#0D8626, #0B991F)">;
|
|
55
|
+
}> | Readonly<{
|
|
56
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#6B2203, #FDB876)">;
|
|
57
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#F2790233, #F2790233)">;
|
|
58
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#EB6E00, #B34A01)">;
|
|
59
|
+
}> | Readonly<{
|
|
60
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#650053, #FEADE3)">;
|
|
61
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#E638B333, #E638B333)">;
|
|
62
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#F351C0, #C02294)">;
|
|
63
|
+
}> | Readonly<{
|
|
64
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#3E0697, #B3B0FE)">;
|
|
65
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#7952FF33, #7952FF33)">;
|
|
66
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#9081FF, #7340FE)">;
|
|
67
|
+
}> | Readonly<{
|
|
68
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#7B0210, #FFB2B8)">;
|
|
69
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#E3193B33, #E3193B33)">;
|
|
70
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#E3193B, #F5394F)">;
|
|
71
|
+
}> | Readonly<{
|
|
72
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#083943, #40DCCD)">;
|
|
73
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#0DB7AF33, #0DB7AF33)">;
|
|
74
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#08A3A3, #08767D)">;
|
|
75
|
+
}> | Readonly<{
|
|
76
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#753F07, #FBCE03)">;
|
|
77
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#E2A40033, #E2A40033)">;
|
|
78
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#C58600, #B47700)">;
|
|
79
|
+
}> | Readonly<{
|
|
80
|
+
readonly color: stylex.StyleXClassNameFor<"color", "light-dark(#042F97, #AFD7FF)">;
|
|
81
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#0171E333, #0171E333)">;
|
|
82
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "light-dark(#0064E0, #2694FE)">;
|
|
83
|
+
}>;
|
|
43
84
|
export declare function eventDotColorStyle(color: ScheduleEventColor | undefined): Readonly<{
|
|
44
85
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "light-dark(#089DD0, #0171A4)">;
|
|
45
86
|
}> | Readonly<{
|
|
@@ -146,7 +187,9 @@ export declare function eventPastSurfaceColorStyle(color: ScheduleEventColor | u
|
|
|
146
187
|
export declare function formatWithPlainDate(date: PlainDate, timezoneID: string, options: Intl.DateTimeFormatOptions): string;
|
|
147
188
|
export declare function formatMonthTitle(date: PlainDate, timezoneID: string): string;
|
|
148
189
|
export declare function formatWeekTitle(start: PlainDate, end: PlainDate, timezoneID: string): string;
|
|
190
|
+
export declare function formatRangeTitle(start: PlainDate, end: PlainDate, timezoneID: string): string;
|
|
149
191
|
export declare function formatFullDate(date: PlainDate, timezoneID: string): string;
|
|
192
|
+
export declare function formatShortDate(date: PlainDate, timezoneID: string): string;
|
|
150
193
|
export declare function formatWeekday(date: PlainDate, timezoneID: string, weekday: 'short' | 'long'): string;
|
|
151
194
|
export declare function formatDayNumber(date: PlainDate, timezoneID: string): string;
|
|
152
195
|
export declare function formatHour(hour: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/Schedule/shared.tsx"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAa3C,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,gBAAgB,EAEhB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAgDA;AAED,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,UAAU,GACX,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,+BAUA;AAED,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,GAAG,EACH,UAAU,GACX,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,EAAE,SAAS,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,+BAmBA;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,GAAG,EACH,UAAU,EACV,MAAc,GACf,EAAE;IACD,KAAK,EAAE,aAAa,CAAC;IACrB,GAAG,CAAC,EAAE,SAAS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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAktBjB,CAAC"}
|
package/dist/Schedule/shared.js
CHANGED
|
@@ -240,6 +240,31 @@ export function getEventCategory(event, categories) {
|
|
|
240
240
|
color: DEFAULT_EVENT_CATEGORY.color
|
|
241
241
|
} : DEFAULT_EVENT_CATEGORY);
|
|
242
242
|
}
|
|
243
|
+
export function eventColorStyle(color) {
|
|
244
|
+
switch (color) {
|
|
245
|
+
case 'cyan':
|
|
246
|
+
return styles.eventCyan;
|
|
247
|
+
case 'gray':
|
|
248
|
+
return styles.eventGray;
|
|
249
|
+
case 'green':
|
|
250
|
+
return styles.eventGreen;
|
|
251
|
+
case 'orange':
|
|
252
|
+
return styles.eventOrange;
|
|
253
|
+
case 'pink':
|
|
254
|
+
return styles.eventPink;
|
|
255
|
+
case 'purple':
|
|
256
|
+
return styles.eventPurple;
|
|
257
|
+
case 'red':
|
|
258
|
+
return styles.eventRed;
|
|
259
|
+
case 'teal':
|
|
260
|
+
return styles.eventTeal;
|
|
261
|
+
case 'yellow':
|
|
262
|
+
return styles.eventYellow;
|
|
263
|
+
case 'blue':
|
|
264
|
+
default:
|
|
265
|
+
return styles.eventBlue;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
243
268
|
export function eventDotColorStyle(color) {
|
|
244
269
|
switch (color) {
|
|
245
270
|
case 'cyan':
|
|
@@ -339,6 +364,9 @@ export function formatWeekTitle(start, end, timezoneID) {
|
|
|
339
364
|
});
|
|
340
365
|
return start.year === end.year ? `${startMonth} - ${endMonth} ${end.year}` : `${startMonth} ${start.year} - ${endMonth} ${end.year}`;
|
|
341
366
|
}
|
|
367
|
+
export function formatRangeTitle(start, end, timezoneID) {
|
|
368
|
+
return `${formatShortDate(start, timezoneID)} - ${formatShortDate(end, timezoneID)}`;
|
|
369
|
+
}
|
|
342
370
|
export function formatFullDate(date, timezoneID) {
|
|
343
371
|
return formatWithPlainDate(date, timezoneID, {
|
|
344
372
|
weekday: 'long',
|
|
@@ -347,6 +375,12 @@ export function formatFullDate(date, timezoneID) {
|
|
|
347
375
|
year: 'numeric'
|
|
348
376
|
});
|
|
349
377
|
}
|
|
378
|
+
export function formatShortDate(date, timezoneID) {
|
|
379
|
+
return formatWithPlainDate(date, timezoneID, {
|
|
380
|
+
month: 'short',
|
|
381
|
+
day: 'numeric'
|
|
382
|
+
});
|
|
383
|
+
}
|
|
350
384
|
export function formatWeekday(date, timezoneID, weekday) {
|
|
351
385
|
return formatWithPlainDate(date, timezoneID, {
|
|
352
386
|
weekday
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreeDScatterGL.d.ts","sourceRoot":"","sources":["../../src/ThreeD/ThreeDScatterGL.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreeDScatterGL.d.ts","sourceRoot":"","sources":["../../src/ThreeD/ThreeDScatterGL.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4FD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,IAAQ,EACR,OAAc,GACf,EAAE,oBAAoB,sCAuJtB"}
|
|
@@ -14,9 +14,13 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { useRef, useEffect, useMemo } from 'react';
|
|
17
|
-
import { parseHex, toGLFloats } from '@astryxdesign/core/utils';
|
|
18
17
|
import { use3D } from "./ThreeDContext.js";
|
|
19
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
function hexToGL(hex) {
|
|
20
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
21
|
+
return [(n >> 16) / 255, (n >> 8 & 0xff) / 255, (n & 0xff) / 255];
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
// SYNC: Steps 1-5 match ThreeDChart.project() exactly.
|
|
21
25
|
const VERT = `
|
|
22
26
|
attribute vec3 a_position;
|
|
@@ -214,7 +218,7 @@ export function ThreeDScatterGL({
|
|
|
214
218
|
const azRad = camera.azimuth * Math.PI / 180;
|
|
215
219
|
const elRad = camera.elevation * Math.PI / 180;
|
|
216
220
|
const scale = Math.min(width, height) * 0.35;
|
|
217
|
-
const [r, g, b] =
|
|
221
|
+
const [r, g, b] = hexToGL(color);
|
|
218
222
|
gl.uniform2f(gl.getUniformLocation(program, 'u_resolution'), width, height);
|
|
219
223
|
gl.uniform2f(gl.getUniformLocation(program, 'u_center'), width / 2, height / 2);
|
|
220
224
|
gl.uniform1f(gl.getUniformLocation(program, 'u_scale'), scale);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/lab",
|
|
3
|
-
"version": "0.1.6-canary.
|
|
3
|
+
"version": "0.1.6-canary.e82deeb",
|
|
4
4
|
"description": "Experimental Astryx components — published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
|
|
5
5
|
"author": "Meta Open Source",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@stylexjs/stylex": ">=0.10.0",
|
|
48
|
-
"@astryxdesign/core": "0.1.6-canary.
|
|
48
|
+
"@astryxdesign/core": "0.1.6-canary.e82deeb",
|
|
49
49
|
"react": ">=19.0.0",
|
|
50
50
|
"react-dom": ">=19.0.0"
|
|
51
51
|
},
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"d3-shape": "^3.2.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
+
"@types/d3-array": "^3.2.2",
|
|
58
59
|
"@types/d3-scale": "^4.0.9",
|
|
59
60
|
"@types/d3-shape": "^3.1.8"
|
|
60
61
|
},
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
} from 'react';
|
|
21
21
|
import {useChart} from './ChartContext';
|
|
22
22
|
import {xPixel} from './utils';
|
|
23
|
-
import {hexToGL} from './webgl';
|
|
24
23
|
|
|
25
24
|
export interface ChartDotGLInteractiveProps {
|
|
26
25
|
/** Which data key for the y values */
|
|
@@ -38,6 +37,11 @@ export interface ChartDotGLInteractiveProps {
|
|
|
38
37
|
renderTooltip?: (datum: Record<string, unknown>, index: number) => ReactNode;
|
|
39
38
|
}
|
|
40
39
|
|
|
40
|
+
function hexToGL(hex: string): [number, number, number] {
|
|
41
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
42
|
+
return [(n >> 16) / 255, ((n >> 8) & 0xff) / 255, (n & 0xff) / 255];
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
/** Encode a point index as an RGB color (supports up to 16.7M points) */
|
|
42
46
|
function indexToColor(i: number): [number, number, number] {
|
|
43
47
|
// Add 1 so index 0 isn't black (which is our clear color)
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {DefinedTheme} from '@astryxdesign/core/theme';
|
|
13
|
-
import {parseHex, parseColor, formatColor} from '@astryxdesign/core/utils';
|
|
14
13
|
|
|
15
14
|
// =============================================================================
|
|
16
15
|
// Types
|
|
@@ -106,21 +105,17 @@ function pickFromRamp(stops: string[], n: number): string[] {
|
|
|
106
105
|
);
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
/**
|
|
110
|
-
* Apply an opacity to a concrete CSS color (hex — with or without the leading
|
|
111
|
-
* `#` — `rgb()`/`rgba()`, named). The `opacity` argument always wins over any
|
|
112
|
-
* alpha already in the color. Unparseable input (e.g. `var()`) is returned
|
|
113
|
-
* unchanged.
|
|
114
|
-
*/
|
|
115
108
|
function hexAlpha(hex: string, opacity: number): string {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
109
|
+
const match = hex.match(
|
|
110
|
+
/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/,
|
|
111
|
+
);
|
|
112
|
+
if (!match) {
|
|
120
113
|
return hex;
|
|
121
114
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
115
|
+
const r = parseInt(match[1], 16);
|
|
116
|
+
const g = parseInt(match[2], 16);
|
|
117
|
+
const b = parseInt(match[3], 16);
|
|
118
|
+
return `rgba(${r},${g},${b},${Math.max(0, Math.min(1, opacity))})`;
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
// =============================================================================
|
package/src/Chart/webgl.ts
CHANGED
|
@@ -10,12 +10,8 @@
|
|
|
10
10
|
* - Premultiplied alpha setup (correct compositing over page)
|
|
11
11
|
* - Shader compilation helpers
|
|
12
12
|
* - Smoothstep circle fragment for crisp point sprites
|
|
13
|
-
* - Hex-to-GL color conversion via the shared @astryxdesign/core/utils/color
|
|
14
|
-
* parsers (fallback instead of NaN)
|
|
15
13
|
*/
|
|
16
14
|
|
|
17
|
-
import {parseHex, toGLFloats} from '@astryxdesign/core/utils';
|
|
18
|
-
|
|
19
15
|
/** Compile a WebGL shader, returns null on failure */
|
|
20
16
|
export function compileShader(
|
|
21
17
|
gl: WebGLRenderingContext,
|
|
@@ -60,12 +56,10 @@ export function createProgram(
|
|
|
60
56
|
return p;
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
/**
|
|
64
|
-
* Parse a hex color (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) to [r, g, b]
|
|
65
|
-
* floats 0-1. Unparseable input returns a neutral fallback instead of NaN.
|
|
66
|
-
*/
|
|
59
|
+
/** Parse hex (#RRGGBB) to [r, g, b] floats 0-1 */
|
|
67
60
|
export function hexToGL(hex: string): [number, number, number] {
|
|
68
|
-
|
|
61
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
62
|
+
return [(n >> 16) / 255, ((n >> 8) & 0xff) / 255, (n & 0xff) / 255];
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
/** DPR with supersampling for crisp circles */
|
package/src/Schedule/shared.tsx
CHANGED
|
@@ -274,6 +274,32 @@ export function getEventCategory(
|
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
export function eventColorStyle(color: ScheduleEventColor | undefined) {
|
|
278
|
+
switch (color) {
|
|
279
|
+
case 'cyan':
|
|
280
|
+
return styles.eventCyan;
|
|
281
|
+
case 'gray':
|
|
282
|
+
return styles.eventGray;
|
|
283
|
+
case 'green':
|
|
284
|
+
return styles.eventGreen;
|
|
285
|
+
case 'orange':
|
|
286
|
+
return styles.eventOrange;
|
|
287
|
+
case 'pink':
|
|
288
|
+
return styles.eventPink;
|
|
289
|
+
case 'purple':
|
|
290
|
+
return styles.eventPurple;
|
|
291
|
+
case 'red':
|
|
292
|
+
return styles.eventRed;
|
|
293
|
+
case 'teal':
|
|
294
|
+
return styles.eventTeal;
|
|
295
|
+
case 'yellow':
|
|
296
|
+
return styles.eventYellow;
|
|
297
|
+
case 'blue':
|
|
298
|
+
default:
|
|
299
|
+
return styles.eventBlue;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
277
303
|
export function eventDotColorStyle(color: ScheduleEventColor | undefined) {
|
|
278
304
|
switch (color) {
|
|
279
305
|
case 'cyan':
|
|
@@ -389,6 +415,17 @@ export function formatWeekTitle(
|
|
|
389
415
|
: `${startMonth} ${start.year} - ${endMonth} ${end.year}`;
|
|
390
416
|
}
|
|
391
417
|
|
|
418
|
+
export function formatRangeTitle(
|
|
419
|
+
start: PlainDate,
|
|
420
|
+
end: PlainDate,
|
|
421
|
+
timezoneID: string,
|
|
422
|
+
): string {
|
|
423
|
+
return `${formatShortDate(start, timezoneID)} - ${formatShortDate(
|
|
424
|
+
end,
|
|
425
|
+
timezoneID,
|
|
426
|
+
)}`;
|
|
427
|
+
}
|
|
428
|
+
|
|
392
429
|
export function formatFullDate(date: PlainDate, timezoneID: string): string {
|
|
393
430
|
return formatWithPlainDate(date, timezoneID, {
|
|
394
431
|
weekday: 'long',
|
|
@@ -398,6 +435,13 @@ export function formatFullDate(date: PlainDate, timezoneID: string): string {
|
|
|
398
435
|
});
|
|
399
436
|
}
|
|
400
437
|
|
|
438
|
+
export function formatShortDate(date: PlainDate, timezoneID: string): string {
|
|
439
|
+
return formatWithPlainDate(date, timezoneID, {
|
|
440
|
+
month: 'short',
|
|
441
|
+
day: 'numeric',
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
401
445
|
export function formatWeekday(
|
|
402
446
|
date: PlainDate,
|
|
403
447
|
timezoneID: string,
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import {useRef, useEffect, useMemo} from 'react';
|
|
17
|
-
import {parseHex, toGLFloats} from '@astryxdesign/core/utils';
|
|
18
17
|
import {use3D} from './ThreeDContext';
|
|
19
18
|
|
|
20
19
|
export interface ThreeDScatterGLProps {
|
|
@@ -23,6 +22,11 @@ export interface ThreeDScatterGLProps {
|
|
|
23
22
|
opacity?: number;
|
|
24
23
|
}
|
|
25
24
|
|
|
25
|
+
function hexToGL(hex: string): [number, number, number] {
|
|
26
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
27
|
+
return [(n >> 16) / 255, ((n >> 8) & 0xff) / 255, (n & 0xff) / 255];
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
// SYNC: Steps 1-5 match ThreeDChart.project() exactly.
|
|
27
31
|
const VERT = `
|
|
28
32
|
attribute vec3 a_position;
|
|
@@ -236,7 +240,7 @@ export function ThreeDScatterGL({
|
|
|
236
240
|
const azRad = (camera.azimuth * Math.PI) / 180;
|
|
237
241
|
const elRad = (camera.elevation * Math.PI) / 180;
|
|
238
242
|
const scale = Math.min(width, height) * 0.35;
|
|
239
|
-
const [r, g, b] =
|
|
243
|
+
const [r, g, b] = hexToGL(color);
|
|
240
244
|
|
|
241
245
|
gl.uniform2f(gl.getUniformLocation(program, 'u_resolution'), width, height);
|
|
242
246
|
gl.uniform2f(
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
import {describe, expect, it} from 'vitest';
|
|
4
|
-
import {getChartColorsFromResolver} from './getChartColors';
|
|
5
|
-
|
|
6
|
-
describe('getChartColorsFromResolver alpha', () => {
|
|
7
|
-
const colors = getChartColorsFromResolver(name => `resolved(${name})`);
|
|
8
|
-
|
|
9
|
-
it('applies opacity to a hex color', () => {
|
|
10
|
-
expect(colors.alpha('#0064E0', 0.2)).toBe('rgba(0, 100, 224, 0.2)');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('applies opacity to bare hex without the leading # (pre-#3739 behavior)', () => {
|
|
14
|
-
expect(colors.alpha('0064E0', 0.2)).toBe('rgba(0, 100, 224, 0.2)');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('applies opacity to rgba() input, overriding its alpha', () => {
|
|
18
|
-
expect(colors.alpha('rgba(0, 100, 224, 0.9)', 0.2)).toBe(
|
|
19
|
-
'rgba(0, 100, 224, 0.2)',
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('preserves unparseable input unchanged', () => {
|
|
24
|
-
expect(colors.alpha('var(--color-accent)', 0.5)).toBe(
|
|
25
|
-
'var(--color-accent)',
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
});
|