@stacksjs/components 0.2.189 → 0.2.191
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/index.js +4 -4
- package/package.json +3 -3
- package/src/ui/heatmap/Heatmap.stx +38 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// ../../../../../../../tmp/stx-components-build-
|
|
2
|
+
// ../../../../../../../tmp/stx-components-build-K0SBhh/stubs/stub-0.js
|
|
3
3
|
var stub_0_default = { __stx: true, src: "./components/CodeBlock.stx" };
|
|
4
|
-
// ../../../../../../../tmp/stx-components-build-
|
|
4
|
+
// ../../../../../../../tmp/stx-components-build-K0SBhh/stubs/stub-1.js
|
|
5
5
|
var stub_1_default = { __stx: true, src: "./components/Footer.stx" };
|
|
6
|
-
// ../../../../../../../tmp/stx-components-build-
|
|
6
|
+
// ../../../../../../../tmp/stx-components-build-K0SBhh/stubs/stub-2.js
|
|
7
7
|
var stub_2_default = { __stx: true, src: "./components/Hero.stx" };
|
|
8
|
-
// ../../../../../../../tmp/stx-components-build-
|
|
8
|
+
// ../../../../../../../tmp/stx-components-build-K0SBhh/stubs/stub-3.js
|
|
9
9
|
var stub_3_default = { __stx: true, src: "./components/Installation.stx" };
|
|
10
10
|
// src/composables/useCopyCode.ts
|
|
11
11
|
function useCopyCode(options) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.191",
|
|
5
5
|
"description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@iconify-json/f7": "^1.2.2",
|
|
66
66
|
"@cwcss/crosswind": "^0.2.14",
|
|
67
|
-
"@stacksjs/stx": "0.2.
|
|
68
|
-
"bun-plugin-stx": "0.2.
|
|
67
|
+
"@stacksjs/stx": "0.2.191",
|
|
68
|
+
"bun-plugin-stx": "0.2.191",
|
|
69
69
|
"ts-syntax-highlighter": "^0.2.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -12,14 +12,37 @@ export const dataSource = $props.dataSource || 'auto'
|
|
|
12
12
|
export const endpoint = $props.endpoint || ''
|
|
13
13
|
export const colorScheme = $props.colorScheme || 'default'
|
|
14
14
|
|
|
15
|
+
// Sequential ramps: lightness moves in one direction from end to end.
|
|
16
|
+
//
|
|
17
|
+
// The old default was a blue-cyan-green-yellow-red rainbow, which is the one
|
|
18
|
+
// ramp a sequential scale should not use. It invents boundaries — the
|
|
19
|
+
// transitions through cyan and yellow are perceptually much sharper than the
|
|
20
|
+
// ones on either side, so a reader sees bands and infers categories in
|
|
21
|
+
// continuous data. And it is not monotonic in lightness: yellow is far lighter
|
|
22
|
+
// than both ends, so the ramp goes light in the middle, and printed in
|
|
23
|
+
// greyscale or read with a colour vision deficiency the high and low ends
|
|
24
|
+
// become indistinguishable while the middle stands out.
|
|
25
|
+
//
|
|
26
|
+
// `rainbow` is kept, because removing a named scheme breaks anyone who asked
|
|
27
|
+
// for it by name. It is no longer what you get by default.
|
|
15
28
|
const colorSchemes = {
|
|
16
|
-
default: ['#
|
|
29
|
+
default: ['#eff3ff', '#bdd7e7', '#6baed6', '#3182bd', '#08519c'],
|
|
17
30
|
fire: ['#000000', '#ff0000', '#ffff00', '#ffffff'],
|
|
18
31
|
cool: ['#000033', '#0066ff', '#00ccff', '#ffffff'],
|
|
19
32
|
grayscale: ['#000000', '#444444', '#888888', '#cccccc', '#ffffff'],
|
|
33
|
+
// Two hues meeting at a neutral, for data with a meaningful midpoint. Not a
|
|
34
|
+
// hue at the middle — that is the rainbow's mistake in miniature.
|
|
35
|
+
diverging: ['#2166ac', '#92c5de', '#f7f7f7', '#f4a582', '#b2182b'],
|
|
36
|
+
rainbow: ['#0000ff', '#00ffff', '#00ff00', '#ffff00', '#ff0000'],
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
export const colors = colorSchemes[colorScheme] || colorSchemes.default
|
|
40
|
+
|
|
41
|
+
// Each stop is addressable as a CSS custom property with the scheme's own value
|
|
42
|
+
// as the fallback, so an app can supply its own hue without changing behaviour
|
|
43
|
+
// for anyone who does not. The heatmap was the one component that could not
|
|
44
|
+
// follow an app's tokens, because the ramp was hardcoded.
|
|
45
|
+
export const stopVars = colors.map((color, i) => `var(--stx-heatmap-stop-${i + 1}, ${color})`)
|
|
23
46
|
</script>
|
|
24
47
|
|
|
25
48
|
<div
|
|
@@ -42,7 +65,7 @@ export const colors = colorSchemes[colorScheme] || colorSchemes.default
|
|
|
42
65
|
@if(showLegend)
|
|
43
66
|
<div class="stx-heatmap__legend">
|
|
44
67
|
<span class="stx-heatmap__legend-label">Low</span>
|
|
45
|
-
<div class="stx-heatmap__legend-gradient" style="background: linear-gradient(to right, {{
|
|
68
|
+
<div class="stx-heatmap__legend-gradient" style="background: linear-gradient(to right, {{ stopVars.join(', ') }})"></div>
|
|
46
69
|
<span class="stx-heatmap__legend-label">High</span>
|
|
47
70
|
</div>
|
|
48
71
|
@endif
|
|
@@ -170,6 +193,18 @@ export const colors = colorSchemes[colorScheme] || colorSchemes.default
|
|
|
170
193
|
endpoint: container.dataset.heatmapEndpoint || ''
|
|
171
194
|
};
|
|
172
195
|
|
|
196
|
+
// Resolve each stop through its custom property, falling back to the
|
|
197
|
+
// scheme's own colour. The legend is plain CSS and picks these up for free;
|
|
198
|
+
// the canvas is painted from JS and would otherwise keep the built-in ramp,
|
|
199
|
+
// leaving an app's themed legend describing a plot it does not match.
|
|
200
|
+
function themedColors() {
|
|
201
|
+
const styles = getComputedStyle(container);
|
|
202
|
+
return config.colors.map(function(color, i) {
|
|
203
|
+
const override = styles.getPropertyValue('--stx-heatmap-stop-' + (i + 1)).trim();
|
|
204
|
+
return override || color;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
173
208
|
// Resize canvas to match container
|
|
174
209
|
function resizeCanvas() {
|
|
175
210
|
const rect = container.getBoundingClientRect();
|
|
@@ -222,7 +257,7 @@ export const colors = colorSchemes[colorScheme] || colorSchemes.default
|
|
|
222
257
|
// Colorize
|
|
223
258
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
224
259
|
const pixels = imageData.data;
|
|
225
|
-
const gradientColors = createGradient(
|
|
260
|
+
const gradientColors = createGradient(themedColors());
|
|
226
261
|
|
|
227
262
|
for (let i = 0; i < pixels.length; i += 4) {
|
|
228
263
|
const alpha = pixels[i + 3];
|