import * as React from "react"; import LinearProgress from "@material-ui/core/LinearProgress"; import { lighten, makeStyles, withStyles } from "@material-ui/core/styles"; import { get } from "lodash"; import { ProgressProps, PluginProps } from "./types"; import { ComponentTypes } from "../types"; import { V1ObjectWrapper, convertProperties } from "../V1ObjectWrapper"; export const Progress: React.FC = ({ style = {}, properties = {}, barStyle = { backgroundColor: "#2096D3" }, value = 0, }) => { const BorderLinearProgress = withStyles({ root: { height: 20, backgroundColor: lighten( get(barStyle, "backgroundColor", "#2096D3"), 0.5 ), borderRadius: 20, }, bar: { ...barStyle, borderRadius: 20, backgroundColor: get(barStyle, "backgroundColor", "#2096D3"), }, })(LinearProgress); const useStyles = makeStyles((theme) => ({ root: { flexGrow: 1, }, margin: { margin: theme.spacing(1), }, })); const classes = useStyles(); return (
); }; const ProgressPlugin: React.FC = ({ settings }) => { const properties = convertProperties(settings.properties); return ( ); }; export const onComponentRender = (hook, payload, actions) => { if (hook.id === "webcomponent" && payload.type === ComponentTypes.PROGRESS) { return [ProgressPlugin]; } }; export default Progress;