@almanaclabs/blaze-ui 0.14.0 → 0.15.0
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/components/metric-tile/metric-tile.d.ts.map +1 -1
- package/dist/components/metric-tile/metric-tile.js +38 -42
- package/dist/components/sparkline/sparkline.d.ts +12 -5
- package/dist/components/sparkline/sparkline.d.ts.map +1 -1
- package/dist/components/sparkline/sparkline.js +48 -43
- package/package.json +1 -1
- package/src/styles/globals.css +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric-tile.d.ts","sourceRoot":"","sources":["../../../src/components/metric-tile/metric-tile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,kBAAkB;;
|
|
1
|
+
{"version":3,"file":"metric-tile.d.ts","sourceRoot":"","sources":["../../../src/components/metric-tile/metric-tile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,kBAAkB;;8EAiBtB,CAAA;AAEF,QAAA,MAAM,uBAAuB;;8EAU3B,CAAA;AAEF,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,gEAAgE;IAChE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,0DAA0D;IAC1D,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,MAAM,WAAW,eACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,EAC7C,YAAY,CAAC,OAAO,kBAAkB,CAAC,EACvC,YAAY,CAAC,OAAO,uBAAuB,CAAC;IAC9C,mFAAmF;IACnF,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,qEAAqE;IACrE,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,4CAA4C;IAC5C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,gEAAgE;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB;AAED,gFAAgF;AAChF,iBAAS,UAAU,CAAC,EAClB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,KAAK,EACT,EAAE,eAAe,qBAyGjB;AAED,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -1,81 +1,77 @@
|
|
|
1
1
|
import { cn as e } from "../../lib/utils.js";
|
|
2
2
|
import "react";
|
|
3
3
|
import { cva as t } from "class-variance-authority";
|
|
4
|
-
import {
|
|
5
|
-
import { IconArrowDownRight as
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
import { IconArrowDownRight as i, IconArrowUpRight as a } from "@tabler/icons-react";
|
|
6
6
|
//#region src/components/metric-tile/metric-tile.tsx
|
|
7
|
-
var
|
|
7
|
+
var o = t("flex min-w-0 flex-col", {
|
|
8
8
|
variants: { variant: {
|
|
9
9
|
subtle: "rounded-xl bg-surface-subtle px-4 py-3",
|
|
10
10
|
plain: "",
|
|
11
|
-
card: "rounded-
|
|
11
|
+
card: "@container/metric-tile relative gap-1 rounded-lg border border-border-subtle bg-card px-[18px] pt-4 pb-3.5"
|
|
12
12
|
} },
|
|
13
13
|
defaultVariants: { variant: "subtle" }
|
|
14
|
-
}),
|
|
14
|
+
}), s = t("tabular-nums", {
|
|
15
15
|
variants: { size: {
|
|
16
16
|
lg: "type-page-title",
|
|
17
17
|
md: "type-metric"
|
|
18
18
|
} },
|
|
19
19
|
defaultVariants: { size: "lg" }
|
|
20
20
|
});
|
|
21
|
-
function
|
|
22
|
-
let
|
|
21
|
+
function c({ label: t, icon: c, value: l, unit: u, delta: d, note: f, chart: p, variant: m, size: h, className: g, ..._ }) {
|
|
22
|
+
let v = m === "card", y = d?.tone ?? (d?.trend === "down" ? "negative" : "positive"), b = d?.trend === "down" ? i : a, x = d ? /* @__PURE__ */ r("p", {
|
|
23
23
|
"data-slot": "metric-tile-delta",
|
|
24
|
-
"data-trend":
|
|
25
|
-
className: e("type-meta flex items-center gap-1",
|
|
24
|
+
"data-trend": d.trend,
|
|
25
|
+
className: e("type-meta flex items-center gap-1", v ? e("mt-0.5 w-fit gap-0.5 self-start rounded-[6px] px-[7px] py-px font-medium whitespace-nowrap tabular-nums", y === "positive" ? "bg-success-soft text-success" : "bg-destructive-soft text-destructive") : "mt-0.5 text-muted-foreground"),
|
|
26
26
|
children: [
|
|
27
|
-
/* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ n(b, {
|
|
28
28
|
"aria-hidden": "true",
|
|
29
|
-
className: e("
|
|
29
|
+
className: e("shrink-0", v ? "icon-optical-12 text-current" : y === "positive" ? "icon-optical-14 text-success" : "icon-optical-14 text-warning")
|
|
30
30
|
}),
|
|
31
|
-
/* @__PURE__ */
|
|
31
|
+
/* @__PURE__ */ r("span", {
|
|
32
32
|
className: "sr-only",
|
|
33
|
-
children: [
|
|
33
|
+
children: [d.trend === "up" ? "Up" : "Down", ", "]
|
|
34
34
|
}),
|
|
35
|
-
|
|
35
|
+
d.label
|
|
36
36
|
]
|
|
37
|
-
}) : null,
|
|
37
|
+
}) : null, S = f ? /* @__PURE__ */ n("div", {
|
|
38
38
|
"data-slot": "metric-tile-note",
|
|
39
|
-
className: "type-meta text-muted-foreground",
|
|
40
|
-
children:
|
|
39
|
+
className: e(v ? "type-label min-w-0 truncate font-normal text-muted-foreground" : "type-meta text-muted-foreground", v && p && "@min-[11rem]/metric-tile:pr-24"),
|
|
40
|
+
children: f
|
|
41
41
|
}) : null;
|
|
42
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ r("div", {
|
|
43
43
|
"data-slot": "metric-tile",
|
|
44
|
-
"data-variant":
|
|
45
|
-
className: e(
|
|
46
|
-
...
|
|
44
|
+
"data-variant": m ?? "subtle",
|
|
45
|
+
className: e(o({ variant: m }), g),
|
|
46
|
+
..._,
|
|
47
47
|
children: [
|
|
48
|
-
|
|
48
|
+
c ? /* @__PURE__ */ r("p", {
|
|
49
49
|
"data-slot": "metric-tile-label",
|
|
50
50
|
className: "type-label flex items-center gap-2 font-medium",
|
|
51
|
-
children: [
|
|
52
|
-
}) : /* @__PURE__ */
|
|
51
|
+
children: [c, t]
|
|
52
|
+
}) : /* @__PURE__ */ n("p", {
|
|
53
53
|
"data-slot": "metric-tile-label",
|
|
54
|
-
className: "type-meta text-muted-foreground",
|
|
54
|
+
className: e(v ? "type-label font-normal" : "type-meta", "text-muted-foreground"),
|
|
55
55
|
children: t
|
|
56
56
|
}),
|
|
57
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ n("p", {
|
|
58
58
|
"data-slot": "metric-tile-value",
|
|
59
|
-
className: e(
|
|
60
|
-
children:
|
|
59
|
+
className: e(v ? "type-stat tabular-nums" : s({ size: h }), c ? "mt-5" : !v && h === "md" && "mt-0.5"),
|
|
60
|
+
children: l
|
|
61
61
|
}),
|
|
62
|
-
|
|
62
|
+
u ? /* @__PURE__ */ n("div", {
|
|
63
63
|
className: "type-meta text-muted-foreground",
|
|
64
|
-
children:
|
|
64
|
+
children: u
|
|
65
65
|
}) : null,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
className: "flex-none pb-0.5",
|
|
74
|
-
children: m
|
|
75
|
-
})]
|
|
76
|
-
}) : /* @__PURE__ */ i(n, { children: [S, C] })
|
|
66
|
+
x,
|
|
67
|
+
S,
|
|
68
|
+
p ? /* @__PURE__ */ n("div", {
|
|
69
|
+
"data-slot": "metric-tile-chart",
|
|
70
|
+
className: e("self-end", v && "mt-1 @min-[11rem]/metric-tile:absolute @min-[11rem]/metric-tile:right-4 @min-[11rem]/metric-tile:bottom-3.5 @min-[11rem]/metric-tile:mt-0"),
|
|
71
|
+
children: p
|
|
72
|
+
}) : null
|
|
77
73
|
]
|
|
78
74
|
});
|
|
79
75
|
}
|
|
80
76
|
//#endregion
|
|
81
|
-
export {
|
|
77
|
+
export { c as MetricTile, o as metricTileVariants };
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
type SparklineProps = Omit<React.ComponentProps<'svg'>, 'values'> & {
|
|
3
|
-
/** The points, oldest first. Null leaves a
|
|
3
|
+
/** The points, oldest first. Null leaves a gap in the line. */
|
|
4
4
|
values: readonly (number | null)[];
|
|
5
5
|
/** Any CSS color. Defaults to the text color, so a `text-*` class sets it. */
|
|
6
6
|
color?: string;
|
|
7
|
-
/** Rendered width and height in pixels. */
|
|
7
|
+
/** Rendered width and height in pixels. Defaults to builder's 90 by 28. */
|
|
8
8
|
width?: number;
|
|
9
9
|
height?: number;
|
|
10
|
+
/** The line's width in pixels. */
|
|
11
|
+
strokeWidth?: number;
|
|
12
|
+
/** Fills under the line with a fading tint. */
|
|
13
|
+
area?: boolean;
|
|
14
|
+
/** Marks the last point with a dot. */
|
|
15
|
+
dot?: boolean;
|
|
10
16
|
/** Names the chart for assistive tech. Leave it out when nearby text says the value. */
|
|
11
17
|
label?: string;
|
|
12
18
|
};
|
|
13
19
|
/**
|
|
14
|
-
* A small line with no axes,
|
|
15
|
-
*
|
|
20
|
+
* A small trend line with no axes, as in builder's stat tiles: a 2px round
|
|
21
|
+
* stroke, with an optional tint under it and a dot on the last point.
|
|
22
|
+
* Decorative unless given a `label`.
|
|
16
23
|
*/
|
|
17
|
-
declare function Sparkline({ values, color, width, height, label, className, style, ...props }: SparklineProps): React.JSX.Element;
|
|
24
|
+
declare function Sparkline({ values, color, width, height, strokeWidth, area, dot, label, className, style, ...props }: SparklineProps): React.JSX.Element;
|
|
18
25
|
export { Sparkline, type SparklineProps };
|
|
19
26
|
//# sourceMappingURL=sparkline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../../../src/components/sparkline/sparkline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG;IAClE
|
|
1
|
+
{"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../../../src/components/sparkline/sparkline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG;IAClE,+DAA+D;IAC/D,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IAClC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,uCAAuC;IACvC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID;;;;GAIG;AACH,iBAAS,SAAS,CAAC,EACjB,MAAM,EACN,KAAK,EACL,KAAU,EACV,MAAW,EACX,WAAe,EACf,IAAY,EACZ,GAAW,EACX,KAAK,EACL,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,qBAqFhB;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,CAAA"}
|
|
@@ -1,69 +1,74 @@
|
|
|
1
1
|
import { cn as e } from "../../lib/utils.js";
|
|
2
2
|
import * as t from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/sparkline/sparkline.tsx
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
function i({ values: i, color: a, width: o = 90, height: s = 28, strokeWidth: c = 2, area: l = !1, dot: u = !1, label: d, className: f, style: p, ...m }) {
|
|
6
|
+
let h = `sparkline${t.useId().replace(/:/g, "")}`, g = i.filter((e) => e !== null && Number.isFinite(e)), _ = c, v = Math.min(...g), y = Math.max(...g), b = y - v || 1, x = i.length > 1 ? (o - _ * 2) / (i.length - 1) : 0, S = [[]];
|
|
7
|
+
i.forEach((e, t) => {
|
|
8
|
+
if (e === null || !Number.isFinite(e)) {
|
|
9
|
+
S[S.length - 1].length && S.push([]);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
S[S.length - 1].push({
|
|
13
|
+
x: _ + t * x,
|
|
14
|
+
y: y === v ? s / 2 : _ + (1 - (e - v) / b) * (s - _ * 2)
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
let C = S.filter((e) => e.length > 0), w = C[C.length - 1]?.at(-1), T = (e) => e.map(({ x: e, y: t }) => `${e.toFixed(2)},${t.toFixed(2)}`).join(" ");
|
|
18
|
+
return /* @__PURE__ */ r("svg", {
|
|
14
19
|
"data-slot": "sparkline",
|
|
15
|
-
viewBox: `0 0 ${
|
|
16
|
-
width:
|
|
17
|
-
height:
|
|
18
|
-
className: e("flex-none overflow-visible",
|
|
19
|
-
style:
|
|
20
|
-
color:
|
|
21
|
-
...
|
|
22
|
-
} :
|
|
23
|
-
...
|
|
20
|
+
viewBox: `0 0 ${o} ${s}`,
|
|
21
|
+
width: o,
|
|
22
|
+
height: s,
|
|
23
|
+
className: e("flex-none overflow-visible", f),
|
|
24
|
+
style: a ? {
|
|
25
|
+
color: a,
|
|
26
|
+
...p
|
|
27
|
+
} : p,
|
|
28
|
+
...d ? {
|
|
24
29
|
role: "img",
|
|
25
|
-
"aria-label":
|
|
30
|
+
"aria-label": d
|
|
26
31
|
} : { "aria-hidden": !0 },
|
|
27
|
-
...
|
|
28
|
-
children: [
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
id:
|
|
32
|
+
...m,
|
|
33
|
+
children: [
|
|
34
|
+
l ? /* @__PURE__ */ n("defs", { children: /* @__PURE__ */ r("linearGradient", {
|
|
35
|
+
id: h,
|
|
31
36
|
x1: "0",
|
|
32
37
|
y1: "0",
|
|
33
38
|
x2: "0",
|
|
34
39
|
y2: "1",
|
|
35
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ n("stop", {
|
|
36
41
|
offset: "0",
|
|
37
42
|
stopColor: "currentColor",
|
|
38
43
|
stopOpacity: "0.18"
|
|
39
|
-
}), /* @__PURE__ */
|
|
44
|
+
}), /* @__PURE__ */ n("stop", {
|
|
40
45
|
offset: "1",
|
|
41
46
|
stopColor: "currentColor",
|
|
42
47
|
stopOpacity: "0"
|
|
43
48
|
})]
|
|
44
|
-
}) }),
|
|
45
|
-
/* @__PURE__ */ r("polygon", {
|
|
49
|
+
}) }) : null,
|
|
50
|
+
C.map((e, i) => e.length > 1 ? /* @__PURE__ */ r(t.Fragment, { children: [l ? /* @__PURE__ */ n("polygon", {
|
|
46
51
|
"data-slot": "sparkline-area",
|
|
47
|
-
fill: `url(#${
|
|
48
|
-
points: `${
|
|
49
|
-
}),
|
|
50
|
-
/* @__PURE__ */ r("polyline", {
|
|
52
|
+
fill: `url(#${h})`,
|
|
53
|
+
points: `${e[0].x},${s} ${T(e)} ${e[e.length - 1].x},${s}`
|
|
54
|
+
}) : null, /* @__PURE__ */ n("polyline", {
|
|
51
55
|
"data-slot": "sparkline-line",
|
|
52
56
|
fill: "none",
|
|
53
57
|
stroke: "currentColor",
|
|
54
|
-
strokeWidth:
|
|
58
|
+
strokeWidth: c,
|
|
55
59
|
strokeLinejoin: "round",
|
|
56
60
|
strokeLinecap: "round",
|
|
57
|
-
points:
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
points: T(e)
|
|
62
|
+
})] }, i) : null),
|
|
63
|
+
u && w ? /* @__PURE__ */ n("circle", {
|
|
64
|
+
"data-slot": "sparkline-end",
|
|
65
|
+
cx: w.x,
|
|
66
|
+
cy: w.y,
|
|
67
|
+
r: c + .5,
|
|
68
|
+
fill: "currentColor"
|
|
69
|
+
}) : null
|
|
70
|
+
]
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
//#endregion
|
|
69
|
-
export {
|
|
74
|
+
export { i as Sparkline };
|
package/package.json
CHANGED
package/src/styles/globals.css
CHANGED
|
@@ -165,6 +165,10 @@
|
|
|
165
165
|
--type-metric-size: 1.375rem;
|
|
166
166
|
--type-metric-line-height: 1.2;
|
|
167
167
|
--type-metric-letter-spacing: -0.02em;
|
|
168
|
+
/* The number in builder's stat tile (ADR 0027): 30px medium, set tight. */
|
|
169
|
+
--type-stat-size: 1.875rem;
|
|
170
|
+
--type-stat-line-height: 1.2;
|
|
171
|
+
--type-stat-letter-spacing: -0.02em;
|
|
168
172
|
--type-accent-title-size: 1.5625rem;
|
|
169
173
|
--type-accent-title-line-height: 1.12;
|
|
170
174
|
--type-content-size: 1rem;
|
|
@@ -692,6 +696,13 @@
|
|
|
692
696
|
font-weight: 400;
|
|
693
697
|
}
|
|
694
698
|
|
|
699
|
+
.type-stat {
|
|
700
|
+
font-size: var(--type-stat-size);
|
|
701
|
+
line-height: var(--type-stat-line-height);
|
|
702
|
+
letter-spacing: var(--type-stat-letter-spacing);
|
|
703
|
+
font-weight: 500;
|
|
704
|
+
}
|
|
705
|
+
|
|
695
706
|
.type-accent-title {
|
|
696
707
|
font-family: var(--font-accent);
|
|
697
708
|
font-size: var(--type-accent-title-size);
|