Skip to content

Commit c1a5421

Browse files
author
iexitdev
committed
Apply Pro chart themes in docs
1 parent 4760735 commit c1a5421

4 files changed

Lines changed: 28 additions & 17 deletions

File tree

apps/site/src/components/ThemeInit.astro

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
<script is:inline>
1+
---
2+
import { chartThemeOptions } from "../previews/chartTheme";
3+
4+
const chartThemeValues = chartThemeOptions.map((option) => option.value);
5+
const themeInitScript = `
26
(() => {
37
const storageKey = "starlight-theme";
48
const chartThemeStorageKey = "chartkit-chart-theme";
5-
const chartThemes = new Set([
6-
"default",
7-
"spectrum",
8-
"aurora",
9-
"verdant",
10-
"cupertino",
11-
"material",
12-
"graphite",
13-
"contrast",
14-
"midnight",
15-
"studio"
16-
]);
9+
const chartThemes = new Set(${JSON.stringify(chartThemeValues)});
1710
const getStoredTheme = () => {
1811
try {
1912
const stored = localStorage.getItem(storageKey);
@@ -42,4 +35,7 @@
4235
document.documentElement.dataset.chartTheme = chartTheme;
4336
document.documentElement.style.colorScheme = theme;
4437
})();
45-
</script>
38+
`;
39+
---
40+
41+
<script is:inline set:html={themeInitScript} />

apps/site/src/previews/chartTheme.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import {
2+
proCartesianChartPresetOptions,
3+
type ProCartesianChartPresetName
4+
} from "@chart-kit/pro/themes";
5+
16
export type ChartThemePreset =
27
| "default"
38
| "spectrum"
@@ -8,7 +13,8 @@ export type ChartThemePreset =
813
| "graphite"
914
| "contrast"
1015
| "midnight"
11-
| "studio";
16+
| "studio"
17+
| ProCartesianChartPresetName;
1218

1319
export const chartThemeStorageKey = "chartkit-chart-theme";
1420
export const chartThemeChangeEvent = "chartkit:chart-theme-change";
@@ -26,7 +32,11 @@ export const chartThemeOptions: Array<{
2632
{ label: "Graphite", value: "graphite" },
2733
{ label: "Contrast", value: "contrast" },
2834
{ label: "Midnight", value: "midnight" },
29-
{ label: "Studio", value: "studio" }
35+
{ label: "Studio", value: "studio" },
36+
...proCartesianChartPresetOptions.map((option) => ({
37+
label: `${option.title} (Pro)`,
38+
value: option.id
39+
}))
3040
];
3141

3242
export const isChartThemePreset = (

apps/site/src/previews/reactNativeWebStub.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,9 @@ export const Touchable = {
10411041
};
10421042

10431043
export const NativeModules = {};
1044+
export const Share = {
1045+
share: () => Promise.resolve({ action: "sharedAction" })
1046+
};
10441047
export const UIManager = {};
10451048
export const TurboModuleRegistry = {
10461049
get: () => null,

apps/site/src/previews/showcaseTheme.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
createChartPreset,
33
type CartesianChartPresetRegistry
44
} from "react-native-chart-kit/v2";
5+
import { proCartesianChartPresets } from "@chart-kit/pro/themes";
56

67
export const showcaseCustomPresets: CartesianChartPresetRegistry = {
78
studio: createChartPreset({
@@ -31,5 +32,6 @@ export const showcaseCustomPresets: CartesianChartPresetRegistry = {
3132
legendLabelSize: 12
3233
}
3334
}
34-
})
35+
}),
36+
...proCartesianChartPresets
3537
};

0 commit comments

Comments
 (0)