inconvo 1.2.0 → 1.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inconvo",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "CLI for installing Inconvo assistant-ui tool components into any project.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,27 +1,15 @@
1
- const clamp = (value: number, min = 0, max = 1) =>
2
- Math.min(Math.max(value, min), max);
3
-
4
- const lightnessToGrayHex = (lightness: number) => {
5
- const channel = Math.round(clamp(lightness) * 255)
6
- .toString(16)
7
- .padStart(2, "0");
8
- return `#${channel}${channel}${channel}`;
9
- };
10
-
11
- export const buildGreyscalePalette = (
12
- seriesCount: number,
13
- isDarkMode: boolean,
14
- ) => {
1
+ const chartColorVars = [
2
+ "var(--chart-1)",
3
+ "var(--chart-2)",
4
+ "var(--chart-3)",
5
+ "var(--chart-4)",
6
+ "var(--chart-5)",
7
+ ];
8
+
9
+ export const buildChartPalette = (seriesCount: number) => {
15
10
  if (seriesCount <= 0) return [];
16
- if (seriesCount === 1) {
17
- return [lightnessToGrayHex(isDarkMode ? 0.78 : 0.5)];
18
- }
19
-
20
- const start = isDarkMode ? 0.95 : 0.8;
21
- const end = isDarkMode ? 0.55 : 0.15;
22
- const step = (end - start) / (seriesCount - 1);
23
-
24
- return Array.from({ length: seriesCount }, (_, index) =>
25
- lightnessToGrayHex(start + step * index),
26
- );
11
+ return Array.from({ length: seriesCount }, (_, index) => {
12
+ const colorIndex = index % chartColorVars.length;
13
+ return chartColorVars[colorIndex] ?? "var(--chart-series-primary)";
14
+ });
27
15
  };
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, type ReactNode } from "react";
4
- import { useTheme } from "next-themes";
5
4
  import {
6
5
  ResponsiveContainer,
7
6
  LineChart as RechartsLineChart,
@@ -17,7 +16,7 @@ import {
17
16
  } from "recharts";
18
17
 
19
18
  import type { InconvoChartData, InconvoChartType } from "~/lib/inconvo/types";
20
- import { buildGreyscalePalette } from "~/components/assistant-ui/tools/inconvo-chart-colors";
19
+ import { buildChartPalette } from "~/components/assistant-ui/tools/inconvo-chart-colors";
21
20
 
22
21
  interface InconvoChartProps {
23
22
  data: InconvoChartData;
@@ -107,8 +106,6 @@ export const InconvoChart = ({
107
106
  xLabel,
108
107
  yLabel,
109
108
  }: InconvoChartProps) => {
110
- const { resolvedTheme } = useTheme();
111
-
112
109
  const chartData = useMemo(() => {
113
110
  return data.labels.map((label, index) => {
114
111
  const row: { name: string; [key: string]: string | number } = {
@@ -121,10 +118,10 @@ export const InconvoChart = ({
121
118
  });
122
119
  }, [data]);
123
120
 
124
- const palette = useMemo(() => {
125
- const isDarkMode = resolvedTheme === "dark";
126
- return buildGreyscalePalette(data.datasets.length, isDarkMode);
127
- }, [data.datasets.length, resolvedTheme]);
121
+ const palette = useMemo(
122
+ () => buildChartPalette(data.datasets.length),
123
+ [data.datasets.length],
124
+ );
128
125
 
129
126
  const axisColor = "var(--muted-foreground)";
130
127
  const textColor = "var(--foreground)";