diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-02 02:04:56 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-02 02:04:56 +0800 |
commit | 3a7f26f6200bd3796a5207f62c0bdd18858db0e1 (patch) | |
tree | cbe7fc033e26e809659d7bb6ec30dbc1c75c0db7 /packages/website/ts/components | |
parent | 484fd68495bf921c57a09b413d978b028f0c80e8 (diff) | |
download | dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar.gz dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar.bz2 dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar.lz dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar.xz dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.tar.zst dexon-0x-contracts-3a7f26f6200bd3796a5207f62c0bdd18858db0e1.zip |
Have basic newsletter subscribe form working
Diffstat (limited to 'packages/website/ts/components')
-rw-r--r-- | packages/website/ts/components/forms/subscribe_form.tsx | 68 | ||||
-rw-r--r-- | packages/website/ts/components/token_balances.tsx | 2 |
2 files changed, 69 insertions, 1 deletions
diff --git a/packages/website/ts/components/forms/subscribe_form.tsx b/packages/website/ts/components/forms/subscribe_form.tsx new file mode 100644 index 000000000..8bb0f4fc7 --- /dev/null +++ b/packages/website/ts/components/forms/subscribe_form.tsx @@ -0,0 +1,68 @@ +import { colors } from '@0xproject/react-shared'; +import * as React from 'react'; + +import RaisedButton from 'material-ui/RaisedButton'; +import { backendClient } from 'ts/utils/backend_client'; + +export interface SubscribeFormProps {} + +export enum SubscribeFormStatus { + None, + Error, + Success, + Loading, +} + +export interface SubscribeFormState { + emailText: string; + status: SubscribeFormStatus; +} + +export class SubscribeForm extends React.Component<SubscribeFormProps, SubscribeFormState> { + public state = { + emailText: '', + status: SubscribeFormStatus.None, + }; + public render(): React.ReactNode { + return ( + <div> + Subscribe to our newsletter for 0x relayer and dApp updates + <div> + <input value={this.state.emailText} onChange={this._handleEmailInputChange.bind(this)} /> + <RaisedButton + labelStyle={{ + textTransform: 'none', + fontSize: 15, + fontWeight: 400, + }} + buttonStyle={{ + borderRadius: 6, + }} + style={{ + boxShadow: '0px 0px 4px rgba(0, 0, 0, 0.25)', + borderRadius: 6, + height: 48, + width: 120, + }} + labelColor="white" + backgroundColor="#252525" + onClick={this._handleSubscribeClickAsync.bind(this)} + label="Subscribe" + /> + </div> + </div> + ); + } + private _handleEmailInputChange(event: React.ChangeEvent<HTMLInputElement>): void { + this.setState({ emailText: event.target.value }); + } + private async _handleSubscribeClickAsync(): Promise<void> { + this._setStatus(SubscribeFormStatus.Loading); + const success = await backendClient.subscribeToNewsletterAsync(this.state.emailText); + const status = success ? SubscribeFormStatus.Success : SubscribeFormStatus.Error; + this._setStatus(status); + } + private _setStatus(status: SubscribeFormStatus): void { + this.setState({ status }); + } +} diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index f5a51dabb..022968941 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -77,11 +77,11 @@ interface TokenBalancesProps { interface TokenBalancesState { errorType: BalanceErrs; + trackedTokenStateByAddress: TokenStateByAddress; isBalanceSpinnerVisible: boolean; isZRXSpinnerVisible: boolean; isTokenPickerOpen: boolean; isAddingToken: boolean; - trackedTokenStateByAddress: TokenStateByAddress; } export class TokenBalances extends React.Component<TokenBalancesProps, TokenBalancesState> { |