aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/ui/multi_select.tsx
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-12-01 02:25:36 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-12-01 02:25:36 +0800
commite65096ee7af7c6d442b5e106db0a07652cc5e047 (patch)
treee43fba0c7aab2154e9c7d21817aa014088c71334 /packages/website/ts/components/ui/multi_select.tsx
parentf1354632a1a2915159f6d662f90b68fe8c3bab38 (diff)
downloaddexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar.gz
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar.bz2
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar.lz
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar.xz
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.tar.zst
dexon-sol-tools-e65096ee7af7c6d442b5e106db0a07652cc5e047.zip
feat: implement multi token select component
Diffstat (limited to 'packages/website/ts/components/ui/multi_select.tsx')
-rw-r--r--packages/website/ts/components/ui/multi_select.tsx38
1 files changed, 21 insertions, 17 deletions
diff --git a/packages/website/ts/components/ui/multi_select.tsx b/packages/website/ts/components/ui/multi_select.tsx
index bf80443af..2cf44cae1 100644
--- a/packages/website/ts/components/ui/multi_select.tsx
+++ b/packages/website/ts/components/ui/multi_select.tsx
@@ -2,40 +2,42 @@ 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 MultiSelectItemConfig {
value: string;
- displayText: React.ReactNode;
+ renderItemContent: (isSelected: boolean) => React.ReactNode;
onClick?: () => void;
}
export interface MultiSelectProps {
- selectedValues: string[];
+ selectedValues?: string[];
items: MultiSelectItemConfig[];
backgroundColor?: string;
- textColor?: string;
+ height?: string;
}
export class MultiSelect extends React.Component<MultiSelectProps> {
public static defaultProps = {
backgroundColor: colors.white,
- textColor: colors.darkGrey,
};
public render(): React.ReactNode {
- const { items, backgroundColor, selectedValues } = this.props;
+ const { items, backgroundColor, selectedValues, height } = this.props;
return (
- <Container backgroundColor={backgroundColor} borderRadius="4px">
+ <Container
+ backgroundColor={backgroundColor}
+ borderRadius="4px"
+ width="100%"
+ height={height}
+ overflowY="scroll"
+ >
{_.map(items, item => (
<MultiSelectItem
key={item.value}
- displayText={item.displayText}
+ renderItemContent={item.renderItemContent}
+ backgroundColor={backgroundColor}
onClick={item.onClick}
- isSelected={_.includes(selectedValues, item.value)}
+ isSelected={_.isUndefined(selectedValues) || _.includes(selectedValues, item.value)}
/>
))}
</Container>
@@ -44,19 +46,21 @@ export class MultiSelect extends React.Component<MultiSelectProps> {
}
export interface MultiSelectItemProps {
- displayText: React.ReactNode;
+ renderItemContent: (isSelected: boolean) => React.ReactNode;
isSelected?: boolean;
onClick?: () => void;
+ backgroundColor?: string;
}
export const MultiSelectItem: React.StatelessComponent<MultiSelectItemProps> = ({
- displayText,
+ renderItemContent,
isSelected,
onClick,
+ backgroundColor,
}) => (
- <Container shouldDarkenOnHover={true} onClick={onClick}>
- <Container borderBottom="1px solid black" padding="0px 15px">
- {displayText}
+ <Container cursor="pointer" shouldDarkenOnHover={true} onClick={onClick} backgroundColor={backgroundColor}>
+ <Container borderBottom={`1px solid ${colors.lightestGrey}`} margin="0px 15px" padding="10px 0px">
+ {renderItemContent(isSelected)}
</Container>
</Container>
);