Skip to content

Commit

Permalink
fix(Storybook): ts fixes for storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jan 20, 2020
1 parent c7ac200 commit e75bb2b
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json']
},
module: {
rules: [
{
Expand All @@ -7,7 +10,8 @@ module.exports = {
query: {
name: 'static/media/[name].[hash:8].[ext]'
}
}
},
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import styled from 'styled-components'

import { Color } from '../../Colors'
import { Color } from '../../Colors/index.ts'
import { Icon } from '../../Icons'

const Wrapper = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components'

import { Icon } from '../../Icons'
import { keysIn } from 'ramda'
import { Palette } from '../../Colors'
import { Palette } from '../../Colors/index.ts'

const Wrapper = styled.div`
display: inline-flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components'

import { Icon } from '../../Icons'
import { keysIn } from 'ramda'
import { Palette } from '../../Colors'
import { Palette } from '../../Colors/index.ts'

const Wrapper = styled.div`
display: inline-flex;
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-info-components/src/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Cookies from 'universal-cookie'
import React, { PureComponent } from 'react'
import styled, { createGlobalStyle } from 'styled-components'

import { Color } from '../Colors'
import { Color } from '../Colors/index.ts'
import { Image } from '../Images'
import { Select } from './Select'
import Link from '../Navigation/Link'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from '../Colors'
import { Color } from '../Colors/index.ts'
import { Icon } from '../Icons'
import PropTypes from 'prop-types'
import React from 'react'
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-info-components/src/Links/Link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { keysIn } from 'ramda'
import { Palette } from '../Colors'
import { Palette } from '../Colors/index.ts'
import PropTypes from 'prop-types'
import React from 'react'
import styled from 'styled-components'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import styled, { css, keyframes } from 'styled-components'

import { Palette } from '../Colors'
import { Palette } from '../Colors/index.ts'

const stretchFrames = keyframes`
0%, 40%, 100% { opacity: 1; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import styled, { css, keyframes } from 'styled-components'

import { Palette } from '../Colors'
import { Palette } from '../Colors/index.ts'

const stretchFrames = keyframes`
0%, 40%, 100% { transform: scaleY(0.4); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import styled, { css, keyframes } from 'styled-components'

import { Palette } from '../Colors'
import { Palette } from '../Colors/index.ts'

const bounceFrames = keyframes`
0%, 100% { transform: scale(0.0); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from '../../Colors'
import { Color } from '../../Colors/index.ts'
import { trackButtonEvent } from '../Events'
import Link from '../Link'
import React from 'react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from '../Colors'
import { Color } from '../Colors/index.ts'
import { FormattedMessage, IntlProvider } from 'react-intl'
import { Image } from '../Images'
import { trackEvent } from './Events'
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-info-components/src/Normalize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/necolas/normalize.css
//
import { Color } from './Colors'
import { Color } from './Colors/index.ts'

const Normalize8 = `
/*! normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-info-components/src/Themes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Palette } from '../Colors'
import { Palette } from '../Colors/index.ts'
import { ThemeProvider } from 'styled-components'
import PropTypes from 'prop-types'
import React from 'react'
Expand Down
49 changes: 31 additions & 18 deletions packages/blockchain-info-components/stories/chapters/colors.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import styled from 'styled-components'
import { storiesOf } from '@storybook/react'

import { keysIn } from 'ramda'
import { Palette } from '../../src/Colors/index.ts'
import { storiesOf } from '@storybook/react'
import Layout from '../components/layout'
import { Palette } from '../../src/Colors'
import React from 'react'
import styled from 'styled-components'

const ColorLayout = styled.div`
display: flex;
Expand Down Expand Up @@ -32,20 +31,20 @@ const Code = styled.div`
display: block;
width: 100%;
height: 50px;
border: 1px solid #CDCDCD;
border: 1px solid #cdcdcd;
box-sizing: border-box;
font-size: 16px;
font-weight: 500;
text-align: center;
`

const PaletteLayout = (props) => {
const PaletteLayout = props => {
const palette = Palette(props.theme)
const keys = keysIn(palette)

return (
<ColorLayout>
{ keys.map(function (key, index) {
{keys.map(function (key, index) {
return (
<Container key={index}>
<Sample bgColor={palette[key]} />
Expand All @@ -67,18 +66,20 @@ const ColorGridRow = styled.tr`
flex-direction: row;
justify-content: center;
align-items: center;
border-top: 1px solid #EFEFEF;
border-bottom: 1px ${props => props.last ? 'solid' : 'none'} #EFEFEF;
border-top: 1px solid #efefef;
border-bottom: 1px ${props => (props.last ? 'solid' : 'none')} #efefef;
`
const ColorGridCell = styled.td`
flex-basis: 20%;
font-size: 18px;
text-transform: uppercase;
text-align: center;
border-left: 1px solid #EFEFEF;
border-right: 1px ${props => props.last ? 'solid' : 'none'} #EFEFEF;
background-color: ${props => props.color ? props.color : 'white'};
&:first-child { flex-basis: 40%; }
border-left: 1px solid #efefef;
border-right: 1px ${props => (props.last ? 'solid' : 'none')} #efefef;
background-color: ${props => (props.color ? props.color : 'white')};
&:first-child {
flex-basis: 40%;
}
`

const PaletteGrid = props => {
Expand All @@ -90,13 +91,25 @@ const PaletteGrid = props => {
<ColorGridBody>
<ColorGridRow>
<ColorGridCell>&nbsp;</ColorGridCell>
{themes.map((theme, index) => <ColorGridCell key={index} last={index === themes.length - 1}>{theme}</ColorGridCell>) }
{themes.map((theme, index) => (
<ColorGridCell key={index} last={index === themes.length - 1}>
{theme}
</ColorGridCell>
))}
</ColorGridRow>
{ keys.map((key, indexRow) => {
{keys.map((key, indexRow) => {
return (
<ColorGridRow key={indexRow} last={indexRow === keys.length - 1}>
<ColorGridCell>{key}</ColorGridCell>
{themes.map((theme, indexCell) => <ColorGridCell key={indexCell} last={indexCell === themes.length - 1} color={Palette(theme)[key]}>&nbsp;</ColorGridCell>) }
{themes.map((theme, indexCell) => (
<ColorGridCell
key={indexCell}
last={indexCell === themes.length - 1}
color={Palette(theme)[key]}
>
&nbsp;
</ColorGridCell>
))}
</ColorGridRow>
)
})}
Expand All @@ -106,7 +119,7 @@ const PaletteGrid = props => {
}

storiesOf('Colors', module)
.addDecorator(story => (<Layout>{story()}</Layout>))
.addDecorator(story => <Layout>{story()}</Layout>)
.add('All colors', () => <PaletteGrid />)
.add('Theme Default', () => <PaletteLayout theme='default' />)
.add('Theme Complement', () => <PaletteLayout theme='complement' />)
Expand Down
18 changes: 12 additions & 6 deletions packages/blockchain-info-components/stories/chapters/icons.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Icon, IconGlobalStyles } from '../../src'
import { keysIn } from 'ramda'
import { storiesOf } from '@storybook/react'
import { withInfo } from '@storybook/addon-info'
import React from 'react'
import styled from 'styled-components'

import { Icon } from '../../src'
import { keysIn } from 'ramda'
import IcomoonMap from '../../src/Icons/Icomoon'
import Layout from '../components/layout'
import React from 'react'
import styled from 'styled-components'

const IconWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -62,7 +61,14 @@ const IconLayout = props => {
const iconKeys = keysIn(IcomoonMap)

storiesOf('Icons', module)
.addDecorator(story => <Layout>{story()}</Layout>)
.addDecorator(story => (
<Layout>
<>
{story()}
<IconGlobalStyles />
</>
</Layout>
))
.addDecorator((story, context) =>
withInfo({ text: 'Documentation', inline: true })(story)(context)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import React from 'react'
import styled, { ThemeProvider } from 'styled-components'

import { Color, Palette } from '../../src/Colors/index.ts'
import { SimpleDropdown } from '../../src/Dropdowns'
import { Color, Palette } from '../../src/Colors'

const BasePage = styled.div`
font-family: -apple-system, '.SFNSText-Regular', 'San Francisco', Roboto,
Expand Down

0 comments on commit e75bb2b

Please sign in to comment.