This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#95): added stories for async components
- Loading branch information
Andreas Gasser
committed
Mar 28, 2019
1 parent
6714780
commit 3be717a
Showing
5 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
|
||
import AsyncContainer from './AsyncContainer'; | ||
import { Colors } from '../../styles'; | ||
|
||
import { baseName, sharedKnobs } from './async.stories'; | ||
|
||
const Styles = { | ||
Background: styled.div` | ||
background-color: ${Colors.ColorsPalette.White}; | ||
padding: 3rem; | ||
`, | ||
}; | ||
|
||
storiesOf(`${baseName}/AsyncContainer`) | ||
.add('default', () => (<Styles.Background> | ||
<AsyncContainer loading={sharedKnobs.getLoading()}> | ||
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p> | ||
</AsyncContainer> | ||
</Styles.Background>)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
import { boolean } from '@storybook/addon-knobs'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
import AsyncImage from './AsyncImage'; | ||
|
||
import { baseName, sharedKnobs } from './async.stories'; | ||
|
||
storiesOf(`${baseName}/AsyncImage`) | ||
.add('default', () => ( | ||
<AsyncImage | ||
src={sharedKnobs.getImage()[0]} | ||
onLoad={action('onLoad')} | ||
/> | ||
)) | ||
.add('with never hide img enabled', () => ( | ||
<AsyncImage | ||
src={sharedKnobs.getImage()[0]} | ||
onLoad={action('onLoad')} | ||
neverHideImg={boolean('neverHideImg', true)} | ||
/> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
import { color } from '@storybook/addon-knobs'; | ||
|
||
import LoadingIndicator from './LoadingIndicator'; | ||
import { Colors } from '../../styles'; | ||
|
||
import { baseName, sharedKnobs } from './async.stories'; | ||
|
||
storiesOf(`${baseName}/LoadingIndicator`, module) | ||
.add('default', () => ( | ||
<LoadingIndicator | ||
size={sharedKnobs.getSize()} | ||
color={{ | ||
light: color('Light color', Colors.Blue.Light), | ||
default: color('Default color', Colors.Blue.Default), | ||
dark: color('Dark color', Colors.Blue.Dark), | ||
}} | ||
/> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { boolean, files, number } from '@storybook/addon-knobs'; | ||
|
||
export const baseName = 'Async'; | ||
|
||
export const sharedKnobs = { | ||
getLoading: () => boolean('Loading', true), | ||
getImage: () => files('Src (image)', 'image/*', []), | ||
getSize: () => number('Size', 100), | ||
}; |