Skip to content

Commit

Permalink
run prettier on EVERYTHING
Browse files Browse the repository at this point in the history
  • Loading branch information
vivshaw committed Aug 7, 2017
1 parent 24e42c8 commit aaa2832
Show file tree
Hide file tree
Showing 19 changed files with 696 additions and 684 deletions.
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "my-reads",
"version": "0.1.0",
"private": true,
"dependencies": {
"enzyme": "^2.9.1",
"jest-fetch-mock": "^1.2.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-scripts": "1.0.10",
"react-test-renderer": "^15.6.1",
"semantic-ui-css": "^2.2.11",
"semantic-ui-react": "^0.71.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!src/registerServiceWorker.js",
"!src/index.js"
]
}
"name": "my-reads",
"version": "0.1.0",
"private": true,
"dependencies": {
"enzyme": "^2.9.1",
"jest-fetch-mock": "^1.2.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-scripts": "1.0.10",
"react-test-renderer": "^15.6.1",
"semantic-ui-css": "^2.2.11",
"semantic-ui-react": "^0.71.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!src/registerServiceWorker.js",
"!src/index.js"
]
}
}
26 changes: 13 additions & 13 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
20 changes: 10 additions & 10 deletions src/common/flowTypes.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @flow

export type BookType = {
id: string,
title: string,
subtitle: string,
authors: Array<string>,
description: string,
shelf: string,
imageLinks: {
thumbnail: string
}
}
id: string,
title: string,
subtitle: string,
authors: Array<string>,
description: string,
shelf: string,
imageLinks: {
thumbnail: string
}
};
74 changes: 37 additions & 37 deletions src/common/testData.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
const testBooks = {
books: [
{
title: "A Book Titled 1",
subtitle: "A Subtitle",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
authors: ["Author One", "Author Two"],
imageLinks: { thumbnail: "cover.gif" },
id: "nggnmAEACAAJ",
shelf: "testShelf"
},
{
title: "Book 2: Electric Boogaloo",
subtitle: "Another Subtitle #2",
description: "Suspendisse facilisis varius sem, ut auctor sem pulvinar sed.",
authors: ["Guy Three", "Guy Four"],
imageLinks: { thumbnail: "pic2.jpg" },
id: "sJf1vQAACAAJ",
shelf: "testShelf"
},
{
title: "3: The Threequel",
subtitle: "The 3rd and Final Subtitle",
description: "Maecenas justo nunc, lobortis et volutpat vel, tempor quis tellus.",
authors: ["Writer Five", "Writer Six"],
imageLinks: { thumbnail: "bookCover.png" },
id: "bKs2xWEECBAL",
shelf: "testShelfTwo"
},
]
}
books: [
{
title: 'A Book Titled 1',
subtitle: 'A Subtitle',
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
authors: ['Author One', 'Author Two'],
imageLinks: { thumbnail: 'cover.gif' },
id: 'nggnmAEACAAJ',
shelf: 'testShelf'
},
{
title: 'Book 2: Electric Boogaloo',
subtitle: 'Another Subtitle #2',
description:
'Suspendisse facilisis varius sem, ut auctor sem pulvinar sed.',
authors: ['Guy Three', 'Guy Four'],
imageLinks: { thumbnail: 'pic2.jpg' },
id: 'sJf1vQAACAAJ',
shelf: 'testShelf'
},
{
title: '3: The Threequel',
subtitle: 'The 3rd and Final Subtitle',
description:
'Maecenas justo nunc, lobortis et volutpat vel, tempor quis tellus.',
authors: ['Writer Five', 'Writer Six'],
imageLinks: { thumbnail: 'bookCover.png' },
id: 'bKs2xWEECBAL',
shelf: 'testShelfTwo'
}
]
};

const jsonHeaders = new Headers(
{
"Accept": "application/json",
"Content-Type": "application/json"
}
);
const jsonHeaders = new Headers({
Accept: 'application/json',
'Content-Type': 'application/json'
});

export { testBooks, jsonHeaders }
export { testBooks, jsonHeaders };
132 changes: 75 additions & 57 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,91 @@ import { Icon, Menu, Segment, Sidebar } from 'semantic-ui-react';
import TopBar from './TopBar.js';
import Shelf from './Shelf';
import { getAll } from '../utils/BooksAPI';
import type { BookType } from '../common/flowTypes'
import type { BookType } from '../common/flowTypes';

