Customize Your Theme
@@ -154,18 +127,12 @@ const ThemeBuilder = () => {
/>
{customThemeConfig && (
- Customization Options
- Customization Options
+
-
)}
diff --git a/demo/ts/components/theme-builder/label-options.tsx b/demo/ts/components/theme-builder/label-options.tsx
deleted file mode 100644
index 6370f999a..000000000
--- a/demo/ts/components/theme-builder/label-options.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import React from "react";
-import { LabelProps } from "victory-core";
-import Slider from "./slider";
-import ColorPicker from "./color-picker";
-
-type LabelOptionsProps = {
- labelConfig?: LabelProps;
- onLabelConfigChange: (labelConfig: LabelProps) => void;
-};
-
-const LabelOptions = ({
- labelConfig,
- onLabelConfigChange,
-}: LabelOptionsProps) => {
- if (!labelConfig) return null;
- return (
-
-
Axis Label Options
-
- onLabelConfigChange({ fontSize: parseInt(event.target.value) })
- }
- />
-
- onLabelConfigChange({ padding: parseInt(event.target.value) })
- }
- />
-
-
- onLabelConfigChange({ fill: event.target.value })
- }
- />
-
-
- );
-};
-export default LabelOptions;
diff --git a/demo/ts/components/theme-builder/options-config.ts b/demo/ts/components/theme-builder/options-config.ts
new file mode 100644
index 000000000..e5c285e91
--- /dev/null
+++ b/demo/ts/components/theme-builder/options-config.ts
@@ -0,0 +1,41 @@
+const optionsConfig = [
+ {
+ type: "section",
+ title: "Color Options",
+ fields: [
+ {
+ type: "colorScale",
+ label: "Color Scale",
+ },
+ ],
+ },
+ {
+ type: "section",
+ title: "Axis Label Options",
+ fields: [
+ {
+ type: "slider",
+ label: "Font Size",
+ min: 10,
+ max: 24,
+ unit: "px",
+ path: "axis.style.axisLabel.fontSize",
+ },
+ {
+ type: "slider",
+ label: "Padding",
+ min: 0,
+ max: 50,
+ unit: "px",
+ path: "axis.style.axisLabel.padding",
+ },
+ {
+ type: "colorPicker",
+ label: "Fill",
+ path: "axis.style.axisLabel.fill",
+ },
+ ],
+ },
+];
+
+export default optionsConfig;
diff --git a/demo/ts/components/theme-builder/select.tsx b/demo/ts/components/theme-builder/select.tsx
index cf8787c6f..0bb7b9d17 100644
--- a/demo/ts/components/theme-builder/select.tsx
+++ b/demo/ts/components/theme-builder/select.tsx
@@ -1,4 +1,5 @@
import React from "react";
+import clsx from "clsx";
export type SelectOption = {
label: string;
@@ -10,12 +11,25 @@ type SelectProps = {
label?: string;
options: SelectOption[];
value: string;
- onChange: (event: React.ChangeEvent
) => void;
+ onChange: (value: string) => void;
+ className?: string;
};
-const Select = ({ id, label, options, value, onChange }: SelectProps) => {
+const Select = ({
+ id,
+ label,
+ options,
+ value,
+ onChange,
+ className,
+}: SelectProps) => {
+ const handleChange = (event: React.ChangeEvent) => {
+ if (onChange) {
+ onChange(event.target.value);
+ }
+ };
return (
-
+
{label && (