@jackbernnie/hiyf 0.1.4 → 0.1.6

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 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` already has its own padding — drop content straight in (`<Card padding="md">…`),
56
+ no inner wrapper needed. To make cards fill a row and stretch to equal heights,
57
+ put them in `<Box flexDirection="row" gap="l">` and give each `flexGrow={1}` (sizing
58
+ is the layout's job; the card's padding is fixed).
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;
@@ -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 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 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
@@ -25,7 +25,7 @@ function CardHeader({ className, ...props }) {
25
25
  {
26
26
  "data-slot": "card-header",
27
27
  className: cn(
28
- "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
28
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
29
29
  className
30
30
  ),
31
31
  ...props
@@ -60,7 +60,7 @@ function CardContent({ className, ...props }) {
60
60
  "div",
61
61
  {
62
62
  "data-slot": "card-content",
63
- className: cn("px-(--card-spacing)", className),
63
+ className: cn(className),
64
64
  ...props
65
65
  }
66
66
  );
@@ -71,7 +71,7 @@ function CardFooter({ className, ...props }) {
71
71
  {
72
72
  "data-slot": "card-footer",
73
73
  className: cn(
74
- "flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",
74
+ "flex items-center rounded-b-xl [.border-t]:pt-(--card-spacing)",
75
75
  className
76
76
  ),
77
77
  ...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.4",
3
+ "version": "0.1.6",
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.87 0 0);
145
- --chart-2: oklch(0.556 0 0);
146
- --chart-3: oklch(0.439 0 0);
147
- --chart-4: oklch(0.371 0 0);
148
- --chart-5: oklch(0.269 0 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.87 0 0);
180
- --chart-2: oklch(0.556 0 0);
181
- --chart-3: oklch(0.439 0 0);
182
- --chart-4: oklch(0.371 0 0);
183
- --chart-5: oklch(0.269 0 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);