Skip to content

Commit

Permalink
feat(first_screen): First Screen added
Browse files Browse the repository at this point in the history
Closed #142
  • Loading branch information
artdaw committed Dec 18, 2018
1 parent 55447a2 commit 1ce3825
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 45 deletions.
2 changes: 1 addition & 1 deletion sandbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm start
## Run local development environment

```bash
npm run dev
UNSPLASH_APP_ID=[ID] UNSPLASH_APP_SECRET=[SECRET] npm run dev npm run dev
```

## Run production environment
Expand Down
3 changes: 2 additions & 1 deletion sandbox/next.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
distDir: "dist",
useFileSystemPublicRoutes: true,
publicRuntimeConfig: {
API_URL: process.env.API_URL || "http://localhost:3000"
UNSPLASH_APP_ID: process.env.UNSPLASH_APP_ID || "",
UNSPLASH_APP_SECRET: process.env.UNSPLASH_APP_SECRET || ""
}
};
35 changes: 35 additions & 0 deletions sandbox/package-lock.json

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

1 change: 1 addition & 0 deletions sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"sanitize-html": "1.19.3",
"semantic-ui-less": "2.4.1",
"semantic-ui-react": "0.83.0",
"unsplash-js": "^4.8.0",
"wretch": "1.4.2"
},
"devDependencies": {
Expand Down
110 changes: 68 additions & 42 deletions sandbox/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,81 @@
import React, { Component } from "react";
import Router from "next/router";
// import getConfig from "next/config";
// import Unsplash from "unsplash-js";
import { Container, Header, Divider, Card } from "semantic-ui-react";

export interface IImage {
url: string;
export interface IUnsplashImage {
raw: string;
full: string;
small: string;
thumb: string;
}

export interface IMainPage {
onImageSelect: (imageUrl: string) => void;
images: Array<IImage>;
images: Array<IUnsplashImage>;
}

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"
}
];
// TODO: add Unsplash support
// const {
// publicRuntimeConfig: { UNSPLASH_APP_ID, UNSPLASH_APP_SECRET }
// } = getConfig();

return { images };
// const unsplash = new Unsplash({
// applicationId: UNSPLASH_APP_ID,
// secret: UNSPLASH_APP_SECRET
// });

// try {
// const imagesRequest = await unsplash.search.photos("fashion", 1, 72);
// const jsonImages = await imagesRequest.json();
// const images = jsonImages.results
// .filter(({ width, height }) => height > width)
// .map(({ urls }) => urls);
// return { images };
// } catch (e) {
// console.log(e);
// return { images: [] };
// }

return {
images: [
{
small:
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544868501-b2f493d76e35?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
{
small:
"https://images.unsplash.com/photo-1544617724-2d30b41f5d05?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
}
]
};
}

render() {
Expand All @@ -62,11 +88,11 @@ class MainPage extends Component<IMainPage> {
</Header>
<Divider hidden />
<Card.Group itemsPerRow={4}>
{images.map(({ url }) => (
{images.map(({ small }) => (
<Card
image={url}
image={small}
onClick={() => {
onImageSelect(url);
onImageSelect(small);
Router.push("/artboard");
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion sandbox/ui-components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IMenu {
const PageMenu: React.SFC<IMenu> = ({ logoSrc }) => (
<Menu fixed="top" inverted>
<Container>
<Menu.Item as="a" header>
<Menu.Item as="a" href="/" header>
<Image size="mini" src={logoSrc} alt="Skrop Logo" />
</Menu.Item>
<Menu.Item as="a" href="/">
Expand Down

0 comments on commit 1ce3825

Please sign in to comment.