@sit-onyx/chartjs-plugin 1.0.0-beta.29 → 1.0.0-beta.290

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.
Files changed (30) hide show
  1. package/README.md +1 -5
  2. package/package.json +15 -4
  3. package/src/index.ts +2 -2
  4. package/src/plugin.ts +2 -2
  5. package/src/stories/BarChart/BarChart.ct.tsx +1 -1
  6. package/src/stories/BarChart/BarChart.stories.ts +1 -1
  7. package/src/stories/BarChart/BarChart.vue +1 -1
  8. package/src/stories/BubbleChart/BubbleChart.ct.tsx +1 -1
  9. package/src/stories/BubbleChart/BubbleChart.stories.ts +1 -1
  10. package/src/stories/BubbleChart/BubbleChart.vue +1 -1
  11. package/src/stories/DoughnutChart/DoughnutChart.ct.tsx +1 -1
  12. package/src/stories/DoughnutChart/DoughnutChart.stories.ts +1 -1
  13. package/src/stories/DoughnutChart/DoughnutChart.vue +1 -1
  14. package/src/stories/LineChart/LineChart.ct.tsx +1 -1
  15. package/src/stories/LineChart/LineChart.stories.ts +1 -1
  16. package/src/stories/LineChart/LineChart.vue +1 -1
  17. package/src/stories/PieChart/PieChart.ct.tsx +1 -1
  18. package/src/stories/PieChart/PieChart.stories.ts +1 -1
  19. package/src/stories/PieChart/PieChart.vue +1 -1
  20. package/src/stories/PolarAreaChart/PolarAreaChart.ct.tsx +1 -1
  21. package/src/stories/PolarAreaChart/PolarAreaChart.stories.ts +1 -1
  22. package/src/stories/PolarAreaChart/PolarAreaChart.vue +1 -1
  23. package/src/stories/RadarChart/RadarChart.ct.tsx +1 -1
  24. package/src/stories/RadarChart/RadarChart.stories.ts +1 -1
  25. package/src/stories/RadarChart/RadarChart.vue +1 -1
  26. package/src/stories/ScatterChart/ScatterChart.ct.tsx +1 -1
  27. package/src/stories/ScatterChart/ScatterChart.stories.ts +1 -1
  28. package/src/stories/ScatterChart/ScatterChart.vue +1 -1
  29. package/src/utils.spec.ts +1 -1
  30. package/src/utils.ts +11 -2
package/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  <div align="center" style="text-align: center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-light.svg">
4
- <source media="(prefers-color-scheme: light)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg">
5
- <img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg" width="160px">
6
- </picture>
2
+ <img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo.svg" height="96px">
7
3
  </div>
8
4
 
9
5
  <br>
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@sit-onyx/chartjs-plugin",
3
3
  "description": "A Chart.js plugin for the onyx design system created by Schwarz IT",
4
- "version": "1.0.0-beta.29",
4
+ "version": "1.0.0-beta.290",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
8
+ "engines": {
9
+ "node": ">=20"
10
+ },
8
11
  "files": [
9
12
  "src"
10
13
  ],
@@ -24,16 +27,24 @@
24
27
  },
25
28
  "peerDependencies": {
26
29
  "chart.js": ">= 4.0.0",
27
- "sit-onyx": "^1.0.0-beta.29"
30
+ "sit-onyx": "^1.0.0-beta.296"
28
31
  },
29
32
  "devDependencies": {
30
- "vue-chartjs": "^5.3.1"
33
+ "@playwright/experimental-ct-vue": "1.54.2",
34
+ "@playwright/test": "1.54.2",
35
+ "@vue/compiler-dom": "3.5.18",
36
+ "chart.js": "4.5.0",
37
+ "vue": "3.5.18",
38
+ "vue-chartjs": "^5.3.2",
39
+ "@sit-onyx/shared": "^1.0.0-beta.4",
40
+ "@sit-onyx/storybook-utils": "^1.0.0-beta.103",
41
+ "sit-onyx": "^1.0.0-beta.296"
31
42
  },
32
43
  "scripts": {
33
44
  "dev": "storybook dev -p 6006 --no-open",
34
45
  "build": "vue-tsc --noEmit",
35
46
  "test": "vitest",
36
47
  "test:coverage": "vitest run --coverage",
37
- "test:components": "playwright install && playwright test"
48
+ "test:playwright": "playwright install && playwright test"
38
49
  }
39
50
  }
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./plugin";
2
- export * from "./utils";
1
+ export * from "./plugin.js";
2
+ export * from "./utils.js";
package/src/plugin.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
- Chart,
3
2
  DoughnutController,
4
3
  PieController,
5
4
  PolarAreaController,
5
+ type Chart,
6
6
  type ChartDataset,
7
7
  type ChartType,
8
8
  type Color,
@@ -10,7 +10,7 @@ import {
10
10
  type ScaleOptionsByType,
11
11
  type ScaleTypeRegistry,
12
12
  } from "chart.js";
