Browse Source

style(storybook): reorganise and tidy up storybook

renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
0c90ef70a3
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 9
      .storybook/config.js
  2. 27
      .storybook/preview-head.html
  3. 5
      app/components/Pay/Pay.js
  4. 22
      app/components/Request/Request.js
  5. 42
      app/components/UI/Bar.js
  6. 58
      app/components/UI/Dropdown.js
  7. 4
      app/components/UI/MainContent.js
  8. 6
      app/components/UI/Menu.js
  9. 1
      app/components/UI/Page.js
  10. 11
      app/components/UI/Panel.js
  11. 4
      app/components/UI/QRCode.js
  12. 2
      app/components/UI/Sidebar.js
  13. 4
      stories/_general/_welcome.stories.js
  14. 8
      stories/_general/color.stories.js
  15. 79
      stories/_general/typography.stories.js
  16. 86
      stories/components/background.stories.js
  17. 14
      stories/components/bar.stories.js
  18. 127
      stories/components/button.stories.js
  19. 2
      stories/components/countdown.stories.js
  20. 118
      stories/components/dropdown.stories.js
  21. 21
      stories/components/header.stories.js
  22. 39
      stories/components/menu.stories.js
  23. 25
      stories/components/message.stories.js
  24. 40
      stories/components/modal.stories.js
  25. 30
      stories/components/notification.stories.js
  26. 20
      stories/components/page-elements.stories.js
  27. 11
      stories/components/panel.stories.js
  28. 28
      stories/components/qrcode.stories.js
  29. 13
      stories/components/spinner.stories.js
  30. 25
      stories/components/typography.stories.js
  31. 0
      stories/containers/pay.stories.js
  32. 0
      stories/containers/request.stories.js
  33. 2
      stories/forms/form.stories.js
  34. 20
      stories/helpers.js
  35. 2
      stories/icons/icon.stories.js
  36. 42
      stories/layouts/page.stories.js
  37. 40
      stories/layouts/panel.stories.js
  38. 27
      test/unit/components/Pay/__snapshots__/PaySummaryLightning.spec.js.snap
  39. 18
      test/unit/components/Pay/__snapshots__/PaySummaryOnchain.spec.js.snap
  40. 10
      test/unit/components/UI/__snapshots__/Bar.spec.js.snap
  41. 72
      test/unit/components/UI/__snapshots__/Dropdown.spec.js.snap
  42. 2
      test/unit/components/UI/__snapshots__/MainContent.spec.js.snap
  43. 2
      test/unit/components/UI/__snapshots__/Menu.spec.js.snap
  44. 4
      test/unit/components/UI/__snapshots__/Page.spec.js.snap
  45. 34
      test/unit/components/UI/__snapshots__/Panel.spec.js.snap
  46. 8
      test/unit/components/UI/__snapshots__/QRCode.spec.js.snap
  47. 1
      test/unit/components/UI/__snapshots__/Sidebar.spec.js.snap

9
.storybook/config.js

@ -16,9 +16,12 @@ import { getDefaultLocale, locales } from 'lib/i18n'
import { BackgroundPrimary, GlobalStyle } from 'components/UI'
const BackgroundPrimaryWithTheme = withTheme(({ theme, ...rest }) => (
<div className={theme.name}>
<BackgroundPrimary p={3} css={{ height: '100vh', 'overflow-y': 'scroll !important' }} {...rest} />
</div>
<BackgroundPrimary
className={theme.name}
p={3}
css={{ height: '100vh', 'overflow-y': 'scroll !important' }}
{...rest}
/>
))
// Register supported locales.

27
.storybook/preview-head.html

