-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): add component to list storybook stories
- Loading branch information
Raphaël Benitte
committed
Aug 26, 2018
1 parent
b44c854
commit 6b9ce02
Showing
9 changed files
with
134 additions
and
27 deletions.
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
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,44 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import VisitIcon from 'react-icons/lib/md/keyboard-arrow-right' | ||
import config from '../config' | ||
import CollapsibleCard from './CollapsibleCard' | ||
|
||
const buildStoryLink = ({ kind, story }) => | ||
`${config.storybookUrl}?selectedKind=${encodeURIComponent( | ||
kind | ||
)}&selectedStory=${encodeURIComponent(story)}` | ||
|
||
export default class Stories extends Component { | ||
static propTypes = { | ||
stories: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
label: PropTypes.string.isRequired, | ||
link: PropTypes.shape({ | ||
kind: PropTypes.string.isRequired, | ||
story: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}) | ||
), | ||
} | ||
|
||
render() { | ||
const { stories } = this.props | ||
|
||
return ( | ||
<CollapsibleCard title="Demos" expandedByDefault={true}> | ||
{stories.map((story, i) => ( | ||
<a | ||
key={i} | ||
className="stories__item" | ||
href={buildStoryLink(story.link)} | ||
target="_blank" | ||
> | ||
{story.label} | ||
<VisitIcon size={20} color="#bbb" /> | ||
</a> | ||
))} | ||
</CollapsibleCard> | ||
) | ||
} | ||
} |
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,44 @@ | ||
export const barStories = [ | ||
{ | ||
label: 'Using markers', | ||
link: { | ||
kind: 'Bar', | ||
story: 'with marker', | ||
}, | ||
}, | ||
{ | ||
label: 'Stacked diverging bar chart', | ||
link: { | ||
kind: 'Bar', | ||
story: 'diverging stacked', | ||
}, | ||
}, | ||
{ | ||
label: 'Grouped diverging bar chart', | ||
link: { | ||
kind: 'Bar', | ||
story: 'diverging grouped', | ||
}, | ||
}, | ||
{ | ||
label: 'Custom bar element', | ||
link: { | ||
kind: 'Bar', | ||
story: 'custom bar item', | ||
}, | ||
}, | ||
{ | ||
label: 'Formatting values', | ||
link: { | ||
kind: 'Bar', | ||
story: 'with formatted values', | ||
}, | ||
}, | ||
{ | ||
label: 'Using custom tooltip', | ||
link: { | ||
kind: 'Bar', | ||
story: 'custom tooltip', | ||
}, | ||
}, | ||
] |
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,16 @@ | ||
export const bubbleStories = [ | ||
{ | ||
label: 'Using formatted values', | ||
link: { | ||
kind: 'Bubble', | ||
story: 'with formatted values', | ||
}, | ||
}, | ||
{ | ||
label: 'Using custom tooltip', | ||
link: { | ||
kind: 'Bubble', | ||
story: 'custom tooltip', | ||
}, | ||
}, | ||
] |
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
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,15 @@ | ||
.stories__item { | ||
padding: 12px 24px; | ||
border-top: 1px solid #e2e5e6; | ||
font-size: 14px; | ||
line-height: 1.6em; | ||
cursor: pointer; | ||
text-decoration: none; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.stories__item:hover { | ||
background: #f7fafb; | ||
} |