13
- import { QUANTITATIVE_COLOR_STEPS, getCSSVariableValue, hexToRgb } from "./utils";
13
+ import { QUANTITATIVE_COLOR_STEPS, getCSSVariableValue, hexToRgb } from "./utils.js";
14
14
 
15
15
  /**
16
16
  * Registers the onyx Chart.js plugin and updates the default styles (colors, fonts etc.) to match
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import BarChart from "./BarChart.vue";
4
4
 
5
5
  test("should render bar chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import BarChart from "./BarChart.vue";
3
3
 
4
4
  const meta: Meta<typeof BarChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Bar } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const labels = ["01.01.2024", "01.02.2024", "01.03.2024", "01.04.2024", "01.05.2024"];
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import BubbleChart from "./BubbleChart.vue";
4
4
 
5
5
  test("should render bubble chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import BubbleChart from "./BubbleChart.vue";
3
3
 
4
4
  const meta: Meta<typeof BubbleChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Bubble } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"bubble"> = {
7
7
  datasets: [
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import DoughnutChart from "./DoughnutChart.vue";
4
4
 
5
5
  test("should render doughnut chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import DoughnutChart from "./DoughnutChart.vue";
3
3
 
4
4
  const meta: Meta<typeof DoughnutChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Doughnut } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"doughnut"> = {
7
7
  labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import LineChart from "./LineChart.vue";
4
4
 
5
5
  test("should render line chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import LineChart from "./LineChart.vue";
3
3
 
4
4
  const meta: Meta<typeof LineChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Line } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const labels = ["01.01.2024", "01.02.2024", "01.03.2024", "01.04.2024", "01.05.2024"];
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import PieChart from "./PieChart.vue";
4
4
 
5
5
  test("should render pie chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import PieChart from "./PieChart.vue";
3
3
 
4
4
  const meta: Meta<typeof PieChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Pie } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"pie"> = {
7
7
  labels: ["Label 1", "Label 2", "Label 3", "Label 4"],
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import PolarAreaChart from "./PolarAreaChart.vue";
4
4
 
5
5
  test("should render polar area chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import PolarAreaChart from "./PolarAreaChart.vue";
3
3
 
4
4
  const meta: Meta<typeof PolarAreaChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { PolarArea } from "vue-chartjs";
4
- import { chartOptionsWithoutScales } from "../data";
4
+ import { chartOptionsWithoutScales } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"polarArea"> = {
7
7
  labels: ["Label 1", "Label 2", "Label 3", "Label 4", "Label 5", "Label 6", "Label 7"],
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import RadarChart from "./RadarChart.vue";
4
4
 
5
5
  test("should render radar chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import RadarChart from "./RadarChart.vue";
3
3
 
4
4
  const meta: Meta<typeof RadarChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Radar } from "vue-chartjs";
4
- import { chartOptionsWithoutScales } from "../data";
4
+ import { chartOptionsWithoutScales } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"radar"> = {
7
7
  labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
@@ -1,5 +1,5 @@
1
1
  import { test } from "@playwright/experimental-ct-vue";
2
- import { executeChartScreenshotTest } from "../playwright-utils";
2
+ import { executeChartScreenshotTest } from "../playwright-utils.js";
3
3
  import ScatterChart from "./ScatterChart.vue";
4
4
 
5
5
  test("should render scatter chart", async ({ mount, page }) => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
2
  import ScatterChart from "./ScatterChart.vue";
3
3
 
4
4
  const meta: Meta<typeof ScatterChart> = {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import type { ChartData } from "chart.js";
3
3
  import { Scatter } from "vue-chartjs";
4
- import { chartOptions } from "../data";
4
+ import { chartOptions } from "../data.js";
5
5
 
6
6
  const chartData: ChartData<"scatter"> = {
7
7
  datasets: [
package/src/utils.spec.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import { hexToRgb } from "./utils";
2
+ import { hexToRgb } from "./utils.js";
3
3
 
4
4
  describe("utils.ts", () => {
5
5
  test("should convert hex to rgb", () => {
package/src/utils.ts CHANGED
@@ -39,8 +39,17 @@ export const getDatasetColors = (color: OnyxColor | `quantitatives-${Quantitativ
39
39
  * Gets the current value of the given CSS variable.
40
40
  * @param CSS variable name, e.g. `--onyx-color-base-primary-500`
41
41
  */
42
- export const getCSSVariableValue = (variableName: string) => {
43
- return getComputedStyle(document.body).getPropertyValue(variableName);
42
+
43
+ export const getCSSVariableValue = (variableName: string): string => {
44
+ const isDark = getComputedStyle(document.body).colorScheme === "dark";
45
+ const computedValue = getComputedStyle(document.body).getPropertyValue(variableName).trim();
46
+ const lightDarkMatch = /^light-dark\(([^,]+),\s*([^)]+)\)$/.exec(computedValue);
47
+
48
+ if (lightDarkMatch) {
49
+ return lightDarkMatch[isDark ? 2 : 1].trim();
50
+ } else {
51
+ return computedValue;
52
+ }
44
53
  };
45
54
 
46
55
  /**