UNPKG

vitessce

Version:

Vitessce app and React component library

74 lines (68 loc) 2.44 kB
import React, { useCallback } from 'react'; import debounce from 'lodash/debounce'; import Slider from '@material-ui/core/Slider'; import TableCell from '@material-ui/core/TableCell'; import TableRow from '@material-ui/core/TableRow'; import { useStyles } from '../shared-plot-options/styles'; import OptionsContainer from '../shared-plot-options/OptionsContainer'; import OptionSelect from '../shared-plot-options/OptionSelect'; import { GLSL_COLORMAPS } from '../../layers/constants'; export default function HeatmapOptions(props) { const { geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, } = props; const classes = useStyles(); function handleGeneExpressionColormapChange(event) { setGeneExpressionColormap(event.target.value); } function handleColormapRangeChange(event, value) { setGeneExpressionColormapRange(value); } const handleColormapRangeChangeDebounced = useCallback( debounce(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange], ); return ( <OptionsContainer> <TableRow> <TableCell className={classes.labelCell} htmlFor="gene-expression-colormap-select"> Gene Expression Colormap </TableCell> <TableCell className={classes.inputCell}> <OptionSelect className={classes.select} value={geneExpressionColormap} onChange={handleGeneExpressionColormapChange} inputProps={{ id: 'gene-expression-colormap-select', }} > {GLSL_COLORMAPS.map(cmap => ( <option key={cmap} value={cmap}>{cmap}</option> ))} </OptionSelect> </TableCell> </TableRow> <TableRow> <TableCell className={classes.labelCell}> Gene Expression Colormap Range </TableCell> <TableCell className={classes.inputCell}> <Slider classes={{ root: classes.slider, valueLabel: classes.sliderValueLabel }} value={geneExpressionColormapRange} onChange={handleColormapRangeChangeDebounced} aria-labelledby="gene-expression-colormap-range-slider" valueLabelDisplay="auto" step={0.005} min={0.0} max={1.0} /> </TableCell> </TableRow> </OptionsContainer> ); }