@ -3,23 +3,44 @@
.dark .story-subtitle,
.dark .chapter-header,
.dark .section-header,
.dark .section-title,
.dark .section-subsection,
.dark .section-button-container {
.dark .section-button-container,
.dark .chapter-h3 {
color: white !important;
display: block;
}
.dark .chapter-header {
border-bottom: 1px solid rgba(255, 255, 255, .5) !important;
}
.light .story-title,
.light .story-subtitle,
.light .chapter-header,
.light .section-header,
.light .section-title,
.light .section-subsection,
.light .section-button-container {
.light .section-button-container,
.light .chapter-h3 {
color: black !important;
display: block;
}
.light .chapter-header {
border-bottom: 1px solid rgba(0, 0, 0, .5) !important;
}
.chapter-header {
margin-bottom: 30px !important;
}
.story-header p {
margin-bottom: 1em;
margin-bottom: 1em !important;
}
.section-container {
margin-bottom: 30px !important;
}
.section-component-container {
margin-bottom: 15px !important;
}
</style>

5
app/components/Pay/Pay.js

@ -678,9 +678,10 @@ class Pay extends React.Component {
})} ${cryptoName} (${cryptoCurrencyTicker})`}
type={isLn ? 'offchain' : isOnchain ? 'onchain' : null}
/>
<Bar pt={2} />
</Panel.Header>
<Bar />
<Panel.Body>
<Panel.Body py={3}>
<Box width={1} css={{ position: 'relative' }}>
{this.renderHelpText()}
<Box width={1} css={{ position: 'absolute' }}>

22
app/components/Request/Request.js

@ -321,9 +321,9 @@ class Request extends React.Component {
subtitle={<FormattedMessage {...messages.subtitle} />}
logo={<Lightning height="45px" width="45px" />}
/>
<Bar pt={2} />
</Panel.Header>
<Bar />
<Panel.Body>
<Panel.Body py={3}>
{currentStep == 'form' ? (
<React.Fragment>
{this.renderHelpText()}
@ -347,14 +347,16 @@ class Request extends React.Component {
</Panel.Body>
{currentStep == 'form' && (
<Panel.Footer>
<Button
type="submit"
disabled={formState.pristine || formState.invalid || isProcessing}
processing={isProcessing}
mx="auto"
>
{nextButtonText}
</Button>
<Text textAlign="center">
<Button
type="submit"
disabled={formState.pristine || formState.invalid || isProcessing}
processing={isProcessing}
mx="auto"
>
{nextButtonText}
</Button>
</Text>
</Panel.Footer>
)}
</Panel>

42
app/components/UI/Bar.js

@ -1,28 +1,20 @@
import React from 'react'
import { Card } from 'rebass'
import system from '@rebass/components'
/**
* @render react
* @name Bar
* @example
* <Bar />
*/
class Bar extends React.PureComponent {
render() {
return (
<Card
width={1}
{...this.props}
borderColor="primaryText"
opacity={0.6}
border={1}
m={0}
p={0}
css={{ 'border-bottom': 'none !important' }}
as="hr"
/>
)
}
}
const Bar = system(
{
is: 'hr',
m: 0,
border: 0,
borderBottom: 1,
borderColor: 'primaryText',
opacity: 0.6
},
'borders',
'borderColor',
'space',
'opacity'
)
Bar.displayName = 'Bar'
export default Bar

58
app/components/UI/Dropdown.js

@ -152,34 +152,36 @@ class Dropdown extends React.Component {
})
const selectedItem = items.find(c => c.key === activeKey)
return (
<DropdownContainer ref={this.setWrapperRef} {...rest}>
<DropdownButton type="button" onClick={this.toggleMenu}>
<Text textAlign="left">
{selectedItem ? selectedItem.name : activeKey}{' '}
{isOpen ? <FaAngleUp /> : <FaAngleDown />}
</Text>
</DropdownButton>
{isOpen && (
<MenuContainer>
<Menu css={justify === 'right' ? { right: 0 } : null}>
{items.map(item => {
return (
<MenuItem key={item.key} onClick={() => this.onChange(item.key)}>
<Flex alignItems="center">
<Text width="20px" textAlign="center">
{activeKey === item.key && (
<Check height="0.95em" color={theme.colors.superGreen} />
)}
</Text>
<Text>{item.name}</Text>
</Flex>
</MenuItem>
)
})}
</Menu>
</MenuContainer>
)}
</DropdownContainer>
<div style={{ display: 'inline-block' }}>
<DropdownContainer ref={this.setWrapperRef} {...rest}>
<DropdownButton type="button" onClick={this.toggleMenu}>
<Text textAlign="left">
{selectedItem ? selectedItem.name : activeKey}{' '}
{isOpen ? <FaAngleUp /> : <FaAngleDown />}
</Text>
</DropdownButton>
{isOpen && (
<MenuContainer>
<Menu css={justify === 'right' ? { right: 0 } : null}>
{items.map(item => {
return (
<MenuItem key={item.key} onClick={() => this.onChange(item.key)}>
<Flex alignItems="center">
<Text width="20px" textAlign="center">
{activeKey === item.key && (
<Check height="0.95em" color={theme.colors.superGreen} />
)}
</Text>
<Text>{item.name}</Text>
</Flex>
</MenuItem>
)
})}
</Menu>
</MenuContainer>
)}
</DropdownContainer>
</div>
)
}
}

4
app/components/UI/MainContent.js

@ -7,8 +7,6 @@ import { BackgroundPrimary } from 'components/UI'
* @example
* <MainContent>Some content</MainContent>
*/
const MainContent = props => (
<BackgroundPrimary as="article" width={1} p={3} css={{ height: '100%' }} {...props} />
)
const MainContent = props => <BackgroundPrimary as="article" width={1} {...props} />
export default MainContent

6
app/components/UI/Menu.js

@ -7,9 +7,11 @@ const SystemMenu = system(
{
extend: MenuBase,
mb: 2,
p: 0
p: 0,
color: 'primaryText'
},
'space'
'space',
'color'
)
const StyledMenu = styled(SystemMenu)`

1
app/components/UI/Page.js

