@jackbernnie/hiyf 0.1.5 → 0.1.7
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/AGENTS.md +5 -0
- package/dist/components/Chart.d.ts +6 -1
- package/dist/components/Chart.js +8 -2
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/chart.js +49 -1
- package/package.json +2 -1
- package/src/theme.css +10 -10
package/AGENTS.md
CHANGED
|
@@ -52,6 +52,11 @@ import { Box, Text } from '@jackbernnie/hiyf'
|
|
|
52
52
|
|
|
53
53
|
`<Text>` renders all text. Pick a `variant` (a role), never a raw size.
|
|
54
54
|
|
|
55
|
+
`Card` self-pads and **fills its container width** by default — drop content
|
|
56
|
+
straight in (`<Card padding="md">…`), no wrapper needed. For an even row of cards,
|
|
57
|
+
use `Grid` (`gridTemplateColumns="repeat(4, minmax(0, 1fr))"`) or a flex row of
|
|
58
|
+
`flexGrow={1}` slots — the layout controls across-row sizing; the card fills it.
|
|
59
|
+
|
|
55
60
|
## Token vocabulary (the entire allowed set)
|
|
56
61
|
|
|
57
62
|
| Prop | Tokens |
|
|
@@ -13,5 +13,10 @@ export interface ChartProps {
|
|
|
13
13
|
* @default 'md'
|
|
14
14
|
*/
|
|
15
15
|
height?: "sm" | "md" | "lg";
|
|
16
|
+
/**
|
|
17
|
+
* Show a legend mapping each series to its color.
|
|
18
|
+
* @default true when there is more than one category
|
|
19
|
+
*/
|
|
20
|
+
legend?: boolean;
|
|
16
21
|
}
|
|
17
|
-
export declare function Chart({ type, data, index, categories, height, }: ChartProps): React.JSX.Element;
|
|
22
|
+
export declare function Chart({ type, data, index, categories, height, legend, }: ChartProps): React.JSX.Element;
|
package/dist/components/Chart.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { LineChart, Line, BarChart, Bar, AreaChart, Area, CartesianGrid, XAxis } from 'recharts';
|
|
4
|
-
import { ChartContainer, ChartTooltip, ChartTooltipContent } from './ui/chart.js';
|
|
4
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent } from './ui/chart.js';
|
|
5
5
|
|
|
6
6
|
const CHART_COLORS = [
|
|
7
7
|
"var(--chart-1)",
|
|
@@ -20,8 +20,10 @@ function Chart({
|
|
|
20
20
|
data,
|
|
21
21
|
index,
|
|
22
22
|
categories,
|
|
23
|
-
height = "md"
|
|
23
|
+
height = "md",
|
|
24
|
+
legend
|
|
24
25
|
}) {
|
|
26
|
+
const showLegend = legend ?? categories.length > 1;
|
|
25
27
|
const config = Object.fromEntries(
|
|
26
28
|
categories.map((cat, i) => [
|
|
27
29
|
cat,
|
|
@@ -36,12 +38,14 @@ function Chart({
|
|
|
36
38
|
const grid = /* @__PURE__ */ jsx(CartesianGrid, { vertical: false });
|
|
37
39
|
const xAxis = /* @__PURE__ */ jsx(XAxis, { dataKey: index, tickLine: false, axisLine: false });
|
|
38
40
|
const tooltip = /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) });
|
|
41
|
+
const legendNode = showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null;
|
|
39
42
|
let chart;
|
|
40
43
|
if (type === "line") {
|
|
41
44
|
chart = /* @__PURE__ */ jsxs(LineChart, { ...commonProps, children: [
|
|
42
45
|
grid,
|
|
43
46
|
xAxis,
|
|
44
47
|
tooltip,
|
|
48
|
+
legendNode,
|
|
45
49
|
categories.map((cat) => /* @__PURE__ */ jsx(
|
|
46
50
|
Line,
|
|
47
51
|
{
|
|
@@ -59,6 +63,7 @@ function Chart({
|
|
|
59
63
|
grid,
|
|
60
64
|
xAxis,
|
|
61
65
|
tooltip,
|
|
66
|
+
legendNode,
|
|
62
67
|
categories.map((cat) => /* @__PURE__ */ jsx(
|
|
63
68
|
Bar,
|
|
64
69
|
{
|
|
@@ -74,6 +79,7 @@ function Chart({
|
|
|
74
79
|
grid,
|
|
75
80
|
xAxis,
|
|
76
81
|
tooltip,
|
|
82
|
+
legendNode,
|
|
77
83
|
categories.map((cat) => /* @__PURE__ */ jsx(
|
|
78
84
|
Area,
|
|
79
85
|
{
|
|
@@ -12,7 +12,7 @@ function Card({
|
|
|
12
12
|
"data-slot": "card",
|
|
13
13
|
"data-size": size,
|
|
14
14
|
className: cn(
|
|
15
|
-
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card px-(--card-spacing) py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
15
|
+
"group/card flex w-full flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card px-(--card-spacing) py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
16
16
|
className
|
|
17
17
|
),
|
|
18
18
|
...props
|
|
@@ -181,6 +181,54 @@ function ChartTooltipContent({
|
|
|
181
181
|
}
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
185
|
+
function ChartLegendContent({
|
|
186
|
+
className,
|
|
187
|
+
hideIcon = false,
|
|
188
|
+
payload,
|
|
189
|
+
verticalAlign = "bottom",
|
|
190
|
+
nameKey
|
|
191
|
+
}) {
|
|
192
|
+
const { config } = useChart();
|
|
193
|
+
if (!payload?.length) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return /* @__PURE__ */ jsx(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
className: cn(
|
|
200
|
+
"flex items-center justify-center gap-4",
|
|
201
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
202
|
+
className
|
|
203
|
+
),
|
|
204
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
205
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`;
|
|
206
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
207
|
+
return /* @__PURE__ */ jsxs(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
className: cn(
|
|
211
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
212
|
+
),
|
|
213
|
+
children: [
|
|
214
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
218
|
+
style: {
|
|
219
|
+
backgroundColor: item.color
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
itemConfig?.label
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
index
|
|
227
|
+
);
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
184
232
|
function getPayloadConfigFromPayload(config, payload, key) {
|
|
185
233
|
if (typeof payload !== "object" || payload === null) {
|
|
186
234
|
return void 0;
|
|
@@ -195,4 +243,4 @@ function getPayloadConfigFromPayload(config, payload, key) {
|
|
|
195
243
|
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
196
244
|
}
|
|
197
245
|
|
|
198
|
-
export { ChartContainer, ChartStyle, ChartTooltip, ChartTooltipContent };
|
|
246
|
+
export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackbernnie/hiyf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "human-in-your-face — a personal, LLM-safe design system. Forked from Polar's Orbit (Apache-2.0).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"recharts": "^3.8.0",
|
|
65
65
|
"sonner": "^2.0.7",
|
|
66
66
|
"tailwind-merge": "^3.6.0",
|
|
67
|
+
"tslib": "^2.8.0",
|
|
67
68
|
"vaul": "^1.1.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
package/src/theme.css
CHANGED
|
@@ -141,11 +141,11 @@
|
|
|
141
141
|
--border: oklch(0.922 0 0);
|
|
142
142
|
--input: oklch(0.922 0 0);
|
|
143
143
|
--ring: oklch(0.708 0 0);
|
|
144
|
-
--chart-1: oklch(0.
|
|
145
|
-
--chart-2: oklch(0.
|
|
146
|
-
--chart-3: oklch(0.
|
|
147
|
-
--chart-4: oklch(0.
|
|
148
|
-
--chart-5: oklch(0.
|
|
144
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
145
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
146
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
147
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
148
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
149
149
|
--radius: 0.75rem;
|
|
150
150
|
--sidebar: oklch(0.985 0 0);
|
|
151
151
|
--sidebar-foreground: oklch(0.145 0 0);
|
|
@@ -176,11 +176,11 @@
|
|
|
176
176
|
--border: oklch(1 0 0 / 10%);
|
|
177
177
|
--input: oklch(1 0 0 / 15%);
|
|
178
178
|
--ring: oklch(0.556 0 0);
|
|
179
|
-
--chart-1: oklch(0.
|
|
180
|
-
--chart-2: oklch(0.
|
|
181
|
-
--chart-3: oklch(0.
|
|
182
|
-
--chart-4: oklch(0.
|
|
183
|
-
--chart-5: oklch(0.
|
|
179
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
180
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
181
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
182
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
183
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
184
184
|
--sidebar: oklch(0.205 0 0);
|
|
185
185
|
--sidebar-foreground: oklch(0.985 0 0);
|
|
186
186
|
--sidebar-primary: oklch(0.488 0.243 264.376);
|