-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unsplash): First screen with mocked data added
Related to #142
- Loading branch information
Showing
1 changed file
with
73 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,80 @@ | ||
import React from "react"; | ||
import React, { Component } from "react"; | ||
import Router from "next/router"; | ||
import { Container, Header, Button } from "semantic-ui-react"; | ||
import { Container, Header, Divider, Card } from "semantic-ui-react"; | ||
|
||
export interface IImage { | ||
url: string; | ||
} | ||
|
||
export interface IMainPage { | ||
onImageSelect: (imageUrl: string) => void; | ||
images: Array<IImage>; | ||
} | ||
|
||
const MainPage: React.SFC<IMainPage> = ({ onImageSelect }) => ( | ||
<div> | ||
<Container> | ||
<Header as="h1" textAlign="center"> | ||
Select Image | ||
</Header> | ||
<Button | ||
onClick={() => { | ||
onImageSelect( | ||
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
); | ||
Router.push("/artboard"); | ||
}} | ||
primary | ||
> | ||
Simulate Image Select | ||
</Button> | ||
</Container> | ||
</div> | ||
); | ||
class MainPage extends Component<IMainPage> { | ||
static async getInitialProps() { | ||
// TODO API call to Unsplash here | ||
const images = [ | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
}, | ||
{ | ||
url: | ||
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" | ||
} | ||
]; | ||
|
||
return { images }; | ||
} | ||
|
||
render() { | ||
const { onImageSelect, images } = this.props; | ||
return ( | ||
<div> | ||
<Container> | ||
<Header as="h1" textAlign="center"> | ||
Select Image | ||
</Header> | ||
<Divider hidden /> | ||
<Card.Group itemsPerRow={4}> | ||
{images.map(({ url }) => ( | ||
<Card | ||
image={url} | ||
onClick={() => { | ||
onImageSelect(url); | ||
Router.push("/artboard"); | ||
}} | ||
/> | ||
))} | ||
</Card.Group> | ||
</Container> | ||
</div> | ||
); | ||
} | ||
} | ||
export default MainPage; |