From 9fda63cf74ea77e01634d2a91e773d4fa3ed68b7 Mon Sep 17 00:00:00 2001 From: Fred Carlsen Date: Thu, 13 Dec 2018 13:35:48 +0100 Subject: Mobile tweaks to contactm modal --- .../website/ts/@next/components/modals/input.tsx | 13 +++-- .../ts/@next/components/modals/modal_contact.tsx | 62 +++++++++++++++++----- 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/packages/website/ts/@next/components/modals/input.tsx b/packages/website/ts/@next/components/modals/input.tsx index eee2d4102..351df105b 100644 --- a/packages/website/ts/@next/components/modals/input.tsx +++ b/packages/website/ts/@next/components/modals/input.tsx @@ -22,11 +22,12 @@ interface LabelProps { export const Input = React.forwardRef((props: InputProps, ref) => { const { name, label, type } = props; const id = `input-${name}`; + const componentType = type === 'textarea' ? 'textarea' : 'input'; return ( - + ); }); @@ -41,12 +42,13 @@ const StyledInput = styled.input` border: 1px solid #D5D5D5; color: #000; font-size: 1.294117647rem; - padding: 16px 15px; + padding: 16px 15px 14px; outline: none; width: 100%; + min-height: ${props => props.type === 'textarea' && `120px`}; &::placeholder { - color: #9D9D9D; + color: #C3C3C3; } `; @@ -54,6 +56,11 @@ const InputWrapper = styled.div` position: relative; flex-grow: ${props => props.width === InputWidth.Full && 1}; width: ${props => props.width === InputWidth.Half && `calc(50% - 15px)`}; + + @media (max-width: 768px) { + width: 100%; + margin-bottom: 30px; + } `; const Label = styled.label` diff --git a/packages/website/ts/@next/components/modals/modal_contact.tsx b/packages/website/ts/@next/components/modals/modal_contact.tsx index a63ab50c0..962a9ab19 100644 --- a/packages/website/ts/@next/components/modals/modal_contact.tsx +++ b/packages/website/ts/@next/components/modals/modal_contact.tsx @@ -34,6 +34,7 @@ export class ModalContact extends React.Component { public state = { isSubmitting: false, isSuccessful: false, + errors: {}, }; public constructor(props: Props) { super(props); @@ -45,7 +46,7 @@ export class ModalContact extends React.Component { return ( <> @@ -85,10 +86,10 @@ export class ModalContact extends React.Component { - + - + @@ -116,33 +117,41 @@ export class ModalContact extends React.Component { e.preventDefault(); // const email = this.emailInput.current.value; - const email = 'fred@sjelfull.no'; + const email = ''; + const name = ''; + const projectOrCompany = ''; + const link = ''; + const comments = ''; this.setState({ ...this.state, isSubmitting: true }); try { - const response = await fetch('/email', { + const response = await fetch('https://website-api.0xproject.com/leads', { method: 'post', + mode: 'cors', + credentials: 'same-origin', headers: { 'content-type': 'application/json; charset=utf-8', }, - body: JSON.stringify({ email }), + body: JSON.stringify({ email, projectOrCompany, link, comments }), }); const json = await response.json(); - console.log(response.json()); + this.setState({ ...this.state, isSuccessful: true }); + + console.log(response); } catch (e) { + this.setState({ ...this.state, errors: [] }); console.log(e); } - - this.setState({ ...this.state, isSuccessful: true }); } private async _onDone(e): void { e.preventDefault(); this.props.onDismiss(); } -}; +} +// Handle errors: {"errors":[{"location":"body","param":"name","msg":"Invalid value"},{"location":"body","param":"email","msg":"Invalid value"}]} const StyledWrap = styled(Wrap)` padding-top: 20px; @@ -162,11 +171,30 @@ const StyledWrap = styled(Wrap)` `; const InputRow = styled.div` - display: flex; - justify-content: space-between; - margin-bottom: 30px; width: 100%; flex: 0 0 auto; + + @media (min-width: 768px) { + display: flex; + justify-content: space-between; + margin-bottom: 30px; + } +`; + +const ButtonRow = styled(InputRow)` + @media (max-width: 768px) { + display: flex; + flex-direction: column; + + button:nth-child(1) { + order: 2; + } + + button:nth-child(2) { + order: 1; + margin-bottom: 10px; + } + } `; const StyledDialogContent = styled(DialogContent)` @@ -174,6 +202,12 @@ const StyledDialogContent = styled(DialogContent)` max-width: 800px; background-color: #F6F6F6 !important; padding: 60px 60px !important; + + @media (max-width: 768px) { + width: calc(100vw - 40px) !important; + margin: 40px auto !important; + padding: 30px 30px !important; + } `; const Form = styled.form` -- cgit v1.2.3