@sit-onyx/chartjs-plugin 1.0.0-alpha.10 → 1.0.0-alpha.12

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/utils.ts +6 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
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-alpha.10",
4
+ "version": "1.0.0-alpha.12",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "peerDependencies": {
26
26
  "chart.js": ">= 4.0.0",
27
- "sit-onyx": "^1.0.0-alpha.55"
27
+ "sit-onyx": "^1.0.0-alpha.57"
28
28
  },
29
29
  "devDependencies": {
30
30
  "vue-chartjs": "^5.3.0"
package/src/utils.ts CHANGED
@@ -2,6 +2,7 @@ import type { OnyxColor } from "sit-onyx/types";
2
2
 
3
3
  /**
4
4
  * Utility for easily styling a Chart.js dataset with a specific onyx color.
5
+ * Will be updated automatically when switching between light/dark mode.
5
6
  *
6
7
  * @example
7
8
  * ```ts
@@ -21,11 +22,13 @@ export const getDatasetColors = (
21
22
  color: OnyxColor | `quantitatives-${100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900}`,
22
23
  ) => {
23
24
  const cssVariable = `--onyx-color-base-${color.startsWith("quantitatives-") ? color : `${color}-500`}`;
24
- const baseColor = getCSSVariableValue(cssVariable);
25
+ // we use arrow functions here so the value is updated / re-evaluated when
26
+ // switched between light and dark mode
27
+ const borderColor = () => getCSSVariableValue(cssVariable);
25
28
 
26
29
  return {
27
- borderColor: baseColor,
28
- backgroundColor: `rgba(${hexToRgb(baseColor)}, 0.3)`,
30
+ borderColor,
31
+ backgroundColor: () => `rgba(${hexToRgb(borderColor())}, 0.3)`,
29
32
  };
30
33
  };
31
34