aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-08 12:30:45 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-08 12:30:45 +0800
commitc0d8ceca82a91a3a6c222e71ecb58f2cd95da62e (patch)
treeb23979fe0389a2644ea9ada3a6b195c38a4e6147 /packages
parent95b2898b9c0898c7e2d98ee603bff0604bf2a829 (diff)
downloaddexon-sol-tools-c0d8ceca82a91a3a6c222e71ecb58f2cd95da62e.tar.gz
dexon-sol-tools-c0d8ceca82a91a3a6c222e71ecb58f2cd95da62e.tar.zst
dexon-sol-tools-c0d8ceca82a91a3a6c222e71ecb58f2cd95da62e.zip
feat: implement basic dropdown component
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/components/erc20_asset_amount_input.tsx2
-rw-r--r--packages/instant/src/components/payment_method.tsx31
-rw-r--r--packages/instant/src/components/ui/dropdown.tsx127
-rw-r--r--packages/instant/src/components/ui/icon.tsx9
-rw-r--r--packages/instant/src/components/zero_ex_instant_container.tsx5
-rw-r--r--packages/instant/src/style/z_index.ts3
6 files changed, 169 insertions, 8 deletions
diff --git a/packages/instant/src/components/erc20_asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx
index f21c21b87..520ac33d5 100644
--- a/packages/instant/src/components/erc20_asset_amount_input.tsx
+++ b/packages/instant/src/components/erc20_asset_amount_input.tsx
@@ -113,7 +113,7 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput
}
return (
<Container marginLeft="5px">
- <Icon icon="chevron" width={12} onClick={this._handleSelectAssetClick} />
+ <Icon icon="chevron" width={12} stroke={ColorOption.white} onClick={this._handleSelectAssetClick} />
</Container>
);
};
diff --git a/packages/instant/src/components/payment_method.tsx b/packages/instant/src/components/payment_method.tsx
new file mode 100644
index 000000000..125b54bad
--- /dev/null
+++ b/packages/instant/src/components/payment_method.tsx
@@ -0,0 +1,31 @@
+import * as _ from 'lodash';
+import * as React from 'react';
+
+import { ColorOption } from '../style/theme';
+
+import { Container } from './ui/container';
+import { Dropdown } from './ui/dropdown';
+import { Text } from './ui/text';
+
+export interface PaymentMethodProps {}
+
+export class PaymentMethod extends React.Component<PaymentMethodProps> {
+ public render(): React.ReactNode {
+ return (
+ <Container padding="20px" width="100%">
+ <Container marginBottom="10px">
+ <Text
+ letterSpacing="1px"
+ fontColor={ColorOption.primaryColor}
+ fontWeight={600}
+ textTransform="uppercase"
+ fontSize="14px"
+ >
+ Payment Method
+ </Text>
+ </Container>
+ <Dropdown value="0x00000000000000" label="25.33 ETH" />
+ </Container>
+ );
+ }
+}
diff --git a/packages/instant/src/components/ui/dropdown.tsx b/packages/instant/src/components/ui/dropdown.tsx
new file mode 100644
index 000000000..2bc552ab4
--- /dev/null
+++ b/packages/instant/src/components/ui/dropdown.tsx
@@ -0,0 +1,127 @@
+import * as _ from 'lodash';
+import * as React from 'react';
+
+import { ColorOption } from '../../style/theme';
+import { zIndex } from '../../style/z_index';
+
+import { Container } from './container';
+import { Flex } from './flex';
+import { Icon } from './icon';
+import { Text } from './text';
+
+export interface DropdownItemConfig {
+ text: string;
+ onClick?: () => void;
+}
+
+export interface DropdownProps {
+ value: string;
+ label: string;
+ items: DropdownItemConfig[];
+}
+
+export interface DropdownState {
+ isOpen: boolean;
+}
+
+export class Dropdown extends React.Component<DropdownProps, DropdownState> {
+ public static defaultProps = {
+ items: [
+ {
+ text: 'Item 1',
+ },
+ {
+ text: 'Item 2',
+ },
+ ],
+ };
+ public state: DropdownState = {
+ isOpen: false,
+ };
+ public render(): React.ReactNode {
+ const { value, label, items } = this.props;
+ const { isOpen } = this.state;
+ const hasItems = !_.isEmpty(items);
+ const borderRadius = isOpen ? '4px 4px 0px 0px' : '4px';
+ return (
+ <Container position="relative">
+ <Container
+ cursor={hasItems ? 'pointer' : undefined}
+ onClick={this._handleDropdownClick}
+ hasBoxShadow={true}
+ borderRadius={borderRadius}
+ border="1px solid"
+ borderColor={ColorOption.feintGrey}
+ padding="0.8em"
+ borderBottom="1px solid"
+ >
+ <Flex justify="space-between">
+ <Text fontSize="16px" lineHeight="19px" fontColor={ColorOption.darkGrey}>
+ {value}
+ </Text>
+ <Container>
+ <Text fontSize="16px" lineHeight="17px" fontColor={ColorOption.lightGrey}>
+ {label}
+ </Text>
+ {hasItems && (
+ <Container marginLeft="5px" display="inline-block" position="relative" bottom="2px">
+ <Icon padding="3px" icon="chevron" width={12} stroke={ColorOption.grey} />
+ </Container>
+ )}
+ </Container>
+ </Flex>
+ </Container>
+ {isOpen && (
+ <Container
+ width="100%"
+ position="absolute"
+ onClick={this._closeDropdown}
+ backgroundColor={ColorOption.white}
+ hasBoxShadow={true}
+ zIndex={zIndex.dropdownItems}
+ >
+ {_.map(items, (item, index) => (
+ <DropdownItem key={item.text} {...item} isLast={index === items.length - 1} />
+ ))}
+ </Container>
+ )}
+ </Container>
+ );
+ }
+ private readonly _handleDropdownClick = (): void => {
+ if (_.isEmpty(this.props.items)) {
+ return;
+ }
+ this.setState({
+ isOpen: !this.state.isOpen,
+ });
+ };
+ private readonly _closeDropdown = (): void => {
+ this.setState({
+ isOpen: false,
+ });
+ };
+}
+
+export interface DropdownItemProps extends DropdownItemConfig {
+ text: string;
+ onClick?: () => void;
+ isLast: boolean;
+}
+
+export const DropdownItem: React.StatelessComponent<DropdownItemProps> = ({ text, onClick, isLast }) => (
+ <Container
+ onClick={onClick}
+ cursor="pointer"
+ darkenOnHover={true}
+ backgroundColor={ColorOption.white}
+ padding="0.8em"
+ borderTop="0"
+ border="1px solid"
+ borderRadius={isLast ? '0px 0px 4px 4px' : undefined}
+ width="100%"
+ borderColor={ColorOption.feintGrey}
+ >
+ <Text>{text}</Text>
+ </Container>
+);
diff --git a/packages/instant/src/components/ui/icon.tsx b/packages/instant/src/components/ui/icon.tsx
index 94ea26900..707aee24f 100644
--- a/packages/instant/src/components/ui/icon.tsx
+++ b/packages/instant/src/components/ui/icon.tsx
@@ -9,7 +9,6 @@ interface IconInfo {
path: string;
fillRule?: svgRule;
clipRule?: svgRule;
- stroke?: string;
strokeOpacity?: number;
strokeWidth?: number;
strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
@@ -47,7 +46,6 @@ const ICONS: IconInfoMapping = {
chevron: {
viewBox: '0 0 12 7',
path: 'M11 1L6 6L1 1',
- stroke: 'white',
strokeOpacity: 0.5,
strokeWidth: 1.5,
strokeLinecap: 'round',
@@ -67,6 +65,7 @@ export interface IconProps {
width: number;
height?: number;
color?: ColorOption;
+ stroke?: ColorOption;
icon: keyof IconInfoMapping;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
padding?: string;
@@ -75,6 +74,7 @@ export interface IconProps {
const PlainIcon: React.StatelessComponent<IconProps> = props => {
const iconInfo = ICONS[props.icon];
const colorValue = _.isUndefined(props.color) ? undefined : props.theme[props.color];
+ const strokeValue = _.isUndefined(props.stroke) ? undefined : props.theme[props.stroke];
return (
<div onClick={props.onClick} className={props.className}>
<svg
@@ -89,7 +89,7 @@ const PlainIcon: React.StatelessComponent<IconProps> = props => {
fill={colorValue}
fillRule={iconInfo.fillRule || 'nonzero'}
clipRule={iconInfo.clipRule || 'nonzero'}
- stroke={iconInfo.stroke}
+ stroke={strokeValue}
strokeOpacity={iconInfo.strokeOpacity}
strokeWidth={iconInfo.strokeWidth}
strokeLinecap={iconInfo.strokeLinecap}
@@ -101,7 +101,8 @@ const PlainIcon: React.StatelessComponent<IconProps> = props => {
};
export const Icon = withTheme(styled(PlainIcon)`
- cursor: ${props => (!_.isUndefined(props.onClick) ? 'pointer' : 'default')};
+ display: inline-block;
+ ${props => (!_.isUndefined(props.onClick) ? 'cursor: pointer' : '')};
transition: opacity 0.5s ease;
padding: ${props => props.padding};
opacity: ${props => (!_.isUndefined(props.onClick) ? 0.7 : 1)};
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx
index 851dfa2db..0543a8e4e 100644
--- a/packages/instant/src/components/zero_ex_instant_container.tsx
+++ b/packages/instant/src/components/zero_ex_instant_container.tsx
@@ -3,15 +3,15 @@ import * as React from 'react';
import { AvailableERC20TokenSelector } from '../containers/available_erc20_token_selector';
import { LatestBuyQuoteOrderDetails } from '../containers/latest_buy_quote_order_details';
import { LatestError } from '../containers/latest_error';
+import { SelectedAssetBuyOrderProgress } from '../containers/selected_asset_buy_order_progress';
import { SelectedAssetBuyOrderStateButtons } from '../containers/selected_asset_buy_order_state_buttons';
import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading';
-import { SelectedAssetBuyOrderProgress } from '../containers/selected_asset_buy_order_progress';
-
import { ColorOption } from '../style/theme';
import { zIndex } from '../style/z_index';
import { SlideAnimationState } from './animations/slide_animation';
+import { PaymentMethod } from './payment_method';
import { SlidingPanel } from './sliding_panel';
import { Container } from './ui/container';
import { Flex } from './ui/flex';
@@ -41,6 +41,7 @@ export class ZeroExInstantContainer extends React.Component<ZeroExInstantContain
>
<Flex direction="column" justify="flex-start">
<SelectedAssetInstantHeading onSelectAssetClick={this._handleSymbolClick} />
+ <PaymentMethod />
<SelectedAssetBuyOrderProgress />
<LatestBuyQuoteOrderDetails />
<Container padding="20px" width="100%">
diff --git a/packages/instant/src/style/z_index.ts b/packages/instant/src/style/z_index.ts
index 727a5189d..95e6cd912 100644
--- a/packages/instant/src/style/z_index.ts
+++ b/packages/instant/src/style/z_index.ts
@@ -1,5 +1,6 @@
export const zIndex = {
errorPopup: 1,
mainContainer: 2,
- panel: 3,
+ dropdownItems: 3,
+ panel: 4,
};
h?id=5f38b1e898698b939d76419cd1fa970effb38ecd'>Don't need to pass a path to camel_gpg_context_new () anymore.Jeffrey Stedfast2002-10-171-16/+0 * Pass mail_config_get_thread_subject() as the third argument toJeffrey Stedfast2002-08-281-0/+3 * removed tip frameRadek Doulik2002-08-281-3/+0 * Add a "don't sign meeting requests" option to the security pane, sinceDan Winship2002-08-151-0/+1 * Set the week start day from the calendar prefs, do same for 24 hourNot Zed2002-08-071-0/+3 * Propagate name changes or removes to the mail config. #15951. Doesn'tNot Zed2002-07-241-0/+5 * Removed special-case code for NNTP support.Jeffrey Stedfast2002-07-051-4/+1 * slight build fixesJeffrey Stedfast2002-06-271-5/+5 * Don't allow the pgp type to be anything except NONE or GPG.Jeffrey Stedfast2002-06-271-3/+11 * Some compiler warning fixes.Jeffrey Stedfast2002-06-261-0/+1 * script signaturesRadek Doulik2002-06-081-2/+2 * enhanced signature editorRadek Doulik2002-06-061-0/+2 * signature editor reworked, WIPRadek Doulik2002-06-051-9/+2 * Check for a label tag when doing a lookup on the COLOR column.Jeffrey Stedfast2002-05-171-0/+2 * Set the text of the reply-to. (mail_account_gui_save): Get the reply-toJeffrey Stedfast2002-04-121-1/+2 * Handle the X-Mailer display style. (There is currently no GUI forDan Winship2002-04-111-0/+10 * Make the drafts and sent folder buttons be EvolutionFolderSelectorButtons.Dan Winship2002-04-051-2/+1 * Sync with yet-another-mail-config branch.Jeffrey Stedfast2002-03-271-0/+9 * New callback to set a colour on a message.Jeffrey Stedfast2002-03-161-4/+16 * new functionRadek Doulik2002-03-091-0/+1 * notify accounts dialog about signature content changeRadek Doulik2002-03-081-0/+2 * merge new signature handlingRadek Doulik2002-03-071-3/+45 * Prompt the user to find out if he/she wants to go to the next folder withJeffrey Stedfast2002-02-201-0/+5 * Bumped the required version of gal.Christopher James Lahey2002-02-071-0/+1 * Save the pathname. (save_part): Use the new mail_config cruft to get theJeffrey Stedfast2002-01-261-0/+3 * Renamed. (mail_config_get_new_mail_notify_sound_file): Renamed.Jeffrey Stedfast2002-01-081-3/+3 * Add the auto-cc/bcc recipients here. The problem with setting them in theJeffrey Stedfast2001-12-201-17/+22 * Setup the new-mail-notification widgets. (notify_command_changed): UpdateJeffrey Stedfast2001-12-191-8/+8 * set the new-mail-notify command.Jeffrey Stedfast2001-12-131-0/+11 * Call mail_config_pgp_type_detect_from_path() instead of doing our own lameJeffrey Stedfast2001-11-091-0/+2 * Don't make the account editor modal either.Jeffrey Stedfast2001-11-061-2/+2 * More fixing of the license texts.Ettore Perazzoli2001-10-281-11/+11 * Ignore the signal if the radio button is not "on". This fixes bug #10532Jeffrey Stedfast2001-10-051-3/+6 * Check for errorsIain Holmes2001-10-021-1/+1 * Update to not send the remember-passphrase option to the context, itJeffrey Stedfast2001-09-261-3/+0 * Throw up a warning dialog if we suspect the config database is corrupt.Jeffrey Stedfast2001-09-261-0/+1 * Only add the account if it doesn't already exist in the config db.Jeffrey Stedfast2001-09-211-0/+1 * Added. Shows a (hopefully) informative dialog warning you that someJon Trowbridge2001-09-091-0/+3 * Respect the user's desire to be prompted to confirm that he wants toJeffrey Stedfast2001-08-171-0/+3 * Save the pgp and smime always-sign options.Jeffrey Stedfast2001-08-101-0/+2 * This should return a GtkWidget not a GtkObject.Jeffrey Stedfast2001-08-081-0/+5 * Figure out whether we're getting the password for the source or thePeter Williams2001-07-271-0/+1 * Now take a CamelService parameter (as passed by Camel). Allows us to havePeter Williams2001-07-261-0/+2 * [Simplifying how default account is stored and used internally, fixesJason Leach2001-07-191-1/+2 * [Bug #4305: Make the automatic mark-as-read timer optional]Jason Leach2001-07-111-0/+3 * Update to pass in the `remember' argument when creating a new pgp context.Jeffrey Stedfast2001-07-101-0/+3 * Setup the Empty Trash On Exit widgets.Jeffrey Stedfast2001-07-031-2/+5 * Throw up the confirmation dialog. (composer_get_message): If the user onlyJeffrey Stedfast2001-06-301-0/+3 * simplified(refactored) signature handling + better support for htmlRadek Doulik2001-06-291-0/+2 * sync folders after we've gotten mailjacob berkman2001-06-261-0/+3 * Update the copyrights, replacing Helix Code with Ximian andEttore Perazzoli2001-06-231-2/+2 * Updated to reflect changes to mail_config_[g,s]et_thread_list().Jeffrey Stedfast2001-06-151-2/+2 * Save the pgp and smime settings. (mail_account_gui_new): Setup the pgp andJeffrey Stedfast2001-06-021-0/+6 * Rename the "PGP" page back to "Other" and add a "default charset" optionDan Winship2001-05-311-0/+3 * Prototype evolution_mail_config_get_type.Jeffrey Stedfast2001-05-281-0/+1 * Save the message-display style. (config_read): Read the message-displayJeffrey Stedfast2001-05-231-2/+2 * Load http images if the user has force-loaded images too.Dan Winship2001-05-161-5/+11 * Split "Other" page into three pages, Display, Composer, and PGP. Add HTMLDan Winship2001-05-151-0/+8 * callback to use GNOME-VFS to load http data. (on_url_requested): HandleDan Winship2001-05-121-0/+8 * Fix some compiler warnings by including the correct bonobo headers and byJeffrey Stedfast2001-05-111-0/+4 * Moved all references for the Mail.h and Bonobo stuff into the .c fileIain Holmes2001-05-091-18/+0 * Importer changesIain Holmes2001-05-091-0/+18 * Use a CamelPgpType. (mail_config_get_pgp_type): Return a CamelPgpType.Jeffrey Stedfast2001-04-211-2/+2 * Mark the messages as seen, not unseen. (is_drafts_folder): New function toJeffrey Stedfast2001-04-161-1/+1 * Merge from evolution-0-10 to evolution-0-10-merge-0 into head.Not Zed2001-04-051-0/+3 * Added #include <libgnome/gnome-paper.h>Jon Trowbridge2001-03-301-6/+7 * Set up the sent/drafts folder buttons. (folder_picker_clicked): Pop up theDan Winship2001-03-291-0/+3 * Probably the very last new config dialog ever. (Ha ha). From Anna, basedDan Winship2001-03-271-4/+2 * set color in html citationRadek Doulik2001-03-211-0/+6 * We don't care about SSL, yea baby... (apply_changes): Don't care aboutJeffrey Stedfast2001-03-161-1/+0 * Fixed memory corruption bug.Jeffrey Stedfast2001-02-231-0/+2 * Cast the CamelMedium to a CamelMimePart before performing actions on it asJeffrey Stedfast2001-02-091-0/+2 * Updated to not connect when getting a list of authtypes. (transport_next):Jeffrey Stedfast2001-02-061-1/+1 * New config function to set the path to the pgp binary.Jeffrey Stedfast2001-01-18