import { colors } from '@0x/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import { zIndex } from 'ts/style/z_index'; import { Container } from './container'; import { Overlay } from './overlay'; import { Text } from './text'; export interface SelectItemConfig { text: string; onClick?: () => void; } export interface SelectProps { value: string; label?: string; items: SelectItemConfig[]; onOpen?: () => void; border?: string; fontSize?: string; iconSize?: number; textColor?: string; labelColor?: string; backgroundColor?: string; } export interface SelectState { isOpen: boolean; } export class Select extends React.Component { public static defaultProps = { items: [] as SelectItemConfig[], textColor: colors.black, backgroundColor: colors.white, fontSize: '16px', iconSize: 25, }; public state: SelectState = { isOpen: false, }; public render(): React.ReactNode { const { value, label, items, border, textColor, labelColor, backgroundColor, fontSize, iconSize } = this.props; const { isOpen } = this.state; const hasItems = !_.isEmpty(items); const borderRadius = isOpen ? '4px 4px 0px 0px' : '4px'; return ( {isOpen && ( )} {value} {label && ( {label} )} {hasItems && ( )} {isOpen && ( {_.map(items, (item, index) => ( ))} )} ); } private readonly _handleDropdownClick = (): void => { if (_.isEmpty(this.props.items)) { return; } const isOpen = !this.state.isOpen; this.setState({ isOpen, }); if (isOpen && this.props.onOpen) { this.props.onOpen(); } }; private readonly _closeDropdown = (): void => { this.setState({ isOpen: false, }); }; } export interface SelectItemProps extends SelectItemConfig { text: string; onClick?: () => void; isLast: boolean; backgroundColor?: string; border?: string; textColor?: string; fontSize?: string; } export const SelectItem: React.StatelessComponent = ({ text, onClick, isLast, border, backgroundColor, textColor, fontSize, }) => ( {text} );