Browse Source

style(home): new layout for wallet settings form

next
Tom Kirkpatrick 6 years ago
parent
commit
a0294031b2
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 4
      app/components/Home/Home.js
  2. 28
      app/components/Home/WalletLauncher.js
  3. 103
      app/components/Home/WalletSettingsFormLocal.js
  4. 8
      app/components/UI/DataRow.js
  5. 8
      stories/containers/home.stories.js
  6. 2
      test/unit/components/Pay/__snapshots__/PaySummaryRow.spec.js.snap
  7. 1
      test/unit/components/UI/__snapshots__/Button.spec.js.snap
  8. 4
      test/unit/components/UI/__snapshots__/Sidebar.spec.js.snap

4
app/components/Home/Home.js

@ -71,8 +71,8 @@ class Home extends React.Component {
</Box> </Box>
</Sidebar.small> </Sidebar.small>
<MainContent width={1 / 2}> <MainContent>
<Box px={3} mt={72}> <Box px={5} mt={72}>
<Switch> <Switch>
<Route <Route
exact exact

28
app/components/Home/WalletLauncher.js

@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { Box, Flex } from 'rebass' import { Box, Flex } from 'rebass'
import { Bar, Button, Heading } from 'components/UI' import { Bar, Button, Heading, Text } from 'components/UI'
import { WalletSettingsFormLocal, WalletSettingsFormRemote, WalletHeader } from '.' import { WalletSettingsFormLocal, WalletSettingsFormRemote, WalletHeader } from '.'
class WalletLauncher extends React.Component { class WalletLauncher extends React.Component {
@ -62,7 +62,7 @@ class WalletLauncher extends React.Component {
return ( return (
<React.Fragment> <React.Fragment>
<Flex mb={4} alignItems="center"> <Flex mb={5} alignItems="center">
<Box width="75%" mr={3}> <Box width="75%" mr={3}>
<WalletHeader title={walletName} /> <WalletHeader title={walletName} />
</Box> </Box>
@ -75,8 +75,8 @@ class WalletLauncher extends React.Component {
{wallet.type === 'local' && ( {wallet.type === 'local' && (
<> <>
<Heading.h2 mb={4}>Settings</Heading.h2> <Heading.h1 mb={5}>Settings</Heading.h1>
<Bar my={2} />
<WalletSettingsFormLocal <WalletSettingsFormLocal
key={wallet.id} key={wallet.id}
id={`wallet-settings-form-${wallet.id}`} id={`wallet-settings-form-${wallet.id}`}
@ -96,15 +96,17 @@ class WalletLauncher extends React.Component {
/> />
</> </>
)} )}
<Button
variant="secondary" <Text mt={4} fontWeight="normal">
type="button" Delete
size="small" </Text>
onClick={this.handleDelete} <Bar my={2} />
ml="auto"
> <Flex justifyContent="center" my={4}>
delete <Button size="small" onClick={this.handleDelete}>
</Button> Delete wallet
</Button>
</Flex>
</React.Fragment> </React.Fragment>
) )
} }

103
app/components/Home/WalletSettingsFormLocal.js

@ -1,7 +1,7 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Flex } from 'rebass' import { Flex } from 'rebass'
import { DataRow, Form, Input, Label, Range, Toggle } from 'components/UI' import { Bar, DataRow, Form, Input, Label, Range, Text, Toggle } from 'components/UI'
import * as yup from 'yup' import * as yup from 'yup'
class WalletSettingsFormLocal extends React.Component { class WalletSettingsFormLocal extends React.Component {
@ -18,51 +18,6 @@ class WalletSettingsFormLocal extends React.Component {
} }
} }
validateAutopilotAllocation = value => {
try {
yup
.number()
.required()
.positive()
.min(0)
.max(100)
.typeError('A number is required')
.validateSync(value)
} catch (error) {
return error.message
}
}
validateAutopilotMaxchannels = value => {
try {
yup
.number()
.required()
.positive()
.integer()
.max(100)
.typeError('A number is required')
.validateSync(value)
} catch (error) {
return error.message
}
}
validateAutopilotChansize = value => {
try {
yup
.number()
.required()
.positive()
.integer()
.max(100000000)
.typeError('A number is required')
.validateSync(value)
} catch (error) {
return error.message
}
}
preSubmit = values => { preSubmit = values => {
if (values.autopilotAllocation) { if (values.autopilotAllocation) {
values.autopilotAllocation = values.autopilotAllocation / 100 values.autopilotAllocation = values.autopilotAllocation / 100
@ -93,14 +48,53 @@ class WalletSettingsFormLocal extends React.Component {
> >
{({ formState }) => ( {({ formState }) => (
<React.Fragment> <React.Fragment>
<Text fontWeight="normal">Naming</Text>
<Bar mt={2} mb={4} />
<DataRow <DataRow
py={2} py={2}
left={<Label htmlFor="alias">Alias</Label>} left={
<>
<Label htmlFor="name" mb={2}>
Wallet name
</Label>
<Text color="gray" fontWeight="light">
The wallet name is only visible for you inside Zap.
</Text>
</>
}
right={
<Input
field="name"
id="name"
initialValue={wallet.name}
placeholder="Enter name"
width={1}
ml="auto"
justifyContent="right"
css={{ 'text-align': 'right' }}
/>
}
/>
<DataRow
py={2}
left={
<>
<Label htmlFor="alias" mb={2}>
Alias
</Label>
<Text color="gray" fontWeight="light">
The alias will be visible for others on the network.
</Text>
</>
}
right={ right={
<Input <Input
field="alias" field="alias"
id="alias" id="alias"
initialValue={wallet.alias} initialValue={wallet.alias}
placeholder="Enter alias"
width={1} width={1}
ml="auto" ml="auto"
justifyContent="right" justifyContent="right"
@ -111,10 +105,13 @@ class WalletSettingsFormLocal extends React.Component {
<DataRow <DataRow
py={2} py={2}
mt={4}
left={<Label htmlFor="autopilot">Autopilot</Label>} left={<Label htmlFor="autopilot">Autopilot</Label>}
right={<Toggle field="autopilot" id="autopilot" initialValue={wallet.autopilot} />} right={<Toggle field="autopilot" id="autopilot" initialValue={wallet.autopilot} />}
/> />
<Bar mt={2} mb={4} />
{formState.values.autopilot ? ( {formState.values.autopilot ? (
<React.Fragment> <React.Fragment>
<DataRow <DataRow
@ -136,11 +133,10 @@ class WalletSettingsFormLocal extends React.Component {
field="autopilotAllocation" field="autopilotAllocation"
id="autopilotAllocation" id="autopilotAllocation"
type="number" type="number"
variant="thin"
min="0" min="0"
max="100" max="100"
step="1" step="1"
width={50} width={70}
ml={2} ml={2}
justifyContent="right" justifyContent="right"
css={{ 'text-align': 'right' }} css={{ 'text-align': 'right' }}
@ -156,11 +152,10 @@ class WalletSettingsFormLocal extends React.Component {
<Input <Input
field="autopilotMaxchannels" field="autopilotMaxchannels"
id="autopilotMaxchannels" id="autopilotMaxchannels"
variant="thin"
type="number" type="number"
initialValue={wallet.autopilotMaxchannels} initialValue={wallet.autopilotMaxchannels}
step="1" step="1"
width={100} width={150}
ml="auto" ml="auto"
justifyContent="right" justifyContent="right"
css={{ 'text-align': 'right' }} css={{ 'text-align': 'right' }}
@ -175,13 +170,12 @@ class WalletSettingsFormLocal extends React.Component {
<Input <Input
field="autopilotMinchansize" field="autopilotMinchansize"
id="autopilotMinchansize" id="autopilotMinchansize"
variant="thin"
type="number" type="number"
min="0" min="0"
max="100000000" max="100000000"
step="1" step="1"
initialValue={wallet.autopilotMinchansize} initialValue={wallet.autopilotMinchansize}
width={100} width={150}
ml="auto" ml="auto"
justifyContent="right" justifyContent="right"
css={{ 'text-align': 'right' }} css={{ 'text-align': 'right' }}
@ -196,13 +190,12 @@ class WalletSettingsFormLocal extends React.Component {
<Input <Input
field="autopilotMaxchansize" field="autopilotMaxchansize"
id="autopilotMaxchansize" id="autopilotMaxchansize"
variant="thin"
type="number" type="number"
min="0" min="0"
max="100000000" max="100000000"
step="1" step="1"
initialValue={wallet.autopilotMaxchansize} initialValue={wallet.autopilotMaxchansize}
width={100} width={150}
ml="auto" ml="auto"
justifyContent="right" justifyContent="right"
css={{ 'text-align': 'right' }} css={{ 'text-align': 'right' }}

8
app/components/UI/DataRow.js

@ -5,12 +5,8 @@ import { Text } from 'components/UI'
const DataRow = ({ left, right, ...rest }) => ( const DataRow = ({ left, right, ...rest }) => (
<Flex alignItems="center" py={3} {...rest} justifyContent="space-between"> <Flex alignItems="center" py={3} {...rest} justifyContent="space-between">
<Text width={1 / 2} fontWeight="normal"> <Text fontWeight="normal">{left}</Text>
{left} <Text textAlign="right">{right}</Text>
</Text>
<Text width={1 / 2} textAlign="right">
{right}
</Text>
</Flex> </Flex>
) )

8
stories/containers/home.stories.js

@ -30,13 +30,7 @@ const store = new Store({
}, },
{ {
id: 2, id: 2,
autopilot: true, autopilot: false,
autopilotAllocation: 0.9,
autopilotMaxchannels: 10,
autopilotMaxchansize: 16777215,
autopilotMinchansize: 20000,
autopilotMinconfs: 1,
autopilotPrivate: false,
chain: 'bitcoin', chain: 'bitcoin',
network: 'mainnet', network: 'mainnet',
type: 'local' type: 'local'

2
test/unit/components/Pay/__snapshots__/PaySummaryRow.spec.js.snap

@ -8,13 +8,11 @@ exports[`component.Form.DataRow should render correctly 1`] = `
> >
<Text <Text
fontWeight="normal" fontWeight="normal"
width={0.5}
> >
left contnet left contnet
</Text> </Text>
<Text <Text
textAlign="right" textAlign="right"
width={0.5}
> >
right content right content
</Text> </Text>

1
test/unit/components/UI/__snapshots__/Button.spec.js.snap

@ -32,6 +32,7 @@ exports[`component.UI.Button should render correctly 1`] = `
border-radius: 5; border-radius: 5;
font-weight: 300; font-weight: 300;
line-height: '18px'; line-height: '18px';
white-space: nowrap;
} }
.c0:disabled { .c0:disabled {

4
test/unit/components/UI/__snapshots__/Sidebar.spec.js.snap

@ -2,7 +2,7 @@
exports[`component.UI.Sidebar should render correctly 1`] = ` exports[`component.UI.Sidebar should render correctly 1`] = `
.c0 { .c0 {
width: 33.33333333333333%; width: 25%;
color: primaryText; color: primaryText;
background-color: tertiaryColor; background-color: tertiaryColor;
position: relative; position: relative;
@ -12,6 +12,6 @@ exports[`component.UI.Sidebar should render correctly 1`] = `
<aside <aside
className="c0" className="c0"
color="primaryText" color="primaryText"
width={0.3333333333333333} width={0.25}
/> />
`; `;

Loading…
Cancel
Save