Skip to content

Commit f987a2b

Browse files
committed
Apply dark mode
1 parent d0b47ad commit f987a2b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

chartlets.js/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 0.0.30 (in development)
2+
3+
* The `Plot` component now respects the current MUI theme mode `"dark"`. (#XX)
4+
15
## Version 0.0.29 (from 2024/11/26)
26

37
* Resolved warnings that appeared when using Vega charts.

chartlets.js/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chartlets.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chartlets",
3-
"version": "0.0.29",
3+
"version": "0.0.30",
44
"description": "An experimental library for integrating interactive charts into existing JavaScript applications.",
55
"type": "module",
66
"files": [

chartlets.js/src/lib/components/Plot.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { VegaLite } from "react-vega";
2+
import type { TopLevelSpec } from "vega-lite";
3+
import { useTheme } from "@mui/material";
24

35
import { type ComponentState } from "@/lib/types/state/component";
46
import type { ComponentProps } from "@/lib/component/Component";
57
import { useSignalListeners } from "@/lib/hooks";
6-
import type { TopLevelSpec } from "vega-lite";
78

89
interface PlotState extends ComponentState {
910
chart?:
@@ -14,6 +15,7 @@ interface PlotState extends ComponentState {
1415
interface PlotProps extends ComponentProps, PlotState {}
1516

1617
export function Plot({ type, id, style, chart, onChange }: PlotProps) {
18+
const muiTheme = useTheme();
1719
const signalListeners = useSignalListeners(chart, type, id, onChange);
1820

1921
if (!chart) {
@@ -22,6 +24,7 @@ export function Plot({ type, id, style, chart, onChange }: PlotProps) {
2224

2325
return (
2426
<VegaLite
27+
theme={muiTheme.palette.mode === "dark" ? "dark" : undefined}
2528
spec={chart}
2629
style={style}
2730
signalListeners={signalListeners}

0 commit comments

Comments
 (0)