Browse Source

Merge pull request #224 from meriadec/master

Update storybook
master
Loëck Vézien 7 years ago
committed by GitHub
parent
commit
7c4c6edc4c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .circleci/config.yml
  2. 9
      src/components/RequestAmount/stories.js
  3. 4
      src/components/base/InputCurrency/stories.js
  4. 19
      src/components/base/Modal/stories.js
  5. 9
      src/styles/global.js

4
.circleci/config.yml

@ -16,8 +16,8 @@ jobs:
name: Flow typed name: Flow typed
command: yarn flow-typed command: yarn flow-typed
- run: - run:
name: Temporary remove flow definitions for react-redux name: Temporary remove broken flow definitions
command: rm flow-typed/npm/react-redux_v5.x.x.js command: rm flow-typed/npm/{react-redux_v5.x.x.js,redux_v3.x.x.js}
- run: - run:
name: Lint name: Lint
command: yarn lint command: yarn lint

9
src/components/RequestAmount/stories.js

@ -4,12 +4,13 @@ import React from 'react'
import { storiesOf } from '@storybook/react' import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions' import { action } from '@storybook/addon-actions'
import { number } from '@storybook/addon-knobs' import { number } from '@storybook/addon-knobs'
import { translate } from 'react-i18next'
import { accounts } from 'components/SelectAccount/stories' import { accounts } from 'components/SelectAccount/stories'
import { RequestAmount } from 'components/RequestAmount' import { RequestAmount } from 'components/RequestAmount'
const stories = storiesOf('Components/RequestAmount', module) const stories = storiesOf('Components', module)
const props = { const props = {
counterValue: 'USD', counterValue: 'USD',
@ -17,8 +18,10 @@ const props = {
account: accounts[0], account: accounts[0],
} }
stories.add('basic', () => ( const RequestAmountComp = translate()(RequestAmount)
<RequestAmount
stories.add('RequestAmount', () => (
<RequestAmountComp
{...props} {...props}
t={k => k} t={k => k}
onChange={action('onChange')} onChange={action('onChange')}

4
src/components/base/InputCurrency/stories.js

@ -8,8 +8,8 @@ import { getDefaultUnitByCoinType } from '@ledgerhq/currencies'
import InputCurrency from 'components/base/InputCurrency' import InputCurrency from 'components/base/InputCurrency'
const stories = storiesOf('Components/InputCurrency', module) const stories = storiesOf('Components', module)
const unit = getDefaultUnitByCoinType(1) const unit = getDefaultUnitByCoinType(1)
stories.add('basic', () => <InputCurrency unit={unit} onChange={action('onChange')} />) stories.add('InputCurrency', () => <InputCurrency unit={unit} onChange={action('onChange')} />)

19
src/components/base/Modal/stories.js

@ -1,10 +1,12 @@
// @flow // @flow
import React, { Fragment } from 'react' import React from 'react'
import { storiesOf } from '@storybook/react' import { storiesOf } from '@storybook/react'
import { boolean } from '@storybook/addon-knobs' import { boolean } from '@storybook/addon-knobs'
import { Modal, ModalBody } from 'components/base/Modal' import { Modal, ModalBody, ModalTitle, ModalContent, ModalFooter } from 'components/base/Modal'
import Box from 'components/base/Box'
import Button from 'components/base/Button'
const stories = storiesOf('Components', module) const stories = storiesOf('Components', module)
@ -14,11 +16,14 @@ stories.add('Modal', () => {
<Modal <Modal
isOpened={isOpened} isOpened={isOpened}
render={({ onClose }) => ( render={({ onClose }) => (
<Fragment> <ModalBody onClose={onClose}>
<ModalBody>Hey!</ModalBody> <ModalTitle>{'modal title'}</ModalTitle>
<ModalBody onClose={onClose}>Hoy!</ModalBody> <ModalContent>{'this is the modal content'}</ModalContent>
<ModalBody>Hu!</ModalBody> <ModalFooter horizontal align="center">
</Fragment> <Box grow>{'modal footer'}</Box>
<Button primary>{'Next'}</Button>
</ModalFooter>
</ModalBody>
)} )}
/> />
) )

9
src/styles/global.js

@ -3,11 +3,15 @@
/* eslint-disable no-unused-expressions */ /* eslint-disable no-unused-expressions */
import { injectGlobal } from 'styled-components' import { injectGlobal } from 'styled-components'
import omitBy from 'lodash/omitBy'
import { fontFace } from 'styles/helpers' import { fontFace } from 'styles/helpers'
import { radii, colors } from 'styles/theme' import { radii, colors } from 'styles/theme'
import reset from './reset' import reset from './reset'
const { STORYBOOK_ENV, NODE_ENV } = process.env
const COPYRIGHTED_FONTS = ['Museo Sans']
const fonts = { const fonts = {
'Open Sans': [ 'Open Sans': [
{ {
@ -73,6 +77,11 @@ const fonts = {
} }
function transformFonts(allFonts) { function transformFonts(allFonts) {
allFonts = omitBy(
allFonts,
(_, key: string) =>
NODE_ENV === 'production' && STORYBOOK_ENV && COPYRIGHTED_FONTS.includes(key),
)
return Object.keys(allFonts) return Object.keys(allFonts)
.map(name => { .map(name => {
const fonts = allFonts[name] const fonts = allFonts[name]

Loading…
Cancel
Save