Skip to content

Commit

Permalink
Updates to DOM-I
Browse files Browse the repository at this point in the history
- New DOM assignment created
- Old assignment moved to stretch
  • Loading branch information
BigKnell committed Apr 23, 2018
1 parent 23994e1 commit fb22e9d
Show file tree
Hide file tree
Showing 14 changed files with 610 additions and 39 deletions.
67 changes: 28 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
# DOM I

Topics:
* Interacting with the DOM
* Selectors
* selectElementsByClassname
* selectElementbyId
* querySelector
* querySelectorAll
* NodeList
* HTMLCollection

## Objectives
* Manipulate the DOM using JavaScript
* Choose selectors for a given problem
* Work with the object the different selectors return

## Beginning Project
* You'll be working in the `digital_timer` directory
* Add your script tag into you index.html
* You can open your `index.html` file in your browser to see your work, but you may also work in codepen.io first if you'd like
* All your work will be done in `index.js`
* Make sure to read both the `index.html` and `styles.css` files so that you know what you're working with
* Organization of your code in `index.js` will be up to you. There will be suggestions provided later in the day
# DOM I - JavaScript Content Management System

## Project Description
You will be making a timer that:
* Counts up to 10 seconds
* Increments every 10 ms
* Has digits change to red when it gets to 10 seconds
* Should not count past 10 seconds

You will also need to look up and use `window.setInterval`. For this method, and any of those listed in the "Topics" section of this README, you are encouraged to use MDN as your resource for Documentation. MDN can be challenging to consume at first, so you may also use something like W3schools if the MDN documentation on a given subject is a bit too complicated.

## Stretch Goals
If you compelete the timer with time to spare:
* Self study and research DOM `events` and `event listeners`
* SG1: Implement a start button. The digital timer should not start until the button is pressed.
* SG2: Once you have a start button working, configure it so that when a user presses the start button it is disabled and not enabled until the timer finishes.
* SG3: Once you have finished SG2, add new new button called `reset` that resets the timer to 0:00:00 and then pressing the start button again will start the timer from 0.
* SG4: Finally, if you have completed all the stretch goals, spend some time styling your timer and buttons.
You are going to be emulating a content managment system by controlling the content in the JavaScript file instead of the HTML file. This project is an excercise pointed at selecting elements and then updating them without touching the HTML file using the DOM.

You have been provided a [JSON object](js/index.js) with all the necessary data to accomplish this task. Use dot or bracket notation to traverse the data provided.

## ONE RULE
* You cannot update the HTML or CSS files directly. You must use JavaScript and the DOM only for your tasks today.

## Task 1: Create selectors to point your data into elements
* Create selectors by using any of the DOM element's methods
* Note that IDs have been used on all images. Use the IDs to update src path content

## Task 2: Update the HTML with the JSON data
* Remember, NO direct updating of the HTML is allowed.
* Using your selectors, update the content to match the example file.
* Remember to update the src attributes on images

## Task 3: Add new content
* Change the color of the navigation text to be green.
* Utilize `.appendChild()` and `.prepend()` to add two new items to the navigation system. You can call them whatever you want.
* Check your work by looking at the [original html](original.html) in the browser

## Stretch Goals
* Update styles throughout the page as you see fit. Study what happens when you updated the DOM using style in JavaScript.
* Study tomorrow's lesson on events and try to integrate a button that can update content on the site with a click of a button. You could build a similar data object with new values to help you test the click event.

## Stretch Project
This project is heavier on logic but employs some DOM manipulation to achieve it's goals. Go check it out here: [stretch assignment](stretch-assignment) and see how far you can get.
299 changes: 299 additions & 0 deletions css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

/* Set every element's box-sizing to border-box */
* {
box-sizing: border-box;
}

html, body {
height: 100%;
font-family: 'Titillium Web', sans-serif;
}

h1, h2, h3, h4, h5 {
font-family: 'Bangers', cursive;
letter-spacing: 1px;
margin-bottom: 15px;
}

.container {
width: 880px;
margin: auto;
}

/* Header Styles */

header {
width: 100%;
display: flex;
}

header nav {
margin-top: 40px;
width: 610px;
justify-content: space-between;
display: flex;
}

header nav a {
text-decoration: none;
color: #b0b0b0;
}

header nav a:hover {
text-decoration: underline;
color: black;
}

header .logo {
align-self: flex-end;
margin: 28px 0 0 91px;
}

/* Call To Action (CTA) Styles */

.cta {
display: flex;
margin-top: 72px;
justify-content: flex-end;
}

.cta .cta-text {
font-size: 72px;
text-align: center;
letter-spacing: 5px;
display: flex;
justify-content: center;
flex-flow: column;
align-items: center;
margin: 0 82px 0 0;
}

.cta .cta-text button {
border: 1px double black;
font-size: 16px;
background: white;
width: 170px;
height: 32px;
margin-top: 10px;
cursor: pointer;
}

.cta .cta-text button:hover {
background: black;
color: white;
}

/* Main Content Styles */

.main-content {
border-top: 2px solid black;
border-bottom: 2px solid black;
margin: 75px 0 35px 0;
padding: 35px 0;
font-size: 16px;
line-height: 18px;
}

.main-content .top-content {
display: flex;
justify-content: space-around;
}

.main-content .middle-img {
display: block;
margin: 30px auto;
}

.main-content .bottom-content {
display: flex;
justify-content: space-around;
}

.main-content .bottom-content p {
padding-right: 20px;
}

/* Contact Styles */

.contact p {
margin: 15px 0;
}

/* Footer Styles */

footer {
text-align: center;
margin: 40px 0 20px;
}

/* Tablet */
@media (max-width: 768px) {

.container {
width: 768px;
}

header {
flex-wrap: wrap;
}

header nav {
width: 768px;
padding: 0 30px;
}

header .logo {
order: -1;
display: block;
margin: 30px auto 0;
}

.cta {
justify-content: center;
}

.cta .cta-text {
margin: 0;
}

.cta img {
display: none;
}

.main-content .middle-img {
width: 100%;
}

.main-content {
margin: 75px 20px 35px;
}

.text-content {
margin: 0 10px;
}

.contact {
margin: 0 30px;
}
}

/* Phone */
@media (max-width: 400px) {

.container {
width: 400px;
}

header {
flex-wrap: wrap;
justify-content: center;
}

header nav {
width: 100%;
display: flex;
flex-direction: column;
margin: 0;
align-items: center;
padding: 0;
}

header nav a {
width: 100%;
display: block;
text-align: center;
padding: 20px 0;
font-size: 20px;
border-bottom: 1px solid gray;
}

header nav a:first-child {
border-top: 1px solid gray;
}

header nav a:hover {
background: gray;
}

header .logo {
margin: 20px 0;
}

.cta {
margin-top: 50px;
flex-flow: column;
align-items: center;
}

.cta img {
max-width: 80%;
}

.main-content .top-content {
justify-content: space-around;
flex-direction: column;
height: 300px;
}

.main-content .bottom-content {
flex-wrap: wrap;
align-content: space-between;
height: 440px;
}

.text-content {
margin: 0;
}

.contact {
margin: 20px;
}
}
Binary file added design-files/desktop-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/header-img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/mid-page-accent.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fb22e9d

Please sign in to comment.