Skip to content

- add Storybook #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 8-mui-setup
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
9 changes: 9 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */

import { configure } from '@storybook/react';

function loadStories() {
require('../stories');
}

configure(loadStories, module);
17 changes: 3 additions & 14 deletions components/City.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { createFragmentContainer, graphql } from 'react-relay';
import Typography from 'material-ui/Typography';
import List, { ListItem, ListItemText } from 'material-ui/List';

const styles = {
subItem: {
marginLeft: '10px'
}
marginLeft: '10px',
},
};

const City = ({ data }) => {
export default ({ data }) => {
if (!data) return null;
return (
<List>
Expand All @@ -21,13 +20,3 @@ const City = ({ data }) => {
</List>
);
};

export default createFragmentContainer(
City,
graphql`
fragment City on LocationArea {
name
slug
}
`
);
16 changes: 1 addition & 15 deletions components/Location.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createFragmentContainer, graphql } from 'react-relay';
import Card, { CardActions, CardContent } from 'material-ui/Card';
import Typography from 'material-ui/Typography';
import Button from 'material-ui/Button';
import City from './City';

const Location = ({ data }) => {
export default ({ data }) => {
return (
<Card key={data.locationId}>
<CardContent>
Expand All @@ -25,16 +24,3 @@ const Location = ({ data }) => {
</Card>
);
};

export default createFragmentContainer(
Location,
graphql`
fragment Location on Location {
locationId
name
city {
...City
}
}
`
);
20 changes: 13 additions & 7 deletions components/LocationsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import Location from './Location';
const styles = {
header: {
textAlign: 'center',
padding: '10px 0 5px 0'
padding: '10px 0 5px 0',
},
container: {
margin: '100px auto 0 auto',
maxWidth: 400
maxWidth: 400,
},
list: {
width: '100%'
}
width: '100%',
},
};

const LocationsList = ({ data }) => {
console.log(JSON.stringify(data));
return (
<div style={styles.container}>
<div style={styles.header}>
Expand All @@ -34,7 +35,7 @@ const LocationsList = ({ data }) => {
<div className={styles.list}>
<List>
{data.allLocations.edges.map(({ node, cursor }) =>
<Location data={node} key={cursor} />
<Location data={node} key={cursor} />,
)}
</List>
</div>
Expand All @@ -50,10 +51,15 @@ export default createFragmentContainer(
edges {
cursor
node {
...Location
locationId
name
city {
slug
name
}
}
}
}
}
`
`,
);
28 changes: 10 additions & 18 deletions components/__generated__/AppQuery.graphql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions components/__generated__/City.graphql.js

This file was deleted.

59 changes: 0 additions & 59 deletions components/__generated__/Location.graphql.js

This file was deleted.

49 changes: 45 additions & 4 deletions components/__generated__/LocationsList.graphql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-jss": "^7.0.2",
"react-relay": "^1.1.0"
"react-relay": "^1.1.0",
"react-storybooks-relay-container": "^1.2.1"
},
"devDependencies": {
"@storybook/react": "^3.2.3",
"babel-plugin-relay": "^1.1.0",
"relay-compiler": "^1.1.0"
},
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"relay": "relay-compiler --src ./components --schema ./schema.json"
"relay": "relay-compiler --src ./components --schema ./schema.json",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
}
}
Loading