diff --git a/package.json b/package.json index 7ad7ff6..0297a04 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "author": "Matúš Námešný", "license": "ISC", "dependencies": { + "axios": "^0.17.0", "babel-cli": "^6.24.1", "babel-polyfill": "^6.7.4", "babel-runtime": "^6.6.1", diff --git a/src/api.js b/src/api.js index e69de29..c801328 100644 --- a/src/api.js +++ b/src/api.js @@ -0,0 +1,7 @@ +module.exports = function(app) { + app.get('/api/blog', ((req, res) => { + res.json({ + "blog": "Blog hello" + }); + })); +} diff --git a/src/components/App.js b/src/components/App.js index 8147e2f..2c76682 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,13 +1,14 @@ import React from 'react'; import { Route, Switch } from 'react-router-dom'; -import { Home, About, Blog, Portfolio, Resume, NotFoundPage } from '.'; +import { Home, About, Portfolio, Resume, NotFoundPage } from '.'; +import { BlogContainer } from '../containers'; export const App = () => (
- + diff --git a/src/components/Blog.js b/src/components/Blog.js index 1cc24b1..b71082b 100644 --- a/src/components/Blog.js +++ b/src/components/Blog.js @@ -1,9 +1,9 @@ import React from 'react'; -export const Blog = () => ( +export const Blog = (props) => (
-

Blog

+

{ props.data.isLoading ? 'Loading...' : 'Blog' }

); diff --git a/src/containers/BlogContainer.js b/src/containers/BlogContainer.js new file mode 100644 index 0000000..0726834 --- /dev/null +++ b/src/containers/BlogContainer.js @@ -0,0 +1,28 @@ +import React, {Component} from 'react'; +import axios from 'axios'; +import {Blog} from '../components'; + +export default class BlogContainer extends Component { + + constructor() { + super(); + + this.state = { + isLoading: true, + } + } + + componentDidMount() { + axios.get('/api/blog').then((res) => { + this.setState({ + isLoading: false, + }); + }) + } + + render() { + return ( + + ) + } +} diff --git a/src/containers/index.js b/src/containers/index.js new file mode 100644 index 0000000..70c9683 --- /dev/null +++ b/src/containers/index.js @@ -0,0 +1 @@ +export { default as BlogContainer } from './BlogContainer'; diff --git a/src/server.js b/src/server.js index 52efc6b..79adac4 100644 --- a/src/server.js +++ b/src/server.js @@ -28,8 +28,10 @@ if (process.env.NODE_ENV === 'development') { app.use(require('express').static('public')) -var serverRender = require('./serverRender') +var api = require('./api'); +api(app); +var serverRender = require('./serverRender') app.get("*", serverRender) app.listen(port, function(error) { diff --git a/src/static/stylesheets/main.scss b/src/static/stylesheets/main.scss index c1f772c..de79a6f 100644 --- a/src/static/stylesheets/main.scss +++ b/src/static/stylesheets/main.scss @@ -19,9 +19,9 @@ $break-large: 1200px; left: 0; color: $white; transition-property: width; - transition-duration: 1s; + transition-duration: 0.75s; -webkit-transition-property: width; - -webkit-transition-duration: 1s; + -webkit-transition-duration: 0.75s; } #cover-page.cover-page-full{ diff --git a/yarn.lock b/yarn.lock index 292b486..d0de726 100644 --- a/yarn.lock +++ b/yarn.lock @@ -202,6 +202,13 @@ aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" +axios@^0.17.0: + version "0.17.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.17.0.tgz#7da747916db803f761651d6091d708789b953c6a" + dependencies: + follow-redirects "^1.2.3" + is-buffer "^1.1.5" + babel-cli@^6.24.1: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" @@ -1542,7 +1549,7 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debug@2.6.9, debug@^2.2.0, debug@^2.6.8: +debug@2.6.9, debug@^2.2.0, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -1844,6 +1851,12 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" +follow-redirects@^1.2.3: + version "1.2.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.5.tgz#ffd3e14cbdd5eaa72f61b6368c1f68516c2a26cc" + dependencies: + debug "^2.6.9" + for-in@^0.1.3: version "0.1.8" resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1"