import styled from "@emotion/styled"; import * as React from "react"; import { MdArrowDropDown } from "react-icons/md"; import { ClipLoader } from "react-spinners"; import { DARK_PRIMARY_TWO, DARK_SECONDARY_THREE, LIGHT_PRIMARY_THREE, LIGHT_SECONDARY_ONE, Theme, } from "../../../shared/colors"; export type SelectValue = { value: string; title: string; }; type Props = { value: string; onSelectChange: (value: string) => any; values: SelectValue[]; colorTheme?: Theme; loading?: boolean; }; type State = {}; class Select extends React.Component { currentSelect = React.createRef(); onSelectChange = (event: React.ChangeEvent) => { this.props.onSelectChange(event.target.value); }; onSelectClick = () => { if (this.currentSelect.current) { this.currentSelect.current.click(); } }; render() { if (this.props.loading) { return ( ); } return ( {this.props.values.map((value) => { return ( ); })} ); } } export default Select; const SpinnerContainer = styled.div` width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; height: 25px; `; const SelectBar = styled.select<{ colorTheme: Theme | undefined }>` display: flex; width: 100%; font-size: 14px; appearance: none; cursor: pointer; background-color: ${(props) => props.colorTheme === Theme.DARK ? DARK_PRIMARY_TWO : LIGHT_PRIMARY_THREE}; color: ${(props) => props.colorTheme === Theme.DARK ? DARK_SECONDARY_THREE : LIGHT_SECONDARY_ONE}; border-radius: 8px; border-width: 0px; padding: 4px 8px; :focus { outline: none; } `; const SelectContainer = styled.div<{ colorTheme: Theme | undefined }>` box-shadow: rgba(0, 0, 0, 0.03) 0px 0px 0px 1px, rgba(0, 0, 0, 0.05) 0px 1px 0px, rgba(0, 0, 0, 0.1) 0px 1px 3px; display: flex; border-radius: 8px; background-color: ${(props) => props.colorTheme === Theme.DARK ? DARK_PRIMARY_TWO : LIGHT_PRIMARY_THREE}; `;