/* Copyright (c) Uber Technologies, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ import * as React from "react"; import { useStyletron } from "baseui"; import { Button, KIND, SIZE } from "baseui/button"; import type { TPropValue, TKnobsProps } from "react-view"; import { PropTypes } from "react-view"; import Knob from "./knob"; const KnobColumn: React.FC = ({ state, knobNames, error, set, }) => { const [css, theme] = useStyletron(); return (
{knobNames.map((name: string) => ( set(value, name)} enumName={state[name].enumName} /> ))}
); }; const Knobs: React.FC = ({ state, set, error }) => { const [css, theme] = useStyletron(); const [showAllKnobs, setShowAllKnobs] = React.useState(false); const allKnobNames = Object.keys(state).filter( (name) => state[name].type !== PropTypes.Custom, ); const filteredKnobNames = allKnobNames.filter( (name: string) => state[name].hidden !== true, ); const knobNames = showAllKnobs ? allKnobNames : filteredKnobNames; const firstGroup = knobNames.slice(0, Math.round(knobNames.length / 2)); const secondGroup = knobNames.slice(Math.round(knobNames.length / 2)); return (
{filteredKnobNames.length !== allKnobNames.length && ( )}
); }; export default Knobs;