import * as React from "react"; import { keys, get } from "lodash"; import { Grid } from "@material-ui/core"; import Select from "react-select"; import { CSSProperties } from "./types"; interface StyleBuilderProps { /** * The incoming style object */ style: React.CSSProperties; /** * Triggered when the setting changes. * * Returns the incoming style object with modifications */ onChange: (style: React.CSSProperties) => void; } const localStyle = { container: { border: "1px solid #CCC", marginTop: 2, }, cell: { fontFamily: "Roboto", fontSize: "10pt", margin: "5px 0", }, input: { width: "100%", boxSizing: "border-box", border: "none", outline: "none", fontSize: "10pt", }, }; export const StyleBuilder: React.FC = ({ style, onChange, }) => { const styleKeys = keys(style); const handleChange = (property, value) => { console.log({ property, value }); onChange({ ...style, [property]: value }); }; const convertCamelCaseToSentenceCase = (text) => { const result = text.replace(/([A-Z])/g, " $1"); return result.charAt(0).toUpperCase() + result.slice(1); }; const options = Object.keys(CSSProperties).map((itm) => ({ value: itm, label: convertCamelCaseToSentenceCase(itm), })); console.log(options); return ( {styleKeys.map((property) => ( <> handleChange(property, e.target.value)} /> ))} ); }; export default StyleBuilder;