@ -9,7 +9,6 @@ import { Flex } from 'rebass'
*/
const Page = ({ css, ...rest }) => (
<Flex
alignItems="stretch"
bg="primaryColor"
as="article"
css={Object.assign(

11
app/components/UI/Panel.js

@ -1,26 +1,25 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Box, Flex } from 'rebass'
import { Text } from 'components/UI'
const PanelHeader = ({ children, ...rest }) => (
<Text pb={3} textAlign="center" {...rest} as="header">
<Box {...rest} as="header">
{children}
</Text>
</Box>
)
PanelHeader.propTypes = { children: PropTypes.node }
const PanelBody = ({ children, ...rest }) => (
<Box py={3} {...rest} as="section" css={{ flex: 1 }}>
<Box {...rest} as="section" css={{ flex: 1 }}>
{children}
</Box>
)
PanelBody.propTypes = { children: PropTypes.node }
const PanelFooter = ({ children, ...rest }) => (
<Text textAlign="center" {...rest} as="footer" pt="auto">
<Box {...rest} as="footer" pt="auto">
{children}
</Text>
</Box>
)
PanelFooter.propTypes = { children: PropTypes.node }

4
app/components/UI/QRCode.js

@ -70,8 +70,8 @@ class ZapQRCode extends React.PureComponent {
static defaultProps = {
size: '150px',
color: 'primaryColor',
bg: 'primaryText'
color: 'black',
bg: 'white'
}
render() {

2
app/components/UI/Sidebar.js

@ -7,7 +7,7 @@ import { BackgroundTertiary } from 'components/UI'
* @example
* <Sidebar>Some content</Sidebar>
*/
const Sidebar = props => <BackgroundTertiary as="aside" p={3} width={4 / 12} {...props} />
const Sidebar = props => <BackgroundTertiary as="aside" width={4 / 12} {...props} />
Sidebar.small = props => <Sidebar {...props} width={3 / 12} />
Sidebar.medium = props => <Sidebar {...props} width={4 / 12} />

4
stories/_welcome.stories.js → stories/_general/_welcome.stories.js

@ -15,7 +15,7 @@ import {
TextArea,
Toggle
} from 'components/UI'
import { Column, Group, Element } from './helpers'
import { Column, Group, Element } from '../helpers'
const store = new Store({
crypto: 'btc',
@ -50,7 +50,7 @@ const store = new Store({
]
})
storiesOf('Welcome', module)
storiesOf('General', module)
.addDecorator(StateDecorator(store))
.addWithChapters('Zap Style Guide', {
subtitle: 'Reusable components for Zap Desktop.',

8
stories/color.stories.js → stories/_general/color.stories.js

@ -5,7 +5,7 @@ import { ThemeProvider, withTheme } from 'styled-components'
import { Box, Card, Flex } from 'rebass'
import { BackgroundPrimary, Text } from 'components/UI'
import { dark, light } from 'themes'
import { Column, Group, Element } from './helpers'
import { Column, Group, Element } from '../helpers'
const Swatch = ({ name, color }) => (
<Element>
@ -42,7 +42,7 @@ const Palette = withTheme(({ theme, ...rest }) => (
</Box>
))
storiesOf('Welcome', module).addWithChapters('Color palette', {
storiesOf('General', module).addWithChapters('Color palette', {
subtitle: 'Colors that we use throughout the app.',
info: `This page shows our two primary colour palettes. These are used as "themes" that users can switch between
within the app.`,
@ -59,7 +59,7 @@ storiesOf('Welcome', module).addWithChapters('Color palette', {
sectionFn: () => (
<Flex>
<Column>
<Group title="Dark">
<Group title="Dark" withBar={false}>
<ThemeProvider theme={dark}>
<BackgroundPrimary p={3}>
<Palette />
@ -69,7 +69,7 @@ storiesOf('Welcome', module).addWithChapters('Color palette', {
</Column>
<Column>
<Group title="Light">
<Group title="Light" withBar={false}>
<ThemeProvider theme={light}>
<BackgroundPrimary p={3}>
<Palette />

79
stories/_general/typography.stories.js

@ -0,0 +1,79 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Heading, Text } from 'components/UI'
storiesOf('General', module).addWithChapters('Typography', {
subtitle: 'Text styles that we use throughout the app.',
info: `This page shows the various fonts and font styles that we use. All text uses the "Roboto" font family.`,
chapters: [
{
title: 'Heading',
sections: [
{
title: 'h1',
sectionFn: () => <Heading.h1>The quick brown fox jumps over the lazy dog</Heading.h1>
},
{
title: 'h2',
sectionFn: () => <Heading.h2>The quick brown fox jumps over the lazy dog</Heading.h2>
},
{
title: 'h3',
sectionFn: () => <Heading.h3>The quick brown fox jumps over the lazy dog</Heading.h3>
},
{
title: 'h4',
sectionFn: () => <Heading.h4>The quick brown fox jumps over the lazy dog</Heading.h4>
}
]
},
{
title: 'Text (weights)',
sections: [
{
title: 'Normal',
sectionFn: () => (
<Text fontWeight="normal">The quick brown fox jumps over the lazy dog</Text>
)
},
{
title: 'Light',
sectionFn: () => <Text>The quick brown fox jumps over the lazy dog</Text>
}
]
},
{
title: 'Text (sizes)',
sections: [
{
title: 'Extra Extra large',
sectionFn: () => <Text fontSize="xxl">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Extra Large',
sectionFn: () => <Text fontSize="xl">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Large',
sectionFn: () => <Text fontSize="l">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Medium',
sectionFn: () => <Text fontSize="m">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Small',
sectionFn: () => <Text fontSize="s">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Extra Small',
sectionFn: () => <Text fontSize="xs">The quick brown fox jumps over the lazy dog</Text>
},
{
title: 'Extra Extra Small',
sectionFn: () => <Text fontSize="xxs">The quick brown fox jumps over the lazy dog</Text>
}
]
}
]
})

86
stories/components/background.stories.js

@ -1,26 +1,66 @@
import React from 'react'
import PropTypes from 'prop-types'
import { storiesOf } from '@storybook/react'
import { BackgroundPrimary, BackgroundTertiary, BackgroundSecondary } from 'components/UI'
import { BackgroundPrimary, BackgroundTertiary, BackgroundSecondary, Page } from 'components/UI'
import { Content } from '../helpers'
storiesOf('Components.Background', module)
.add('dark', () => (
<BackgroundPrimary
css={{
height: '50vh'
}}
/>
))
.add('light', () => (
<BackgroundTertiary
css={{
height: '50vh'
}}
/>
))
.add('lightest', () => (
<BackgroundSecondary
css={{
height: '50vh'
}}
/>
))
const Wrapper = ({ children }) => (
<Page css={{ height: '50px', 'min-height': '200px' }}>{children}</Page>
)
Wrapper.propTypes = {
children: PropTypes.node
}
storiesOf('Components', module).addWithChapters('Background', {
chapters: [
{
sections: [
{
options: {
decorator: story => <Wrapper>{story()}</Wrapper>
},
sectionFn: () => (
<BackgroundPrimary
width={1}
css={{
height: '100%'
}}
>
<Content>BackgroundPrimary</Content>
</BackgroundPrimary>
)
},
{
options: {
decorator: story => <Wrapper>{story()}</Wrapper>
},
sectionFn: () => (
<BackgroundSecondary
width={1}
css={{
height: '100%'
}}
>
<Content>BackgroundSecondary</Content>
</BackgroundSecondary>
)
},
{
options: {
decorator: story => <Wrapper>{story()}</Wrapper>
},
sectionFn: () => (
<BackgroundTertiary
width={1}
css={{
height: '100%'
}}
>
<Content>BackgroundTertiary</Content>
</BackgroundTertiary>
)
}
]
}
]
})

14
stories/components/bar.stories.js

@ -2,4 +2,16 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { Bar } from 'components/UI'
storiesOf('Components.Bar', module).add('bar', () => <Bar />)
storiesOf('Components', module).addWithChapters('Bar', {
subtitle: 'For dividing sections.',
info: `The Bar component is used to divide sections.`,
chapters: [
{
sections: [
{
sectionFn: () => <Bar />
}
]
}
]
})

127
stories/components/button.stories.js

@ -5,43 +5,90 @@ import { Button } from 'components/UI'
import SystemNavPrevious from 'components/Icon/SystemNavPrevious'
import SystemNavNext from 'components/Icon/SystemNavNext'
storiesOf('Components.Button', module)
.add('Basic', () => <Button onClick={action('clicked')}>Basic button</Button>)
.add('With Icon', () => (
<section>
<Button onClick={action('clicked')}>
<SystemNavPrevious />
Previous
</Button>{' '}
<Button onClick={action('clicked')}>
Next
<SystemNavNext />
</Button>
</section>
))
.add('Processing', () => (
<Button processing onClick={action('clicked')}>
Processing
</Button>
))
.add('Disabled', () => (
<Button disabled onClick={action('clicked')}>
Disabled button
</Button>
))
.add('Primary', () => (
<Button onClick={action('clicked')} variant="primary">
Primary button
</Button>
))
.add('Secondary', () => (
<Button onClick={action('clicked')} variant="secondary">
Secondary button
</Button>
))
.add('Small', () => (
<Button onClick={action('clicked')} size="small">
Small button
</Button>
))
.add('Normal', () => <Button onClick={action('clicked')}>Medium button</Button>)
storiesOf('Components', module).addWithChapters('Button', {
subtitle: 'Buttons for forms and anything else that the user might want to click on.',
chapters: [
{
sections: [
{
title: 'Basic',
sectionFn: () => <Button onClick={action('clicked')}>Basic button</Button>
},
{
title: 'With Icon',
sectionFn: () => (
<section>
<Button onClick={action('clicked')}>
<SystemNavPrevious />
Previous
</Button>{' '}
<Button onClick={action('clicked')}>
Next
<SystemNavNext />
</Button>
</section>
)
}
]
},
{
title: 'Variants',
sections: [
{
title: 'Primary',
sectionFn: () => (
<Button onClick={action('clicked')} variant="primary">
Primary button
</Button>
)
},
{
title: 'Secondary',
sectionFn: () => (
<Button onClick={action('clicked')} variant="secondary">
Secondary button
</Button>
)
}
]
},
{
title: 'States',
sections: [
{
title: 'Processing',
sectionFn: () => (
<Button processing onClick={action('clicked')}>
Processing
</Button>
)
},
{
title: 'Disabled',
sectionFn: () => (
<Button disabled onClick={action('clicked')}>
Disabled button
</Button>
)
}
]
},
{
title: 'Sizes',
sections: [
{
title: 'Medium',
sectionFn: () => <Button onClick={action('clicked')}>Medium button</Button>
},
{
title: 'Small',
sectionFn: () => (
<Button onClick={action('clicked')} size="small">
Small button
</Button>
)
}
]
}
]
})

2
stories/components/countdown.stories.js

@ -2,7 +2,7 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { Countdown } from 'components/UI'
storiesOf('Components.Countdown', module).addWithChapters('Countdown', {
storiesOf('Components', module).addWithChapters('Countdown', {
chapters: [
{
sections: [

118
stories/components/dropdown.stories.js

@ -1,58 +1,76 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { StateDecorator, Store } from '@sambego/storybook-state'
import { State, Store } from '@sambego/storybook-state'
import { Dropdown } from 'components/UI'
const store = new Store({
crypto: 'btc',
fiat: 'usd',
cryptoCurrencies: [
storiesOf('Components', module).addWithChapters('Dropdown', {
chapters: [
{
key: 'btc',
name: 'BTC'
},
{
key: 'bits',
name: 'bits'
},
{
key: 'sats',
name: 'satoshis'
}
],
fiatCurrencies: [
{
key: 'usd',
name: 'USD'
},
{
key: 'eur',
name: 'EUR'
},
{
key: 'gbp',
name: 'GBP'
sections: [
{
title: 'Left justify (default)',
sectionFn: () => {
const store = new Store({
crypto: 'btc',
cryptoCurrencies: [
{
key: 'btc',
name: 'BTC'
},
{
key: 'bits',
name: 'bits'
},
{
key: 'sats',
name: 'satoshis'
}
]
})
return (
<State store={store}>
<Dropdown
activeKey={store.get('crypto')}
items={store.get('cryptoCurrencies')}
onChange={crypto => store.set({ crypto })}
/>
</State>
)
}
},
{
title: 'Right justify',
sectionFn: () => {
const store = new Store({
fiat: 'usd',
fiatCurrencies: [
{
key: 'usd',
name: 'USD'
},
{
key: 'eur',
name: 'EUR'
},
{
key: 'gbp',
name: 'GBP'
}
]
})
return (
<State store={store}>
<Dropdown
activeKey={store.get('fiat')}
items={store.get('fiatCurrencies')}
onChange={fiat => store.set({ fiat })}
justify="right"
/>
</State>
)
}
}
]
}
]
})
storiesOf('Components.Dropdown', module)
.addDecorator(StateDecorator(store))
.add('Crypto', () => {
return (
<Dropdown
activeKey={store.get('crypto')}
items={store.get('cryptoCurrencies')}
onChange={crypto => store.set({ crypto })}
/>
)
})
.add('Fiat', () => {
return (
<Dropdown
activeKey={store.get('fiat')}
items={store.get('fiatCurrencies')}
onChange={fiat => store.set({ fiat })}
/>
)
})

21
stories/components/header.stories.js

@ -3,6 +3,21 @@ import { storiesOf } from '@storybook/react'
import { Header } from 'components/UI'
import Lightning from 'components/Icon/Lightning'
storiesOf('Components.Header', module).add('Header', () => (
<Header title="Title here" subtitle="Subtitle here" logo={<Lightning />} />
))
storiesOf('Components', module).addWithChapters('Header', {
subtitle: 'A section heading with on optional title, subtitle, and icon.',
chapters: [
{
sections: [
{
sectionFn: () => (
<Header
title="This is a heading"
subtitle="You can add an optional subtitle too."
logo={<Lightning />}
/>
)
}
]
}
]
})

39
stories/components/menu.stories.js

@ -3,18 +3,29 @@ import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'
import { Menu, MenuItem, MenuItemGroup } from 'components/UI'
storiesOf('Components.Menu', module).add('Menu', () => (
<Menu onSelect={action('select')}>
<MenuItemGroup title="My Items">
<MenuItem key="item1">My item 1</MenuItem>
<MenuItem key="item2">My item 2</MenuItem>
<MenuItem key="item3">My item 3</MenuItem>
</MenuItemGroup>
storiesOf('Components', module).addWithChapters('Menu', {
subtitle: 'A section heading with on optional title, subtitle, and icon.',
chapters: [
{
sections: [
{
sectionFn: () => (
<Menu onSelect={action('select')}>
<MenuItemGroup title="My Items">
<MenuItem key="item1">My item 1</MenuItem>
<MenuItem key="item2">My item 2</MenuItem>
<MenuItem key="item3">My item 3</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="Other items">
<MenuItem key="item4">Other item 1</MenuItem>
<MenuItem key="item5">Other item 2</MenuItem>
<MenuItem key="item6">Other item 3</MenuItem>
</MenuItemGroup>
</Menu>
))
<MenuItemGroup title="Other items">
<MenuItem key="item4">Other item 1</MenuItem>
<MenuItem key="item5">Other item 2</MenuItem>
<MenuItem key="item6">Other item 3</MenuItem>
</MenuItemGroup>
</Menu>
)
}
]
}
]
})

25
stories/components/message.stories.js

@ -0,0 +1,25 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Message } from 'components/UI'
storiesOf('Components', module).addWithChapters('Message', {
subtitle: 'For displaying messages.',
chapters: [
{
sections: [
{
title: 'Success',
sectionFn: () => <Message variant="success">Success message</Message>
},
{
title: 'Warning',
sectionFn: () => <Message variant="warning">Warning message</Message>
},
{
title: 'Error',
sectionFn: () => <Message variant="error">Error message</Message>
}
]
}
]
})

40
stories/components/modal.stories.js

@ -3,16 +3,30 @@ import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'
import { Modal, Page, Text } from 'components/UI'
storiesOf('Components.Modal', module).add('Modal', () => (
<Page>
<Modal onClose={action('clicked')}>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Text>
</Modal>
</Page>
))
storiesOf('Components', module).addWithChapters('Modal', {
subtitle: 'For displaying content in an overlay.',
info: `We use modals to display popup screens on top of your current position in the app. Closing the modal should
take you back to where you were before you opened it.`,
chapters: [
{
sections: [
{
sectionFn: () => (
<Page>
<Modal onClose={action('clicked')}>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</Text>
</Modal>
</Page>
)
}
]
}
]
})

30
stories/components/notification.stories.js

@ -2,8 +2,28 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { Notification } from 'components/UI'
storiesOf('Components.Notification', module)
.add('Success', () => <Notification variant="success">Success message</Notification>)
.add('Warning', () => <Notification variant="warning">Warning message</Notification>)
.add('Error', () => <Notification variant="error">Error message</Notification>)
.add('Processing', () => <Notification processing>Processing message</Notification>)
storiesOf('Components', module).addWithChapters('Notification', {
subtitle: 'For displaying important messages.',
chapters: [
{
sections: [
{
title: 'Success',
sectionFn: () => <Notification variant="success">Success notification</Notification>
},
{
title: 'Warning',
sectionFn: () => <Notification variant="warning">Warning notification</Notification>
},
{
title: 'Error',
sectionFn: () => <Notification variant="error">Error notification</Notification>
},
{
title: 'Processing',
sectionFn: () => <Notification processing>Processing notification</Notification>
}
]
}
]
})

20
stories/components/page-elements.stories.js

@ -1,20 +0,0 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Page, MainContent, Sidebar } from 'components/UI'
storiesOf('Components.Layouts', module)
.add('MainContent', () => <MainContent>Main content</MainContent>)
.add('Sidebar', () => <Sidebar>Sidebar</Sidebar>)
.add('Page', () => <Page>Page</Page>)
.add('Page - sidebar left', () => (
<Page>
<Sidebar.small>Sidebar left</Sidebar.small>
<MainContent>Main content</MainContent>
</Page>
))
.add('Page - sidebar right', () => (
<Page>
<MainContent>Main content</MainContent>
<Sidebar.large>Sidebar right</Sidebar.large>
</Page>
))

11
stories/components/panel.stories.js

@ -1,11 +0,0 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Panel } from 'components/UI'
storiesOf('Components.Panel', module).add('Panel', () => (
<Panel css={{ height: '500px' }}>
<Panel.Header bg="secondaryColor">Header here</Panel.Header>
<Panel.Body bg="tertiaryColor">Body here</Panel.Body>
<Panel.Footer bg="secondaryColor">Footer here</Panel.Footer>
</Panel>
))

28
stories/components/qrcode.stories.js

@ -2,6 +2,28 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { QRCode } from 'components/UI'
storiesOf('Components.QR Code', module).add('QR Code', () => (
<QRCode value="w35x2gzfdech26tnd96xjan9yqks6cqzysxqr23s8wgz42uvfa833nhl75vxewpmsu3up7dnw5pl3nurp0tcagsl6lg5f3ty" />
))
storiesOf('Components', module).addWithChapters('QR Code', {
subtitle: 'For displaying complex data in an easily scannable format.',
chapters: [
{
sections: [
{
title: 'default size',
sectionFn: () => (
/* eslint-disable max-len */
<QRCode value="w35x2gzfdech26tnd96xjan9yqks6cqzysxqr23s8wgz42uvfa833nhl75vxewpmsu3up7dnw5pl3nurp0tcagsl6lg5f3ty" />
)
},
{
title: 'custom size',
sectionFn: () => (
<QRCode
value="w35x2gzfdech26tnd96xjan9yqks6cqzysxqr23s8wgz42uvfa833nhl75vxewpmsu3up7dnw5pl3nurp0tcagsl6lg5f3ty"
size="100px"
/>
)
}
]
}
]
})

13
stories/components/spinner.stories.js

@ -3,4 +3,15 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { Spinner } from 'components/UI'
storiesOf('Components.Spinners', module).add('circle', () => <Spinner />)
storiesOf('Components', module).addWithChapters('Spinner', {
subtitle: 'For letting the user know that something is happening.',
chapters: [
{
sections: [
{
sectionFn: () => <Spinner />
}
]
}
]
})

25
stories/components/typography.stories.js

@ -1,25 +0,0 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Heading, Text } from 'components/UI'
storiesOf('Components.Typography', module)
.add('heading', () => (
<React.Fragment>
<Heading>This is a default heading (h2)</Heading>
<Heading.h1>This is an h1</Heading.h1>
<Heading.h2>This is an h2</Heading.h2>
<Heading.h3>This is an h3</Heading.h3>
<Heading.h4>This is an h4</Heading.h4>
<Heading.h5>This is an h5</Heading.h5>
<Heading.h6>This is an h6</Heading.h6>
</React.Fragment>
))
.add('text', () => (
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Text>
))

0
stories/pages/pay.stories.js → stories/containers/pay.stories.js

0
stories/pages/request.stories.js → stories/containers/request.stories.js

2
stories/components/form.stories.js → stories/forms/form.stories.js

@ -31,7 +31,7 @@ const selectItems = [
{ value: 'banana' }
]
storiesOf('Components.Form', module)
storiesOf('Forms', module)
.add('Input', () => (
<Form>
<Input field="fieldName" id="field-name" />

20
stories/helpers.js

@ -1,20 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Box } from 'rebass'
import { Bar, Heading } from 'components/UI'
import { Box, Flex } from 'rebass'
import { Bar, Heading, Page } from 'components/UI'
export const Window = props => <Page css={{ height: 'calc(100vh - 40px)' }} {...props} />
export const Column = props => <Box width={1 / 2} mr={5} {...props} />
export const Group = ({ title, children }) => (
export const Group = ({ title, children, withBar = true }) => (
<Box mb={4}>
<Heading.h3 mb={2} fontWeight="normal">
{title}
</Heading.h3>
<Bar mb={3} />
{withBar && <Bar mb={3} />}
{children}
</Box>
)
Group.propTypes = {
title: PropTypes.string,
children: PropTypes.node
children: PropTypes.node,
withBar: PropTypes.bool
}
export const Element = props => <Box py={1} {...props} />
export const Content = ({ children }) => (
<Flex justifyContent="center" alignItems="center" css={{ height: '100%' }}>
<Heading>{children}</Heading>
</Flex>
)
Content.propTypes = {
children: PropTypes.node
}

2
stories/components/icon.stories.js → stories/icons/icon.stories.js

@ -106,7 +106,7 @@ const zapIconsList = {
ZapLogoBlack
}
const zapIconStories = storiesOf('Components.Icon', module)
const zapIconStories = storiesOf('Icons', module)
Object.keys(zapIconsList).forEach(name => {
var Icon = zapIconsList[name]

42
stories/layouts/page.stories.js

@ -0,0 +1,42 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { Page, MainContent, Sidebar } from 'components/UI'
import { Content } from '../helpers'
storiesOf('Layouts', module).addWithChapters('Page', {
subtitle: 'The outer most application wrapper.',
info: `Pages can have optional sidebars on the left or right.`,
chapters: [
{
sections: [
{
title: 'Page with small left sidebar',
sectionFn: () => (
<Page>
<Sidebar.small bg="green">
<Content>Sidebar</Content>
</Sidebar.small>
<MainContent bg="blue">
<Content>MainContent</Content>
</MainContent>
</Page>
)
},
{
title: 'Page with large right sidebar',
sectionFn: () => (
<Page>
<MainContent bg="blue">
<Content>MainContent</Content>
</MainContent>
<Sidebar.large bg="green">
<Content>Sidebar</Content>
</Sidebar.large>
</Page>
)
}
]
}
]
})

40
stories/layouts/panel.stories.js

@ -0,0 +1,40 @@
import React from 'react'
import PropTypes from 'prop-types'
import { storiesOf } from '@storybook/react'
import { Page, Panel } from 'components/UI'
import { Content } from '../helpers'
const Wrapper = ({ children }) => (
<Page css={{ height: '500px', 'min-height': '500px' }}>{children}</Page>
)
Wrapper.propTypes = {
children: PropTypes.node
}
storiesOf('Layouts', module).addWithChapters('Panel', {
subtitle: 'For pages with a fixed header and footer.',
info: `Header and footer regions will always stick to the top and bottom of a panels container.`,
chapters: [
{
sections: [
{
sectionFn: () => (
<Wrapper>
<Panel width={1} css={{ height: '100%' }}>
<Panel.Header bg="green">
<Content>Panel Header</Content>
</Panel.Header>
<Panel.Body bg="blue">
<Content>Panel Body</Content>
</Panel.Body>
<Panel.Footer bg="green">
<Content>Panel Footer</Content>
</Panel.Footer>
</Panel>
</Wrapper>
)
}
]
}
]
})

27
test/unit/components/Pay/__snapshots__/PaySummaryLightning.spec.js.snap

@ -88,7 +88,14 @@ exports[`component.Form.PaySummaryLightning should render correctly 1`] = `
</styled.div>
</Styled(styled.div)>
</styled.div>
<Bar />
<Bar
border={0}
borderBottom={1}
borderColor="primaryText"
is="hr"
m={0}
opacity={0.6}
/>
<DataRow
left={
<FormattedMessage
@ -110,7 +117,14 @@ exports[`component.Form.PaySummaryLightning should render correctly 1`] = `
/>
}
/>
<Bar />
<Bar
border={0}
borderBottom={1}
borderColor="primaryText"
is="hr"
m={0}
opacity={0.6}
/>
<DataRow
left={
<FormattedMessage
@ -130,6 +144,13 @@ exports[`component.Form.PaySummaryLightning should render correctly 1`] = `
</React.Fragment>
}
/>
<Bar />
<Bar
border={0}
borderBottom={1}
borderColor="primaryText"
is="hr"
m={0}
opacity={0.6}
/>
</styled.div>
`;

18
test/unit/components/Pay/__snapshots__/PaySummaryOnchain.spec.js.snap

@ -101,7 +101,14 @@ exports[`component.Form.PaySummaryOnchain should render correctly 1`] = `
</styled.div>
</Styled(styled.div)>
</styled.div>
<Bar />
<Bar
border={0}
borderBottom={1}
borderColor="primaryText"
is="hr"
m={0}
opacity={0.6}
/>
<DataRow
left={
<FormattedMessage
@ -118,7 +125,14 @@ exports[`component.Form.PaySummaryOnchain should render correctly 1`] = `
/>
}
/>
<Bar />
<Bar
border={0}
borderBottom={1}
borderColor="primaryText"
is="hr"
m={0}
opacity={0.6}
/>
<DataRow
left={
<FormattedMessage

10
test/unit/components/UI/__snapshots__/Bar.spec.js.snap

@ -2,18 +2,14 @@
exports[`component.UI.Bar should render correctly 1`] = `
.c0 {
margin: 0px;
padding: 0px;
width: 100%;
border-bottom: none !important;
border: 1px solid;
border: 0;
border-bottom: 1px solid;
border-color: primaryText;
margin: 0px;
opacity: 0.6;
}
<hr
className="c0"
opacity={0.6}
width={1}
/>
`;

72
test/unit/components/UI/__snapshots__/Dropdown.spec.js.snap

@ -40,41 +40,49 @@ exports[`component.Dropdown should render correctly 1`] = `
}
<div
className="c0"
onClick={[MockFunction]}
style={
Object {
"display": "inline-block",
}
}
>
<button
className="c1"
onClick={[Function]}
type="button"
<div
className="c0"
onClick={[MockFunction]}
>
<div
className="c2"
color="primaryText"
fontSize="m"
<button
className="c1"
onClick={[Function]}
type="button"
>
BTC
<svg
fill="currentColor"
height="1em"
preserveAspectRatio="xMidYMid meet"
style={
Object {
"color": undefined,
"verticalAlign": "middle",
}
}
viewBox="0 0 40 40"
width="1em"
<div
className="c2"
color="primaryText"
fontSize="m"
>
<g>
<path
d="m31 16.4q0 0.3-0.2 0.5l-10.4 10.4q-0.3 0.3-0.5 0.3t-0.6-0.3l-10.4-10.4q-0.2-0.2-0.2-0.5t0.2-0.5l1.2-1.1q0.2-0.2 0.5-0.2t0.5 0.2l8.8 8.8 8.7-8.8q0.3-0.2 0.5-0.2t0.6 0.2l1.1 1.1q0.2 0.2 0.2 0.5z"
/>
</g>
</svg>
</div>
</button>
BTC
<svg
fill="currentColor"
height="1em"
preserveAspectRatio="xMidYMid meet"
style={
Object {
"color": undefined,
"verticalAlign": "middle",
}
}
viewBox="0 0 40 40"
width="1em"
>
<g>
<path
d="m31 16.4q0 0.3-0.2 0.5l-10.4 10.4q-0.3 0.3-0.5 0.3t-0.6-0.3l-10.4-10.4q-0.2-0.2-0.2-0.5t0.2-0.5l1.2-1.1q0.2-0.2 0.5-0.2t0.5 0.2l8.8 8.8 8.7-8.8q0.3-0.2 0.5-0.2t0.6 0.2l1.1 1.1q0.2 0.2 0.2 0.5z"
/>
</g>
</svg>
</div>
</button>
</div>
</div>
`;

2
test/unit/components/UI/__snapshots__/MainContent.spec.js.snap

@ -2,11 +2,9 @@
exports[`component.UI.MainContent should render correctly 1`] = `
.c0 {
padding: 16px;
width: 100%;
color: primaryText;
background-color: primaryColor;
height: 100%;
}
<article

2
test/unit/components/UI/__snapshots__/Menu.spec.js.snap

@ -4,6 +4,7 @@ exports[`component.UI.Menu should render correctly 1`] = `
.c0 {
margin-bottom: 8px;
padding: 0px;
color: #ffffff;
outline: none;
}
@ -38,6 +39,7 @@ exports[`component.UI.Menu should render correctly 1`] = `
<ul
className="rc-menu c0 rc-menu-root rc-menu-vertical"
color="primaryText"
mb={2}
onKeyDown={[Function]}
p={0}

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

@ -12,10 +12,6 @@ exports[`component.UI.Page should render correctly 1`] = `
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: stretch;
-webkit-box-align: stretch;
-ms-flex-align: stretch;
align-items: stretch;
}
<article

34
test/unit/components/UI/__snapshots__/Panel.spec.js.snap

@ -1,14 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`component.UI.Panel should render correctly 1`] = `
.c2 {
padding-top: 16px;
padding-bottom: 16px;
.c1 {
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
.c2 {
padding-top: auto;
}
.c0 {
height: 100%;
display: -webkit-box;
@ -20,41 +22,21 @@ exports[`component.UI.Panel should render correctly 1`] = `
flex-direction: column;
}
.c1 {
padding-bottom: 16px;
font-size: m;
color: primaryText;
text-align: center;
line-height: 1.4;
}
.c3 {
padding-top: auto;
font-size: m;
color: primaryText;
text-align: center;
line-height: 1.4;
}
<article
className="c0"
>
<header
className="c1"
color="primaryText"
fontSize="m"
className=""
>
Header here
</header>
<section
className="c2"
className="c1"
>
Body here
</section>
<footer
className="c3"
color="primaryText"
fontSize="m"
className="c2"
>
Footer here
</footer>

8
test/unit/components/UI/__snapshots__/QRCode.spec.js.snap

@ -105,9 +105,9 @@ exports[`component.UI.QRCode should render correctly 1`] = `
/>
</div>
<svg
bg="primaryText"
bg="white"
className="c6"
color="primaryColor"
color="black"
height="80%"
shapeRendering="crispEdges"
viewBox="0 0 21 21"
@ -115,11 +115,11 @@ exports[`component.UI.QRCode should render correctly 1`] = `
>
<path
d="M0,0 h21v21H0z"
fill="primaryText"
fill="white"
/>
<path
d="M0 0h7v1H0zM8 0h1v1H8zM12 0h1v1H12zM14,0 h7v1H14zM0 1h1v1H0zM6 1h1v1H6zM8 1h2v1H8zM11 1h1v1H11zM14 1h1v1H14zM20,1 h1v1H20zM0 2h1v1H0zM2 2h3v1H2zM6 2h1v1H6zM8 2h5v1H8zM14 2h1v1H14zM16 2h3v1H16zM20,2 h1v1H20zM0 3h1v1H0zM2 3h3v1H2zM6 3h1v1H6zM8 3h1v1H8zM10 3h1v1H10zM12 3h1v1H12zM14 3h1v1H14zM16 3h3v1H16zM20,3 h1v1H20zM0 4h1v1H0zM2 4h3v1H2zM6 4h1v1H6zM9 4h4v1H9zM14 4h1v1H14zM16 4h3v1H16zM20,4 h1v1H20zM0 5h1v1H0zM6 5h1v1H6zM8 5h1v1H8zM10 5h1v1H10zM12 5h1v1H12zM14 5h1v1H14zM20,5 h1v1H20zM0 6h7v1H0zM8 6h1v1H8zM10 6h1v1H10zM12 6h1v1H12zM14,6 h7v1H14zM0 8h2v1H0zM4 8h3v1H4zM12 8h1v1H12zM15 8h1v1H15zM17,8 h4v1H17zM1 9h4v1H1zM8 9h1v1H8zM12 9h3v1H12zM17 9h2v1H17zM0 10h1v1H0zM4 10h3v1H4zM10 10h1v1H10zM12 10h2v1H12zM18 10h2v1H18zM1 11h1v1H1zM3 11h2v1H3zM7 11h6v1H7zM15 11h1v1H15zM19 11h1v1H19zM1 12h1v1H1zM3 12h5v1H3zM10 12h2v1H10zM14 12h3v1H14zM19,12 h2v1H19zM8 13h2v1H8zM11 13h2v1H11zM17 13h2v1H17zM0 14h7v1H0zM11 14h1v1H11zM14 14h3v1H14zM19 14h1v1H19zM0 15h1v1H0zM6 15h1v1H6zM8 15h2v1H8zM13 15h2v1H13zM16 15h1v1H16zM20,15 h1v1H20zM0 16h1v1H0zM2 16h3v1H2zM6 16h1v1H6zM8 16h1v1H8zM10 16h1v1H10zM12 16h3v1H12zM16 16h2v1H16zM20,16 h1v1H20zM0 17h1v1H0zM2 17h3v1H2zM6 17h1v1H6zM9 17h2v1H9zM12 17h5v1H12zM18,17 h3v1H18zM0 18h1v1H0zM2 18h3v1H2zM6 18h1v1H6zM12 18h2v1H12zM16 18h3v1H16zM0 19h1v1H0zM6 19h1v1H6zM8 19h5v1H8zM15 19h2v1H15zM0 20h7v1H0zM8 20h2v1H8zM11 20h1v1H11zM14 20h2v1H14zM17 20h1v1H17zM20,20 h1v1H20z"
fill="primaryColor"
fill="black"
/>
</svg>
</div>

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

@ -2,7 +2,6 @@
exports[`component.UI.Sidebar should render correctly 1`] = `
.c0 {
padding: 16px;
width: 33.33333333333333%;
color: primaryText;
background-color: tertiaryColor;

Loading…
Cancel
Save