class App extends Component {
state = {
filterQuery: '',
menuVisible: false,
shelves: [],
shelvedBooks: {}
}
state = {
filterQuery: '',
menuVisible: false,
shelves: [],
shelvedBooks: {}
};

toggleMenu = () => {
this.setState((state) => ({ menuVisible: !state.menuVisible }))
}
toggleMenu = () => {
this.setState(state => ({ menuVisible: !state.menuVisible }));
};

updateQuery = (query: string) => {
this.setState({ filterQuery: query.trim() });
};
updateQuery = (query: string) => {
this.setState({ filterQuery: query.trim() });
};

clearQuery = () => {
this.setState({ filterQuery: '' });
};
clearQuery = () => {
this.setState({ filterQuery: '' });
};

componentDidMount() {
getAll().then((books: Array<BookType>) => {
const shelves = Array.from(new Set(books.map(book => book.shelf)))
const shelvedBooks = shelves.reduce((map, shelf) => {
map[shelf] = books.filter(book => book.shelf === shelf)
return map
}, {})
this.setState({
shelves,
shelvedBooks
})
})
}
componentDidMount() {
getAll().then((books: Array<BookType>) => {
const shelves = Array.from(new Set(books.map(book => book.shelf)));
const shelvedBooks = shelves.reduce((map, shelf) => {
map[shelf] = books.filter(book => book.shelf === shelf);
return map;
}, {});
this.setState({
shelves,
shelvedBooks
});
});
}

render() {
const {shelves, shelvedBooks} = this.state;
render() {
const { shelves, shelvedBooks } = this.state;

const showingShelves = shelves.filter((shelf: string) => shelvedBooks[shelf]).map(shelf => {
return (
<Shelf
key={shelf+'-id'}
title={shelf}
books={this.state.shelvedBooks[shelf]}
filterQuery={this.state.filterQuery}
clearQuery={this.clearQuery}
/>
)
})
const showingShelves = shelves
.filter((shelf: string) => shelvedBooks[shelf])
.map(shelf => {
return (
<Shelf
key={shelf + '-id'}
title={shelf}
books={this.state.shelvedBooks[shelf]}
filterQuery={this.state.filterQuery}
clearQuery={this.clearQuery}
/>
);
});

return (
<div className="App">
<TopBar filterQuery={this.state.filterQuery} toggleMenu={this.toggleMenu} updateQuery={this.updateQuery} />
return (
<div className="App">
<TopBar
filterQuery={this.state.filterQuery}
toggleMenu={this.toggleMenu}
updateQuery={this.updateQuery}
/>

<Sidebar.Pushable as={Segment} attached="bottom">
<Sidebar width='thin' as={Menu} animation="uncover" visible={this.state.menuVisible} icon="labeled" vertical inverted>
<Menu.Item><Icon name="home" />Home</Menu.Item>
<Menu.Item><Icon name="search" />Search</Menu.Item>
</Sidebar>
<Sidebar.Pusher>
{showingShelves}
</Sidebar.Pusher>
</Sidebar.Pushable>
</div>
);
}
<Sidebar.Pushable as={Segment} attached="bottom">
<Sidebar
width="thin"
as={Menu}
animation="uncover"
visible={this.state.menuVisible}
icon="labeled"
vertical
inverted
>
<Menu.Item>
<Icon name="home" />Home
</Menu.Item>
<Menu.Item>
<Icon name="search" />Search
</Menu.Item>
</Sidebar>
<Sidebar.Pusher>
{showingShelves}
</Sidebar.Pusher>
</Sidebar.Pushable>
</div>
);
}
}

export default App;
57 changes: 28 additions & 29 deletions src/components/Book.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,33 @@
import React from 'react';
import { Card, Image } from 'semantic-ui-react';

const Book = (
props: {
title: string,
subtitle?: string,
description: string,
authors: Array<string>,
coverImageUrl: string
}) => {
return (
<Card>
<Card.Content>
<Image floated='right' size='mini' src={props.coverImageUrl} />
<Card.Header>
{props.title}
</Card.Header>
{props.subtitle &&
<Card.Meta>
{props.subtitle}
</Card.Meta>
}
<Card.Description>
{props.description.substring(0, 140) + "..."}
</Card.Description>
</Card.Content>
<Card.Content extra>
{props.authors.join(', ')}
</Card.Content>
</Card>
)}
const Book = (props: {
title: string,
subtitle?: string,
description: string,
authors: Array<string>,
coverImageUrl: string
}) => {
return (
<Card>
<Card.Content>
<Image floated="right" size="mini" src={props.coverImageUrl} />
<Card.Header>
{props.title}
</Card.Header>
{props.subtitle &&
<Card.Meta>
{props.subtitle}
</Card.Meta>}
<Card.Description>
{props.description.substring(0, 140) + '...'}
</Card.Description>
</Card.Content>
<Card.Content extra>
{props.authors.join(', ')}
</Card.Content>
</Card>
);
};

export default Book;
Loading

0 comments on commit aaa2832

Please sign in to comment.