From a3620f307448f7854be04a12bce741385cc27ddd Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Thu, 14 Jun 2018 13:24:30 +0200 Subject: [PATCH] Create popover component, replace popover in columns configurator Feature #13601 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../columns-configurator.tsx | 84 +++++++------------ src/components/popover/popover.tsx | 53 ++++++++++++ 2 files changed, 83 insertions(+), 54 deletions(-) create mode 100644 src/components/popover/popover.tsx diff --git a/src/components/data-explorer/columns-configurator/columns-configurator.tsx b/src/components/data-explorer/columns-configurator/columns-configurator.tsx index 5a3fb014b0..a46d2243e5 100644 --- a/src/components/data-explorer/columns-configurator/columns-configurator.tsx +++ b/src/components/data-explorer/columns-configurator/columns-configurator.tsx @@ -3,70 +3,46 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { WithStyles, StyleRulesCallback, Theme, withStyles, IconButton, Popover, Paper, List, Checkbox, ListItemText, ListItem, Typography, ListSubheader } from '@material-ui/core'; +import { WithStyles, StyleRulesCallback, Theme, withStyles, IconButton, Paper, List, Checkbox, ListItemText, ListItem, Typography, ListSubheader } from '@material-ui/core'; import MenuIcon from "@material-ui/icons/Menu"; import { Column } from '../column'; import { PopoverOrigin } from '@material-ui/core/Popover'; +import Popover from "../../popover/popover"; +import { IconButtonProps } from '@material-ui/core/IconButton'; export interface ColumnsConfiguratorProps { columns: Array>; onColumnToggle: (column: Column) => void; } - -class ColumnsConfigurator extends React.Component> { - - state = { - anchorEl: undefined - }; - - transformOrigin: PopoverOrigin = { - vertical: "top", - horizontal: "right", - }; - - render() { - const { columns, onColumnToggle, classes } = this.props; - return ( - <> - - - - - - Configure table columns +const ColumnsConfigurator: React.SFC> = ({ columns, onColumnToggle, classes }) => { + return ( + + + + + Configure table columns - { - columns.map((column, index) => ( - onColumnToggle(column)}> - - {column.header} - - - )) - } - - - - - ); - } - - handleClose = () => { - this.setState({ anchorEl: undefined }); - } - - handleClick = (event: React.MouseEvent) => { - this.setState({ anchorEl: event.currentTarget }); - } - -} + { + columns.map((column, index) => ( + onColumnToggle(column)}> + + {column.header} + + + )) + } + + + + ); +}; + +const ColumnsConfiguratorTrigger: React.SFC = (props) => ( + + + +); type CssRules = "root" | "checkbox"; diff --git a/src/components/popover/popover.tsx b/src/components/popover/popover.tsx new file mode 100644 index 0000000000..b7e082be4c --- /dev/null +++ b/src/components/popover/popover.tsx @@ -0,0 +1,53 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { Popover as MaterialPopover } from '@material-ui/core'; + +import { PopoverOrigin } from '@material-ui/core/Popover'; + +export interface PopoverProps { + triggerComponent: React.ComponentType<{ onClick: (event: React.MouseEvent) => void }>; +} + + +class Popover extends React.Component { + + state = { + anchorEl: undefined + }; + + transformOrigin: PopoverOrigin = { + vertical: "top", + horizontal: "right", + }; + + render() { + return ( + <> + + + {this.props.children} + + + ); + } + + handleClose = () => { + this.setState({ anchorEl: undefined }); + } + + handleClick = (event: React.MouseEvent) => { + this.setState({ anchorEl: event.currentTarget }); + } + +} + +export default Popover; -- 2.30.2