mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Merge branch 'master' of github.com:kenotron/bootcamp
This commit is contained in:
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
BIN
assets/todo_screenshot.jpg
Normal file
BIN
assets/todo_screenshot.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="./fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
|
||||
10
index.html
10
index.html
@@ -16,22 +16,16 @@
|
||||
<h2>Day 1</h2>
|
||||
Setup, HTML, CSS, Javascript and Intro to React
|
||||
</li>
|
||||
<li class="Tile">
|
||||
<a target="_blank" href="./step1-00/" class="Tile-link">
|
||||
Step 0 <br />
|
||||
HTML/CSS/JS
|
||||
</a>
|
||||
</li>
|
||||
<li class="Tile">
|
||||
<a target="_blank" href="./step1-01/" class="Tile-link">
|
||||
Step 1 <br />
|
||||
Todo HTML
|
||||
HTML/CSS/JS
|
||||
</a>
|
||||
</li>
|
||||
<li class="Tile">
|
||||
<a target="_blank" href="./step1-02/" class="Tile-link">
|
||||
Step 2 <br />
|
||||
Todo CSS
|
||||
Todo HTML & CSS
|
||||
</a>
|
||||
</li>
|
||||
<li class="Tile">
|
||||
|
||||
29
package-lock.json
generated
29
package-lock.json
generated
@@ -3600,7 +3600,8 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@@ -3621,12 +3622,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -3641,17 +3644,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -3768,7 +3774,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -3780,6 +3787,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -3794,6 +3802,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@@ -3801,7 +3810,8 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
@@ -3905,7 +3915,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -4038,6 +4049,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@@ -4057,6 +4069,7 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../assets/shared.css" />
|
||||
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.1/css/fabric.min.css" />
|
||||
</head>
|
||||
|
||||
<body class="ms-Fabric">
|
||||
<div class="Container">
|
||||
<ul class="Tiles">
|
||||
<li class="Tile"><a href="./html-demo/html-demo.html" class="Tile-link">HTML Demo</a></li>
|
||||
<li class="Tile"><a href="./css-demo/css-demo.html" class="Tile-link">CSS Demo</a></li>
|
||||
<li class="Tile"><a href="./css-demo/css-demo-finished.html" class="Tile-link">CSS Demo Finished</a></li>
|
||||
<li class="Tile"><a href="./js-demo/js-demo.html" class="Tile-link">JS Demo</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
23
step1-01/README.md
Normal file
23
step1-01/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## How the Web Works
|
||||
|
||||
A simple web page is rendered on the screen via the following steps
|
||||
|
||||
> There are many sub steps in this process
|
||||
> but these are the highlights
|
||||
|
||||
1. You instruct the browser which webpage you'd like to see
|
||||
2. The browser looks up the site in a 'DNS Server'
|
||||
- This is like a big phone book for website server addresses
|
||||
3. The browser asks the server to send over a specific page of the website `developer.mozilla.org/filename.html` or `developer.mozilla.org`
|
||||
- If asked for a 'root' level address, most servers will return `'root'/index.html`
|
||||
4. The server sends the HTML file back to the browser
|
||||
5. The browser starts to read the HTML file from the top to the bottom, \*stopping any time that additional resources are required
|
||||
- CSS stylesheets
|
||||
- JavaScript files
|
||||
- Fonts
|
||||
- Images
|
||||
6. Browser makes requests for additional resources
|
||||
- Those resources might request even more files
|
||||
7. Once the browser gets to the bottom of the page it can start rendering, and then load the page
|
||||
|
||||

