Skip to content
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
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>svideo</title>
<title>zvideo</title>
<link rel="stylesheet" href="/public/style.css">
</head>
<body>
<div id="app"></div>
<script src="public/bundle.js"></script>
<script src="/public/bundle.js"></script>
</body>
</html>
32 changes: 16 additions & 16 deletions js/ClientApp.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import Landing from './Landing';
import Search from './Search';

const ce = React.createElement;
const FourOhFour = () => <h1>404</h1>;

const MyTitle = function(props) {
return ce('div', null, ce('h1', { style: { color: props.color } }, props.title));
};
const App = () => (
<BrowserRouter>
<div className="app">
<Switch>
<Route exact path="/" component={Landing} />
<Route path="/search" component={Search} />
<Route component={FourOhFour} />
</Switch>
</div>
</BrowserRouter>
);

const MyFirstComponent = function() {
return ce(
'div',
{ id: 'my-first-component' },
ce(MyTitle, { title: 'Game of Thrones', color: 'YellowGreen' }),
ce(MyTitle, { title: 'Stranger Things', color: 'GreenYellow' }),
ce(MyTitle, { title: 'Rick and Morty', color: 'LimeGreen' }),
ce(MyTitle, { title: 'House of Cards', color: 'peru' })
);
};

render(ce(MyFirstComponent), document.getElementById('app'));
render(<App />, document.getElementById('app'));
12 changes: 12 additions & 0 deletions js/Landing.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { Link } from 'react-router-dom';

const Landing = () => (
<div className='landing'>
<h1>zvideo</h1>
<input type='text' placeholder='Search' />
<Link to="/search">or Browse All</Link>
</div>
);

export default Landing;
12 changes: 12 additions & 0 deletions js/Search.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import ShowCard from './ShowCard';
import preload from '../data.json';


const Search = () => (
<div className="search">
{preload.shows.map(show => <ShowCard show={show} />) }
</div>
);

export default Search;
14 changes: 14 additions & 0 deletions js/ShowCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'

const ShowCard = props => (
<div className="show-card">
<img alt={`${props.show.title} Show Poster`} src={`/public/img/posters/${props.show.poster}`} />
<div>
<h3>{props.show.title}</h3>
<h4>({props.show.year})</h4>
<p>{props.show.description}</p>
</div>
</div>
);

export default ShowCard;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scripts": {
"api": "node ratingsAPI.js",
"build": "webpack",
"dev": "webpack-dev-server",
"format": "prettier --write --single-quote --print-width=120 --parser=flow --tab-width=2 \"js/**/*.{js,jsx}\"",
"lint": "eslint **/*.{js,jsx} --quiet",
"watch": "webpack --watch"
Expand Down
24 changes: 17 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ module.exports = {
devtool: 'cheap-eval-source-map',
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
filename: 'bundle.js',
},
devServer: {
publicPath: '/public/',
historyApiFallback: true,
},
resolve: {
extensions: ['.js', '.jsx', '.json']
extensions: ['.js', '.jsx', '.json'],
},
stats: {
colors: true,
reasons: true,
chunks: true
chunks: true,
},
module: {
rules: [
{
enforce: 'pre',
test: /\.jsx?$/,
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.jsx?$/,
loader: 'babel-loader'
}
]
}
loader: 'babel-loader',
},
],
},
};