diff --git a/assets/flux.png b/assets/flux.png index bf48f6f..8ca6934 100644 Binary files a/assets/flux.png and b/assets/flux.png differ diff --git a/assets/todo-components.png b/assets/todo-components.png new file mode 100644 index 0000000..4b3ff26 Binary files /dev/null and b/assets/todo-components.png differ diff --git a/index.html b/index.html index 6fbe1cc..f19aa5c 100644 --- a/index.html +++ b/index.html @@ -16,26 +16,27 @@
${highlighted}`;
- };
- marked.setOptions({ renderer });
-
- if (div) {
- const response = await fetch(div.dataset['src'] || '../README.md');
- const markdownText = await response.text();
- div.innerHTML = marked(markdownText, { baseUrl: '../' });
- restoreScroll(div);
-
- div.addEventListener('scroll', evt => {
- saveScroll(div);
- });
-
- window.addEventListener('resize', evt => {
- saveScroll(div);
- });
- }
-}
-
-const scrollKey = `${window.location.pathname}_scrolltop`;
-
-function saveScroll(div) {
- window.localStorage.setItem(scrollKey, String(div.scrollTop));
-}
-
-function restoreScroll(div) {
- const scrollTop = window.localStorage.getItem(scrollKey);
- if (scrollTop) {
- div.scrollTop = parseInt(scrollTop);
- }
-}
-
-run();
diff --git a/package-lock.json b/package-lock.json
index fc22f36..5e52d08 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8363,25 +8363,25 @@
}
},
"react": {
- "version": "16.7.0",
- "resolved": "https://registry.npmjs.org/react/-/react-16.7.0.tgz",
- "integrity": "sha512-StCz3QY8lxTb5cl2HJxjwLFOXPIFQp+p+hxQfc8WE0QiLfCtIlKj8/+5tjjKm8uSTlAW+fCPaavGFS06V9Ar3A==",
+ "version": "16.8.3",
+ "resolved": "https://registry.npmjs.org/react/-/react-16.8.3.tgz",
+ "integrity": "sha512-3UoSIsEq8yTJuSu0luO1QQWYbgGEILm+eJl2QN/VLDi7hL+EN18M3q3oVZwmVzzBJ3DkM7RMdRwBmZZ+b4IzSA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
- "scheduler": "^0.12.0"
+ "scheduler": "^0.13.3"
}
},
"react-dom": {
- "version": "16.7.0",
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.7.0.tgz",
- "integrity": "sha512-D0Ufv1ExCAmF38P2Uh1lwpminZFRXEINJe53zRAbm4KPwSyd6DY/uDoS0Blj9jvPpn1+wivKpZYc8aAAN/nAkg==",
+ "version": "16.8.3",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.8.3.tgz",
+ "integrity": "sha512-ttMem9yJL4/lpItZAQ2NTFAbV7frotHk5DZEHXUOws2rMmrsvh1Na7ThGT0dTzUIl6pqTOi5tYREfL8AEna3lA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
- "scheduler": "^0.12.0"
+ "scheduler": "^0.13.3"
}
},
"react-is": {
@@ -8888,9 +8888,9 @@
"dev": true
},
"scheduler": {
- "version": "0.12.0",
- "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.12.0.tgz",
- "integrity": "sha512-t7MBR28Akcp4Jm+QoR63XgAi9YgCUmgvDHqf5otgAj4QvdoBE4ImCX0ffehefePPG+aitiYHp0g/mW6s4Tp+dw==",
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.13.3.tgz",
+ "integrity": "sha512-UxN5QRYWtpR1egNWzJcVLk8jlegxAugswQc984lD3kU7NuobsO37/sRfbpTdBjtnD5TBNFA2Q2oLV5+UmPSmEQ==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
diff --git a/package.json b/package.json
index d290100..6accdc7 100644
--- a/package.json
+++ b/package.json
@@ -63,8 +63,8 @@
"live-server": "^1.2.1",
"marked": "^0.6.1",
"office-ui-fabric-react": "^6.144.0",
- "react": "^16.7.0",
- "react-dom": "^16.7.0",
+ "react": "^16.8.3",
+ "react-dom": "^16.8.3",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.8",
diff --git a/step1-01/exercise/README.md b/step1-01/exercise/README.md
index 34d6476..c69176e 100644
--- a/step1-01/exercise/README.md
+++ b/step1-01/exercise/README.md
@@ -1,49 +1 @@
-# Step 1 Exercise
-
-The power of HTML is its ability to represent complex information in a way that conveys meaning. In this exercise you are going to be creating an HTML page for my favorite recipe.
-
-## The Exercise
-
-1. Create a recipe page to host our recipe (page title, headings, sections, paragraphs, lists etc)
-2. Use title, header, main, footer, headings (h1/h2 etc), paragraphs, lists
-3. Use ordered and unordered lists appropriately
-4. Add the `baked_beans.jpg` iagine included in this folder
-5. Add an anchor tag around 'Wisconsin Beer Brats'
-
-## 4th of July Baked Beans
-
-It's great how a single meal can take you back dozens of years. This is one of those recipes that never seems to fail to impress.
-
-I learned this recipe for the cousin of one of my college friends back in Nashville Tenessee. We had an amazing 4th of July feast which included this recipe and some bratworst like these Wisconsin Beer Brats https://www.culinaryhill.com/wisconsin-beer-brats/
-
-Prep Time: 10 minutes
-Cook time: 3+ hours
-Servings: 12
-
-**Ingredients**
-1LB Bacon chopped
-3 Cans Bush's Origin Baked Beans
-1 Walla Wall Onion chopped
-2 ground garlic cloves
-3 Tablespoons of mustard
-2 Tablespoons of molasses
-3 Tablespoons of brown sugar
-
-**Directions**
-Cook bacon until it is mostly cooked, then drain most of the grease and put aside
-Cook onion in remaining bacon grease
-Combine onions and bacon, then add garlic, cook for a few more minutes
-Add beans and get up to simmer temperate
-Add mustard until your beans are nice and yellow
-Add molassas until color darkens again
-Add brown sugar until properly sweet
-Simmer for a long time, occassionally sturing
-
-**Expert Tipes**
-Burning off most of the liquid gives you nice, hearty, sticky beans.
-If the beans get too try, you can always add beer!
-
-**Nutritional Information**
-Calories: lots
-Fat: lots
-Fun: lots
+Readme is in index.html
diff --git a/step1-01/exercise/index.html b/step1-01/exercise/index.html
index 1895d20..5c30717 100644
--- a/step1-01/exercise/index.html
+++ b/step1-01/exercise/index.html
@@ -1,4 +1,76 @@
-
-
+
+ +/* +Step 1 Exercise + +The power of HTML is its ability to represent complex information in a way that conveys meaning. In this exercise you are going to be creating an HTML page for my favorite recipe. + +## The Exercise + +1. Create a recipe page to host our recipe +2. Use title, header, main, footer, headings (h1/h2 etc), paragraphs, lists +3. Use ordered and unordered lists appropriately +4. Add the `baked_beans.jpg` image included in this folder: `https://raw.githubusercontent.com/Microsoft/frontend-bootcamp/master/step1-01/exercise/baked_beans.jpg` +5. Add an anchor tag around 'Wisconsin Beer Brats' + +## The Recipe + +Title: +4th of July Baked Beans + +Description: +It's great how a single meal can take you back dozens of years. This is one of those recipes that never seems to fail to impress. + +I learned this recipe from the cousin of one of my college friends back in Nashville Tennessee. We had an amazing 4th of July feast which included this recipe and some bratwurst like these Wisconsin Beer Brats https://www.culinaryhill.com/wisconsin-beer-brats/ + +Prep Time: 10 minutes +Cook time: 3+ hours +Servings: 12 + +Ingredients: +1LB Bacon chopped +3 Cans Bush's Original Baked Beans +1 Walla Wall Onion chopped +2 ground garlic cloves +3 Tablespoons of mustard +2 Tablespoons of molasses +3 Tablespoons of brown sugar + +Directions: +Cook bacon until it is mostly cooked, then drain most of the grease and put aside +Cook onion in remaining bacon grease +Combine onions and bacon, then add garlic, cook for a few more minutes +Add beans and get up to simmer temperature +Add mustard until your beans are nice and yellow +Add molasses until color darkens again +Add brown sugar until properly sweet +Simmer for a long time, occasionally stirring + +Expert Tips: +Burning off most of the liquid gives you nice, hearty, sticky beans. +If the beans get too dry, you can always add beer! + +Nutritional Information: +Calories: lots +Fat: lots +Fun: lots + +*/ + ++
Add Recipe Here+
-
+/* 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: specified separately for each side */
+ margin-bottom: 15px;
+ margin-top: 15px;
+
+ /* Shorthand: Padding applies to all sides */
+ padding: 10px;
+
+ /* Border shorthand and 3-digit hex */
+ border: 1px solid #ddd;
+}
+
+/* Overriding inherited styles */
+//span {
+ color: #004578;
+}
+
+/* Sibling selector */
+//a + a {
+ /* Changing elements from inline to block */
+ display: block;
+}
+
+/* Targeting a class name */
+//.tiles {
+ display: flex;
+}
+
+/* Descendant selector */
+//.tiles img {
+ width: 100%;
+}
+
+/* Direct descendant selector */
+//.tiles > div {
+ /* rgb color */
+ background: rgb(10, 10, 10);
+ color: white;
+ flex-basis: 100%;
+ /* Padding/margin shorthand. 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;
+ border: 1px solid white;
+}
+
+/* Qualified selector */
+//div.important-links {
+ background: #004578;
+}
+
+/* Style inheritance only works for unstyled elements */
+//a {
+ color: white;
+}
+
+/* Hover pseudo-selector */
+//a:hover {
+ color: #ccc;
+}
+
+/* Positional pseudo-selector */
+//.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;
+}
+
+ +<h1>This is my <span>Title</span></h1> +<div class="tiles"> + <div class="important-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 type="email" /> + <input value="Submit" type="submit" /> + </div> + </div> +</div> ++
+/* 1. */ + +/* 2. */ + +/* 3. */ + +/* 4. */ + +/* 5. */ + +/* 6. */ + +/* Bonus */ ++
+<section> + <h2>1. Text Color: Red</h2> + <div>2. Color Green (hint: Sibling Selector)</div> + <ul class="myList"> + <li> + 3. Border Green + </li> + </ul> + <main> + <div class="myClass">4. Background Green</div> + <div class="myClass otherClass"> + 5. Background Green & Color White + (Hint Qualified Selector) + </div> + <div id="myId" class="otherClass">6. Background Yellow</div> + </main> + <ul> + <li> + Don't Style Me + </li> + </ul> + <div>Bonus: Border Pink</div> +</section> ++
+
+body {
+ font: 1.2em sans-serif;
+}
+
+.tiles > div {
+ background: rgb(10, 10, 10);
+ color: white;
+ flex-basis: 100%;
+ padding: 10px 20px 15px;
+ margin: 10px 20px 10px 0;
+ border: 1px solid white;
+}
+
+#contact-form {
+ display: flex;
+ flex-direction: column;
+}
+
+input[type='submit'] {
+ align-self: flex-start;
+ margin-top: 10px;
+}
+
+ +<div class="tiles"> + <div> + <h2>Contact Us</h2> + <div id="contact-form"> + <label>Email</label><input id="email" type="email" /> + <input class="submit" value="Submit" type="submit" /> + </div> + </div> +</div> ++
+// Count the number of 'a' characters in the email form. +// Update button to reflect that number. + +
+label,
+button {
+ display: block;
+ margin-bottom: 10px;
+}
+
+ +<label><input type="checkbox" />Ice cream</label> +<label><input type="checkbox" />Pizza</label> +<label><input type="checkbox" />Tacos</label> +<label><input type="checkbox" />Meatloaf</label> +<label><input type="checkbox" />Brocolli</label> - +<button>Display Your Favorites</button> - +<div class="favorites"></div> ++
+/*
+1. Create a function named `getFavs` and set its contents to `alert('clicked')`
+2. Create a variable `button` and set it to a reference to our button by using `document.querySelector('button')`
+3. Add a click event listener to the button that calls `getFavs`. Click the button and make sure it calls our alert.
+4. Replace the alert with a new `favList` variable set to an empty array: `[]`
+5. Create a const variable `inputs` set to all of the inputs on the page. `querySelectorAll` will help here
+6. Iterate over all of the inputs using `for (const input of inputs) {}`
+7. For each iteration use an `if` statement to check if `input.checked` is equal to true
+8. If the above tests passes, push the `input.parentNode.textContent` onto the `favList` array. Pass that text into `favList.push()` as the parameter to add it to the array
+9. Outside of the for loop, use `document.querySelector('.favorites')` to target the div at the bottom of the page. Set the div's `textContent` to `favList.join(' ')`. This will join each of the foods together into a string separated by a space.
+*/
+
+
+ Hello World
, document.getElementById('app')); @@ -90,9 +64,9 @@ export class App extends React.Component { ## Counter Component -In this example we'll start with an already scaffolded-out control. The goal of our counter is to track how many times the counter button is clicked. In the past JavaScript demo we might have accessed the counter element using `document.querySelector('.counter')` and manually incremented the number found there. While using the DOM as your data store works, it's REALLY hard to scale past the most basic demo. +In this example we'll start with an already scaffolded-out control. The goal of our counter is to track how many times the counter button is clicked. -React solves this by allowing each control to specify its own data store, called **state**. We can reference values in state when we render our UI, and we can also update state over the lifetime of our application. +React allows each control to specify its own data store, called **state**. We can reference values in state when we render our UI, and we can also update state over the lifetime of our application. ### Adding State @@ -113,7 +87,7 @@ constructor(props) { #### Using [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) for props and state -Both `props` are `state` are JavaScript objects. They have a bunch of key/value pairs in them which you can access via `this.props.foo` or `this.state.bar`. Sometimes they have MANY values inside of them which you need access to. You could do this: +Both `props` and `state` are JavaScript objects. They have a bunch of key/value pairs in them which you can access via `this.props.foo` or `this.state.bar`. Sometimes they have MANY values inside of them which you need access to. You could do this: ```js let cat = this.props.cat; @@ -205,11 +179,13 @@ This function will update our component's state, incrementing the counter value ```jsx _onButtonClick = () => { - this.setState(prevState => ({ counter: prevState.counter + 1 })); + this.setState({ + counter: this.state.counter + 1 + }); }; ``` -> This isn't exactly a method, but a class property that is set to an [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). This mostly works the same as `onButtonClick() { }` but eliminates the need for [extra boilerplate](https://medium.freecodecamp.org/this-is-why-we-need-to-bind-event-handlers-in-class-components-in-react-f7ea1a6f93eb) used to avoid potential "gotchas" with [how `this` works in JavaScript](https://codeburst.io/javascript-the-keyword-this-for-beginners-fb5238d99f85).) +> Note that this could also be written as `this.setState(prevState => ({ counter: prevState.counter + 1 }));` to ensure that state is not updated until the previous state has been determined Now that we have a function to increment our count, all that's left is to connect it to our button. @@ -217,11 +193,9 @@ Now that we have a function to increment our count, all that's left is to connec ``` -> Note the syntax is a bit different than in HTML: `onclick="funcName()"` in HTML vs `onClick={this.funcName}` in JSX. - > Also note that each `Counter` maintains its own state! You can modify the state inside of one counter without affecting the others. -## Bonus: Using a Button component +## Using a Button component Buttons are among the most commonly written components. Custom buttons help abstract common styling, add icons or other decorations, and increase functionality (menu buttons etc). Let's take a quick look at a custom button component to see how it comes together. diff --git a/step1-05/TodoApp.html b/step1-05/TodoApp.html new file mode 100644 index 0000000..44b2d66 --- /dev/null +++ b/step1-05/TodoApp.html @@ -0,0 +1,36 @@ + + + +Hello World