|
||||
127
step1-01/css-demo/README.md
Normal file
127
step1-01/css-demo/README.md
Normal file
@@ -0,0 +1,127 @@
|
||||
## CSS Demo
|
||||
|
||||
### CSS Properties
|
||||
|
||||
Now that we've gone over adding HTML tags to the page, lets cover adding styles to those tags. We can do quite a lot with styles! We can change:
|
||||
|
||||
- Typography
|
||||
- Colors
|
||||
- Appearance (Corners, Borders, Decorations)
|
||||
- Layout
|
||||
- Position
|
||||
- Inline vs Block
|
||||
- Animations
|
||||
- and [many more](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference)
|
||||
|
||||
CSS is always applied in `property: value` pairs, like `background: blue;` and are terminated with a semi colon.
|
||||
|
||||
### Applying CSS to an HTML file
|
||||
|
||||
CSS can be applied to HTML tags in three different ways.
|
||||
|
||||
1. Inline - Styles are applied directly to the HTML tag
|
||||
|
||||
- `<div style="background: blue; color: white;">Hello </div>`
|
||||
|
||||
2. Via a `<style>` tag in the HTML page
|
||||
3. Through an externally loaded CSS file
|
||||
|
||||
- `<link rel="stylesheet" href="./css-demo-finished.css" />`
|
||||
|
||||
### Targeting specific HTML tags
|
||||
|
||||
Inline styles are always applied directly to the element you place them on, style tags and external CSS files need a method for matching HTML elements with their prospective style sets. We call these "selectors", and they are just as important to learn as the properties/values themselves. Below are a series of selectors and property/value combinations that we'll apply to our CSS Demo page
|
||||
|
||||
```css
|
||||
/* Targeting the entire page */
|
||||
body {
|
||||
font: 1.2em sans-serif;
|
||||
}
|
||||
|
||||
/* Targeting an HTML tag */
|
||||
h1 {
|
||||
/* Color name */
|
||||
color: black;
|
||||
|
||||
/* 6 digit hex */
|
||||
background: #ababab;
|
||||
|
||||
/* Margin: property for each side */
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
|
||||
/* Shorthand: Padding applies to all sides */
|
||||
padding: 10px;
|
||||
|
||||
/* 3 digit hex and border shorthand */
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* Overriding inherited styles */
|
||||
span {
|
||||
color: #004578;
|
||||
}
|
||||
|
||||
/* Targeting a class name */
|
||||
.tiles {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Decendant selector */
|
||||
.tiles img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Direct decendant selector */
|
||||
.tiles > div {
|
||||
/* rgb colors */
|
||||
background: rgb(10, 10, 10);
|
||||
color: white;
|
||||
flex-basis: 100%;
|
||||
/* Longhand goes clockwise from top
|
||||
10px - all
|
||||
10px 20px - top/bottom left/right
|
||||
10px 20px 15px - top left/right bottom
|
||||
*/
|
||||
padding: 10px 20px 15px;
|
||||
margin: 10px 20px 10px 0;
|
||||
}
|
||||
|
||||
/* Qualified selector */
|
||||
div.links {
|
||||
background: #004578;
|
||||
}
|
||||
|
||||
/* Style inheritance only works for unstyled elements */
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Pseudo hover selector */
|
||||
a:hover {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
/* Sibling selectors */
|
||||
a ~ a {
|
||||
/* Changing elements from inline to block */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Positional Pseudo Selectors */
|
||||
.tiles > div:last-child {
|
||||
/* overrides margin-right but leaves other margins alone */
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* ID selector */
|
||||
#contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Attribute selector */
|
||||
input[type='submit'] {
|
||||
margin-top: 10px;
|
||||
}
|
||||
```
|
||||
@@ -1,5 +1,4 @@
|
||||
/* https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Combinators_and_multiple_selectors */
|
||||
|
||||
/* Targeting an HTML tag */
|
||||
body {
|
||||
font: 1.2em sans-serif;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="./fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
63
step1-01/css-demo/css-demo.css
Normal file
63
step1-01/css-demo/css-demo.css
Normal file
@@ -0,0 +1,63 @@
|
||||
/* https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Combinators_and_multiple_selectors */
|
||||
|
||||
/* body {
|
||||
font: 1.2em sans-serif;
|
||||
} */
|
||||
|
||||
/* h1 {
|
||||
color: black;
|
||||
background: #ababab;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
} */
|
||||
|
||||
/* span {
|
||||
color: #004578;
|
||||
} */
|
||||
|
||||
/* .tiles {
|
||||
display: flex;
|
||||
} */
|
||||
|
||||
/* .tiles img {
|
||||
width: 100%;
|
||||
} */
|
||||
|
||||
/* .tiles > div {
|
||||
background: rgb(10, 10, 10);
|
||||
color: white;
|
||||
flex-basis: 100%;
|
||||
padding: 10px 20px 15px;
|
||||
margin: 10px 20px 10px 0;
|
||||
} */
|
||||
|
||||
/* div.links {
|
||||
background: #004578;
|
||||
} */
|
||||
|
||||
/* a {
|
||||
color: white;
|
||||
} */
|
||||
|
||||
/* a:hover {
|
||||
color: #ccc;
|
||||
} */
|
||||
|
||||
/* a ~ a {
|
||||
display: block;
|
||||
} */
|
||||
|
||||
/* .tiles > div:last-child {
|
||||
margin-right: 0;
|
||||
} */
|
||||
|
||||
/* #contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
} */
|
||||
|
||||
/* input[type='submit'] {
|
||||
margin-top: 10px;
|
||||
} */
|
||||
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
71
step1-01/html-demo/README.md
Normal file
71
step1-01/html-demo/README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
## HTML Demo
|
||||
|
||||
The [HTML demo page](http://localhost:8080/step1-00/html-demo/html-demo.html) is a large collection of HTML elements that you will come across during development. The full list of elements can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element).
|
||||
|
||||
To learn more about each element, click on the elements below.
|
||||
|
||||
### [Document Meta Data](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Document_metadata)
|
||||
|
||||
- [html](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html) - Root level element
|
||||
- [head](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head) - Provides general information (meta-data) about the page
|
||||
- [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title) - Defines document title shown via browser tab
|
||||
- [link](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) - Links to external resource (usually stylesheets)
|
||||
- [style](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style) - Inline style tag
|
||||
|
||||
### [Content Sectioning](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Content_sectioning)
|
||||
|
||||
- [section](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section) - Generic section of content
|
||||
- [header](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header) - Introductory content or navigational aid
|
||||
- [footer](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer) - Footer for nearest sectioning element
|
||||
- [main](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main) - Dominent content
|
||||
- [nav](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav) - Navigational aid
|
||||
- [article](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article) - Syndicated content
|
||||
- [aside](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside) - Related information
|
||||
- [h1,h2,h3,h4,h5,h6](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements) - Section headings
|
||||
|
||||
### [Block Text Content](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Text_content)
|
||||
|
||||
- [div](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div) - A generic block level container
|
||||
- [p](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p) - A paragraph
|
||||
- [ol](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol) - Ordered list (1,2,3)
|
||||
- [ul](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul) - Unordered list
|
||||
- [li](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li) - List item
|
||||
- [pre](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre) - Preformatted text
|
||||
|
||||
### [Inline Text Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Inline_text_semantics)
|
||||
|
||||
- [a](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) - Anchor element for creating links to other pages, files, email
|
||||
- [span](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span) - Generic inline container
|
||||
- [b](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b) - Bring attention to content
|
||||
- [em](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em) - Stress emphasis
|
||||
- [i](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i) - Range of text set off from normal text
|
||||
- [sub](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub) - Subscript text
|
||||
- [sup](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup) - Superscript text
|
||||
- [code](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code) - Fragment of computer code (monospace)
|
||||
|
||||
### [Image and multimedia](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Inline_text_semantics)
|
||||
|
||||
- [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) - Embeds image into document
|
||||
|
||||
### [Table Content](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Table_content)
|
||||
|
||||
- [table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) - Root table container
|
||||
- [thead](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead) - Table head container
|
||||
- [tr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr) - Table row
|
||||
- [th](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) - Table head cell
|
||||
- [tbody](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody) - Table body container
|
||||
- [td](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) - Normal table cell
|
||||
|
||||
### [Forms](https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Forms)
|
||||
|
||||
- [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) - Form container
|
||||
- [label](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label) - Label text for form elements
|
||||
- [select](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select) - A dropdown container
|
||||
- [option](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option) - Dropdown elements
|
||||
- [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) - A form field to collect various inputs. Types include:
|
||||
- text
|
||||
- checkbox
|
||||
- color
|
||||
- date
|
||||
- radio
|
||||
- submit
|
||||
@@ -126,6 +126,10 @@
|
||||
|
||||
<h3>Inline style tags</h3>
|
||||
<p><b>b tag</b> <em>em tag</em> <i>i tag</i> <sub>sub tag</sub> <sup>sup tab</sup> <code>code tag</code></p>
|
||||
|
||||
<div>
|
||||
<img src="../../assets/fabric.jpg" width="100" />
|
||||
</div>
|
||||
</section>
|
||||
<hr />
|
||||
<section>
|
||||
@@ -1,27 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>todos</h1>
|
||||
<div><input placeholder="add todo" /><button>Add</button></div>
|
||||
<div>
|
||||
<button>all</button>
|
||||
<button>active</button>
|
||||
<button>completed</button>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../assets/shared.css" />
|
||||
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.1/css/fabric.min.css" />
|
||||
</head>
|
||||
|
||||
<body class="ms-Fabric">
|
||||
<div class="Container">
|
||||
<ul class="Tiles">
|
||||
<li class="Tile"><a href="./html-demo/html-demo.html" class="Tile-link">HTML Demo</a></li>
|
||||
<li class="Tile"><a href="./css-demo/css-demo.html" class="Tile-link">CSS Demo</a></li>
|
||||
<li class="Tile"><a href="./css-demo/css-demo-finished.html" class="Tile-link">CSS Demo Finished</a></li>
|
||||
<li class="Tile"><a href="./js-demo/js-demo.html" class="Tile-link">JS Demo</a></li>
|
||||
<li class="Tile"><a href="./js-demo/js-demo-finished.html" class="Tile-link">JS Demo Finished</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<label><input type="checkbox" /> Todo 1</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input type="checkbox" /> Todo 2</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input type="checkbox" /> Todo 3</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input type="checkbox" /> Todo 4</label>
|
||||
</li>
|
||||
</ul>
|
||||
<div><span>4 items left</span> <button>Clear Completed</button></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
116
step1-01/js-demo/README.md
Normal file
116
step1-01/js-demo/README.md
Normal file
@@ -0,0 +1,116 @@
|
||||
## JavaScript Demo
|
||||
|
||||
It's entirely possible to create a website with nothing but HTML and CSS, but as soon as you want user interaction other than links and forms, you'll need to reach for JavaScript, the scripting language of the web. Fortunately, JavaScript has grown up quite a bit since it was introduced in the 90s, and now runs just about everything: web applications, mobile applications, native applications, servers, robots and rocket ships.
|
||||
|
||||
In this demo we are going to cover a few of the core basics of the language that will help us when we start writing our TODO app. At the end of this demo we will be able to display the number of the letter 'a's in our email input.
|
||||
|
||||
We'll be covering:
|
||||
|
||||
- Variables
|
||||
- Functions
|
||||
- Conditionals
|
||||
- Loops
|
||||
- Interacting with the DOM (Document Object Model)
|
||||
|
||||
### Variables
|
||||
|
||||
Javascript is a loosly typed language. We can create a new variable with the keywords `var, let, const` and use them within our application. These variables can contain one of the following types of values:
|
||||
|
||||
1. boolean
|
||||
2. number
|
||||
3. string
|
||||
4. array
|
||||
5. object
|
||||
|
||||
Because they are not strongly typed, we can switch a varible from a number, to a string, to an array anytime we want to. In practice, this is a bit of an anti-pattern, as it makes debugging and refactoring extremely difficult. This is why we write just about every project in [Typescript](https://www.typescriptlang.org/).
|
||||
|
||||
Lets start off our demo by adding some variables to our [script tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
||||
|
||||
```js
|
||||
const match = 'a';
|
||||
let matches = 0;
|
||||
```
|
||||
|
||||
### Functions
|
||||
|
||||
Functions are resuable pieces of functionality. Functions can take inputs (parameters), and return values. Functions can be called from within your program, from within other functions, or invoked from within the DOM itself.
|
||||
|
||||
In our example we'll create a function called displayMatches (camelCase is typical for functions) and we'll invoke this function anytime that our submit button is clicked. For now we'll simply call a console log (a function that prints values to the browser console);
|
||||
|
||||
```html
|
||||
<input onclick="displayMatches()" class="submit" value="Submit" type="submit" />
|
||||
```
|
||||
|
||||
```js
|
||||
function displayMatches() {
|
||||
console.log("I'm Clicked");
|
||||
}
|
||||
```
|
||||
|
||||
### Iteration
|
||||
|
||||
Next up we are going to iterate through a string of text, and find all of the 'a' characters in the list. We don't yet have that string, so we'll use a fill in for now. Once we have our `email` variable we can loop over it with the [`for of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loop syntax.
|
||||
|
||||
```js
|
||||
function displayMatches() {
|
||||
const text = 'abcda';
|
||||
for (let letter of text) {
|
||||
console.log(letter);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Conditionals
|
||||
|
||||
Next we want to compare each `letter` with our `match` value, and if they are the same, we will increment our matches variable. Notice that `match` is a const and `matches` is a let because we expected `matches` to change over time. Remember that `letter = match` would set the `letter` variable to the value in `match`, so we use `==`, equality operator, and `===` strict equality operator, to make these comparisons.
|
||||
|
||||
> ("1" == 1) is true whereas ("1" === 1) would be false
|
||||
|
||||
```js
|
||||
function displayMatches() {
|
||||
const text = 'abcda';
|
||||
for (let letter of text) {
|
||||
if (letter === match) {
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
console.log(matches);
|
||||
}
|
||||
```
|
||||
|
||||
### Interacting with the DOM
|
||||
|
||||
Now that we have a function performing all of our logic, it's time to connect this to our DOM by using some of the browsers built in functions.
|
||||
|
||||
First we need to get a reference to the email field in our app. To do this, I've added an `id` to the input, and we will call one of JavaScripts oldest methods (IE 5.5), getElementyId, which we find on the browser provided `document` global variable. This function will return a reference to that input, and we can store it in the `email` variable.
|
||||
|
||||
```js
|
||||
const email = document.getElementById('email');
|
||||
console.log(email);
|
||||
```
|
||||
|
||||
And since what we're actually after is the "value" of the input field, we can set our `text` variable to the string assigned to the "value" key. To see this in action. Right click on the console message created by the code above, choose "save as variable" and then type `variableName.value`.
|
||||
|
||||
```js
|
||||
const text = email.value;
|
||||
```
|
||||
|
||||
#### Returning the values to the DOM
|
||||
|
||||
Now that we've read values from the DOM, and fed that into our matching logic, we are ready to return that number to our app. To do this we first need to grab a reference to our submit button, and since this button has no `id` we are going to use the more modern (IE8) `querySelector` to get it. This function takes any valid CSS selector and returns the first found match.
|
||||
|
||||
```js
|
||||
const submit = document.querySelector('.submit');
|
||||
```
|
||||
|
||||
Now that we have a reference to the submit input, we can set its value to a new value.
|
||||
|
||||
```js
|
||||
submit.value = matches + ' matches';
|
||||
```
|
||||
|
||||
If you are curious, we could have done this in a single line by chaining these methods and keys together:
|
||||
|
||||
```js
|
||||
document.querySelector('.submit').value = matches + ' matches';
|
||||
```
|
||||
@@ -1,5 +1,7 @@
|
||||
<html>
|
||||
<head> </head>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../css-demo/css-demo-finished.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>This is my <span>Title</span></h1>
|
||||
@@ -12,12 +14,12 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
<div id="contact-form">
|
||||
<label>Email</label><input class="email" type="email" />
|
||||
<label>Email</label><input id="email" type="email" />
|
||||
<input onclick="displayMatches()" class="submit" value="Submit" type="submit" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,13 +31,15 @@
|
||||
let matches = 0;
|
||||
|
||||
function displayMatches() {
|
||||
const text = document.querySelector('.email').value;
|
||||
const email = document.getElementById('email');
|
||||
const text = email.value;
|
||||
for (let letter of text) {
|
||||
if (letter === match) {
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
document.querySelector('.submit').value = matches + ' matches';
|
||||
const submit = document.querySelector('.submit');
|
||||
submit.value = matches + ' matches';
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
30
step1-01/js-demo/js-demo.html
Normal file
30
step1-01/js-demo/js-demo.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../css-demo/css-demo-finished.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>This is my <span>Title</span></h1>
|
||||
<div class="tiles">
|
||||
<div class="links">
|
||||
<h2>Important Links</h2>
|
||||
<a href="#">We're Awesome</a>
|
||||
<a href="#">Learn More</a>
|
||||
<a href="#">Hire Us</a>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
<div id="contact-form">
|
||||
<label>Email</label><input class="email" type="email" />
|
||||
<input class="submit" value="Submit" type="submit" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script></script>
|
||||
</html>
|
||||
9
step1-02/README.md
Normal file
9
step1-02/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## HTML and CSS
|
||||
|
||||
## Demo
|
||||
|
||||
Scaffold out page
|
||||
|
||||
## Exercise
|
||||
|
||||
Add and style footer
|
||||
34
step1-02/finished/index.html
Normal file
34
step1-02/finished/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>todos</h1>
|
||||
<div class="addTodo"><input class="textfield" placeholder="add todo" /><button class="submit">Add</button></div>
|
||||
<nav class="filter">
|
||||
<button class="active">all</button>
|
||||
<button>active</button>
|
||||
<button>completed</button>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<ul class="todos">
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 1 </span> </label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 2 </span> </label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 3 </span> </label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 4 </span> </label>
|
||||
</li>
|
||||
</ul>
|
||||
</main>
|
||||
<footer><span>4 items left</span> <button class="submit">Clear Completed</button></footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,21 +1,23 @@
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
width: 400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addTodo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.textfield {
|
||||
width: 80%;
|
||||
flex-grow: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.add {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
.button {
|
||||
.submit {
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ h1 {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter .active {
|
||||
border-bottom: 2px solid blue;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
<body>
|
||||
<h1>todos</h1>
|
||||
<input class="textfield" placeholder="add todo" /><button class="button add">Add</button>
|
||||
<div class="filter">
|
||||
<button class="active">all</button>
|
||||
<button>active</button>
|
||||
<button>completed</button>
|
||||
</div>
|
||||
<ul class="todos">
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 1</label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 2</label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 3</label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 4</label>
|
||||
</li>
|
||||
</ul>
|
||||
<footer><span>4 items left</span> <button class="button">Clear Completed</button></footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
18
step1-03/README.md
Normal file
18
step1-03/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
Demo
|
||||
|
||||
already done
|
||||
|
||||
- addTodo
|
||||
- filter
|
||||
- filter()
|
||||
- getTodoText
|
||||
|
||||
Walk through 'addTodo'
|
||||
attach addTodo to button
|
||||
write clearInput/add to addTodo
|
||||
write updateRemaining
|
||||
|
||||
## Exercise
|
||||
|
||||
write clearCompleted
|
||||
add to footer button
|
||||
@@ -1,29 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
<head>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>todos</h1>
|
||||
<input class="textfield" placeholder="add todo" />
|
||||
<button onclick="addTodo()" class="button add">
|
||||
Add
|
||||
</button>
|
||||
<div class="filter">
|
||||
<button onclick="filter('all', this)" class="active">all</button>
|
||||
<button onclick="filter('active', this)">active</button>
|
||||
<button onclick="filter('completed', this)">completed</button>
|
||||
</div>
|
||||
<header>
|
||||
<h1>todos</h1>
|
||||
<div class="addTodo">
|
||||
<input class="textfield" placeholder="add todo" />
|
||||
<button onclick="addTodo()" class="submit add">Add</button>
|
||||
</div>
|
||||
<nav class="filter">
|
||||
<button onclick="filter('all', this)" class="active">all</button>
|
||||
<button onclick="filter('active', this)">active</button>
|
||||
<button onclick="filter('completed', this)">completed</button>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<ul class="todos">
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 1</label>
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 1 </span></label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 2</label>
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 2 </span></label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 3</label>
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 3 </span></label>
|
||||
</li>
|
||||
<li class="todo">
|
||||
<label><input type="checkbox" /> Todo 4</label>
|
||||
<label><input type="checkbox" /> <span class="title"> Todo 4 </span></label>
|
||||
</li>
|
||||
</ul>
|
||||
<footer>
|
||||
@@ -33,13 +38,12 @@
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function getValue(selector) {
|
||||
const inputValue = document.querySelector(selector).value;
|
||||
return inputValue;
|
||||
function getTodoText() {
|
||||
return document.querySelector('.textfield').value;
|
||||
}
|
||||
|
||||
function clearInput(selector) {
|
||||
document.querySelector(selector).value = '';
|
||||
function clearInput() {
|
||||
document.querySelector('.textfield').value = '';
|
||||
}
|
||||
|
||||
function updateRemaining() {
|
||||
@@ -50,11 +54,11 @@
|
||||
|
||||
function addTodo() {
|
||||
const todo = document.querySelector('.todo');
|
||||
const newTodo = todo.cloneNode();
|
||||
newTodo.innerHTML = `<label><input type="checkbox" /> ${getValue('.textfield')}</label>`;
|
||||
const newTodo = todo.cloneNode(true);
|
||||
newTodo.querySelector('.title').innerText = getTodoText();
|
||||
todo.parentElement.insertBefore(newTodo, todo);
|
||||
|
||||
clearInput('.textfield');
|
||||
clearInput();
|
||||
updateRemaining();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
width: 400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addTodo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.textfield {
|
||||
width: 80%;
|
||||
flex-grow: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.add {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
.button {
|
||||
.submit {
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ h1 {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter .active {
|
||||
border-bottom: 2px solid blue;
|
||||
}
|
||||
@@ -44,7 +47,3 @@ footer {
|
||||
footer span {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
7
step1-05/README.md
Normal file
7
step1-05/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
demo
|
||||
Header
|
||||
ListItem
|
||||
|
||||
exercise
|
||||
Footer
|
||||
List
|
||||
@@ -3,16 +3,14 @@ import { TodoFooter } from './components/TodoFooter';
|
||||
import { TodoHeader } from './components/TodoHeader';
|
||||
import { TodoList } from './components/TodoList';
|
||||
|
||||
|
||||
export class TodoApp extends React.Component {
|
||||
render() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<TodoHeader />
|
||||
<TodoList />
|
||||
<TodoFooter />
|
||||
</div>
|
||||
<div>
|
||||
<TodoHeader />
|
||||
<TodoList />
|
||||
<TodoFooter />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
|
||||
export const TodoFooter = (props: any) => {
|
||||
|
||||
return (
|
||||
<footer>
|
||||
<span>
|
||||
<span className="remaining">4</span> items left
|
||||
</span>
|
||||
<button className="button">Clear Completed</button>
|
||||
<button className="submit">Clear Completed</button>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,16 +3,18 @@ import React from 'react';
|
||||
export class TodoHeader extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<header>
|
||||
<h1>todos</h1>
|
||||
<input className="textfield" placeholder="add todo" />
|
||||
<button className="button add">Add</button>
|
||||
<div className="filter">
|
||||
<div className="addTodo">
|
||||
<input className="textfield" placeholder="add todo" />
|
||||
<button className="submit">Add</button>
|
||||
</div>
|
||||
<nav className="filter">
|
||||
<button className="active">all</button>
|
||||
<button>active</button>
|
||||
<button>completed</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ import { TodoListItem } from './TodoListItem';
|
||||
|
||||
export class TodoList extends React.Component<any, any> {
|
||||
render() {
|
||||
const { filter, todos } = this.props;
|
||||
|
||||
return (
|
||||
<ul className="todos">
|
||||
<TodoListItem/>
|
||||
<TodoListItem/>
|
||||
<TodoListItem/>
|
||||
<TodoListItem/>
|
||||
<TodoListItem />
|
||||
<TodoListItem />
|
||||
<TodoListItem />
|
||||
<TodoListItem />
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
width: 400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addTodo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.textfield {
|
||||
width: 80%;
|
||||
flex-grow: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.add {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
.button {
|
||||
.submit {
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ h1 {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter .active {
|
||||
border-bottom: 2px solid blue;
|
||||
}
|
||||
@@ -44,7 +47,3 @@ footer {
|
||||
footer span {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
12
step1-06/README.md
Normal file
12
step1-06/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
already done
|
||||
itemCount filtering
|
||||
|
||||
demo
|
||||
|
||||
add state
|
||||
pass to header and list
|
||||
add filter class stuff
|
||||
|
||||
exercise
|
||||
update footer to include todos
|
||||
add item count and item(s)
|
||||
@@ -7,7 +7,7 @@ export const TodoFooter = (props: any) => {
|
||||
<span>
|
||||
{itemCount} item{itemCount > 1 ? 's' : ''} left
|
||||
</span>
|
||||
<button className="button">Clear Completed</button>
|
||||
<button className="submit">Clear Completed</button>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,17 +3,20 @@ import React from 'react';
|
||||
export class TodoHeader extends React.Component<any, any> {
|
||||
render() {
|
||||
const { filter } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<header>
|
||||
<h1>todos</h1>
|
||||
<input className="textfield" placeholder="add todo" />
|
||||
<button className="button add">Add</button>
|
||||
<div className="filter">
|
||||
<div className="addTodo">
|
||||
<input className="textfield" placeholder="add todo" />
|
||||
<button className="submit">Add</button>
|
||||
</div>
|
||||
<nav className="filter">
|
||||
<button className={filter == 'all' ? 'active' : ''}>all</button>
|
||||
<button className={filter == 'active' ? 'active' : ''}>active</button>
|
||||
<button className={filter == 'completed' ? 'active' : ''}>completed</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
width: 400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addTodo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.textfield {
|
||||
width: 80%;
|
||||
flex-grow: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.add {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
.button {
|
||||
.submit {
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ h1 {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter .active {
|
||||
border-bottom: 2px solid blue;
|
||||
}
|
||||
@@ -44,7 +47,3 @@ footer {
|
||||
footer span {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export const TodoFooter = (props: TodoFooterProps) => {
|
||||
<span>
|
||||
{itemCount} item{itemCount > 1 ? 's' : ''} left
|
||||
</span>
|
||||
<button onClick={() => props.clear()} className="button">
|
||||
<button onClick={() => props.clear()} className="submit">
|
||||
Clear Completed
|
||||
</button>
|
||||
</footer>
|
||||
|
||||
@@ -16,13 +16,15 @@ export class TodoHeader extends React.Component<TodoHeaderProps, any> {
|
||||
render() {
|
||||
const { filter, setFilter } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<header>
|
||||
<h1>todos</h1>
|
||||
<input value={this.state.labelInput} onChange={this._onChange} className="textfield" placeholder="add todo" />
|
||||
<button onClick={this._onAdd} className="button add">
|
||||
Add
|
||||
</button>
|
||||
<div className="filter">
|
||||
<div className="addTodo">
|
||||
<input value={this.state.labelInput} onChange={this._onChange} className="textfield" placeholder="add todo" />
|
||||
<button onClick={this._onAdd} className="submit">
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
<nav className="filter">
|
||||
<button onClick={() => setFilter('all')} className={filter == 'all' ? 'active' : ''}>
|
||||
all
|
||||
</button>
|
||||
@@ -32,8 +34,8 @@ export class TodoHeader extends React.Component<TodoHeaderProps, any> {
|
||||
<button onClick={() => setFilter('completed')} className={filter == 'completed' ? 'active' : ''}>
|
||||
completed
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
width: 400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.addTodo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.textfield {
|
||||
width: 80%;
|
||||
flex-grow: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.add {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
.button {
|
||||
.submit {
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ h1 {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter .active {
|
||||
border-bottom: 2px solid blue;
|
||||
}
|
||||
@@ -44,7 +47,3 @@ footer {
|
||||
footer span {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
Reference in New Issue
Block a user