-
Go to github and create a new repo. DO NOT click any additional details!
-
Follow the directions provided on github to create the project locally, add remote and push your first commit.
-
IF YOU DO NOT GET THE INSTRUCTIONS you clicked extra stuff!!! it gets the hose again
-
We want to set up a new project here so we'll run
npm init -y
inside the project -
Create a blank HTML5 scaffald index.html in folder 'dist' and app.js in folder 'src'
-
Add a single script tag to your index.html
<script src="./app.bundle.js"></script>
-
npm install jquery bootstrap babel-core babel-loader babel-preset-es2015 sass-loader node-sass webpack css-loader style-loader -D
-
Copy the webpack.config.js from slack or the repo into the root of our application. Pretty please.
-
You'll need this added to your web pack:
devServer: {
contentBase: "./dist"
},
- And your scripts in your package.json needs to have the following:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"watch": "webpack --watch",
"start": "webpack-dev-server --open"
},
- Add a
.gitignore
and add the following lines
/node_modules
/dist
- Probably gonna need
npm install -D file-loader
for bootstrap fonts loaded from file...maybe - update our webpack with file-loader module
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
loader: "file-loader"
}
- add a style.scss to your src folder with the following
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
$halloween-background-color: #f07c05;
$text-color: #faf7f7;
body {
background: $halloween-background-color;
color: $text-color;
}
- Add nav and navbar stuff to index.html
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#nav1">Halloween Wobble Site</a>
</div>
<ul class="nav navbar-nav">
<li class="active navShows">
<a href="#nav1">Meow Shows</a>
</li>
<li class="active navSurprise">
<a href="#nav2">Surprise</a>
</li>
</ul>
</div>
</nav>
- Now you can run your dev server, but first we need to install it
npm install -D webpack-dev-server
. And make sure that our npm scripts for start is correct.
"start": "webpack-dev-server --open"
-
Create a fetch request, wrapped in function. and handle the resolve or reject from the fetch call. Console.log out the payload in json so we know that it's working, or failing. :-(
const movieURL = "https://api.themoviedb.org/3/genre/27/movies?api_key=2434d246ec60c162a86db597467ef4ed&language=en-US&include_adult=false&sort_by=created_at.asc"
-
Now we want to loop over the results of each movie and create a div element, append an image element to it with the poster url, and finally append that create element to the class div 'movies' that is also our bootstrap row.
-
Sweet!!! Images!!! but why are then off set ? :-( Here we want to leverage column resets Bootstrap Docs by applying a column reset at responsive breakpoints, we get them to align correctly. Double Sweet.
-
Ok. I think we've had it for the day.
-
Now we've got our movies up, and showing thumbnail and title as a class caption. Rad. Looks good in md-col, but what about xsm, sm, and lg. So let's fix that!
-
Adding in release data and description, and a call to action button for details
-
We added col for xs, sm, and lg. This includes clearfix for 2 col layout aka sm/xs.
-
Modify our webpack. Rad
//webpack config
//....
{ test: /bootstrap\/dist\/js\/umd\//, loader: "imports?jQuery=jquery" }
]
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
- Update our index with a modal class attr. See Index below
<!--Modal in Action -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal Content HERE -->
<div class="modal-content">
<!-- modal header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Movie Details!!!!</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
<p>Movies Details Here!!!!</p>
</div>
<!-- Modal FOOTER -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- End of Modal Content -->
</div>
</div>
- Event listener in js. To open our modal on click of said button.
// ---> Event Listeners
$("#myBtn").click(function() {
$("#myModal").modal();
});
- Now that you have a modal working. Rad. Good job. We want to fetch the data for each poster individually. Below is the APIURL you'll need to get the details of a specific movie
//Note the Movie Id needs to be concated before you can fetch!!!!
https://api.themoviedb.org/3/movie/<MOVIE-ID>?api_key=2434d246ec60c162a86db597467ef4ed
- You can attach a click event directly on an element as it is created. Sadly you can't attach an event listener on an element before it's appended to the DOM.
.click(function() {
console.log(movie.id);
//
})