About This Workshop
The first day provides an introduction to the fundamentals of the web: HTML, CSS and JavaScript.
On the second day we'll dive into more advanced topics like TypeScript, testing, and state management.
To start the dev "inner loop," run:
```
npm start
```
This will load the site shown below.
### 4. Lesson Structure
1. Demos will either be via CodePen (Steps 1, 2 and 3) or done in the step folder. Follow the step README to walkthrough the demo.
2. Much like demos, exercises are done via CodePen or in the project step folders. These exercises will give you an opportunity to try what was demonstrated in the first step.
## What to expect
For each lesson, the presenter will walk through some demo code to teach core concepts about the topic. Don't worry about writing code at this point. Just follow along via the readmes linked below.
Most lessons also have an exercise portion. Exercise instructions are usually found in the readme for each step's "exercise" folder.
### Day one
Day one covers the basics of HTML, CSS and JavaScript, as well as an introduction to React and Typescript.
1. [Introduction to HTML](step1-01)
2. [Introduction to CSS](step1-02)
3. [Introduction JavaScript](step1-03)
4. [Introduction to React](step1-04)
5. [React Components](step1-05)
6. [State-driven UI](step1-06)
7. [Types and UI-driven state](step1-07)
### Day two
1. [TypeScript basics](step2-01)
2. [Fluent UI component library](step2-02)
3. [Theming and styling](step2-03)
4. [React Context](step2-04)
5. [Redux: Store](step2-05)
6. [Redux: React binding](step2-06)
### Bonus content
* [Redux: Service calls](bonus-servicecalls)
* [Testing with Jest](bonus-jest)
## Additional resources
- [MDN Web Docs](https://developer.mozilla.org/en-US/)
- [React Docs](https://reactjs.org/docs/getting-started.html)
- [Thinking in React](https://reactjs.org/docs/thinking-in-react.html)
## Follow the authors!
If you are interested in JavaScript, TypeScript, React, Redux, or Design Systems, follow us on Twitter:
- [@kenneth_chau](https://twitter.com/kenneth_chau)
- [@micahgodbolt](https://twitter.com/micahgodbolt)
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Legal notices
Microsoft and any contributors grant you a license to the Microsoft documentation and other content
in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode),
see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the
[LICENSE-CODE](LICENSE-CODE) file.
Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation
may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries.
The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.
Privacy information can be found at https://privacy.microsoft.com/en-us/
Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents,
or trademarks, whether by implication, estoppel or otherwise.
================================================
FILE: assets/scripts.js
================================================
// prettier-ignore
var appInsights = window.appInsights || function (a) {
function b(a) { c[a] = function () { var b = arguments; c.queue.push(function () { c[a].apply(c, b) }) } } var c = { config: a }, d = document, e = window; setTimeout(function () { var b = d.createElement("script"); b.src = a.url || "https://az416426.vo.msecnd.net/scripts/a/ai.0.js", d.getElementsByTagName("script")[0].parentNode.appendChild(b) }); try { c.cookie = d.cookie } catch (a) { } c.queue = []; for (var f = ["Event", "Exception", "Metric", "PageView", "Trace", "Dependency"]; f.length;)b("track" + f.pop()); if (b("setAuthenticatedUserContext"), b("clearAuthenticatedUserContext"), b("startTrackEvent"), b("stopTrackEvent"), b("startTrackPage"), b("stopTrackPage"), b("flush"), !a.disableExceptionTracking) { f = "onerror", b("_" + f); var g = e[f]; e[f] = function (a, b, d, e, h) { var i = g && g(a, b, d, e, h); return !0 !== i && c["_" + f](a, b, d, e, h), i } } return c
}({
instrumentationKey: "6ad37ae0-c4ab-4739-925c-1e2773c31f17"
});
// prettier-ignore
if (window.location.hostname !== 'localhost') {
window.appInsights = appInsights, appInsights.queue && 0 === appInsights.queue.length && appInsights.trackPageView(null, null, { urlReferrer: document.referrer });
}
================================================
FILE: assets/shared.css
================================================
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
background-color: #f3f2f1;
}
a {
color: #0078d4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 {
margin: 0;
}
h1 a {
font-size: 16px;
font-weight: 400;
}
.Container {
justify-content: center;
padding: 20px 0;
max-width: 1040px;
margin: 0 auto;
}
.Tiles {
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
grid-gap: 20px;
display: grid;
list-style-type: none;
margin: 0;
padding: 0;
counter-reset: steps;
}
.Tile {
background-color: white;
border-radius: 2px;
box-shadow: 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.132), 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.108);
opacity: 0.96;
transition: all 0.15s linear;
position: relative;
overflow: hidden;
padding: 12px;
}
.Tile:not(.Tile--intro):hover {
box-shadow: 0 6.4px 14.4px 0 rgba(0, 0, 0, 0.132), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.108);
opacity: 1;
}
.Tile.Tile--numbered::after {
counter-increment: steps;
content: counter(steps);
position: absolute;
left: -20px;
bottom: -3px;
font-size: 220px;
line-height: 188px;
color: #eaeaea;
z-index: 1;
}
.Tile-link {
align-items: center;
text-align: center;
color: #323130;
display: flex;
flex-direction: column;
height: 148px;
justify-content: center;
text-decoration: none;
position: relative;
font-size: 24px;
font-weight: 200;
z-index: 2;
}
a.Tile-link {
color: #0078d7;
}
a.Tile-link:hover {
text-decoration: underline;
}
.Tile-link i {
font-size: 32px;
margin-bottom: 12px;
color: #605e5c;
}
.Tile-links {
font-size: 16px;
color: #605e5c;
}
.Tile-links a {
text-decoration: none;
color: #0078d4;
}
.Tile-links a:hover {
text-decoration: underline;
}
.Tile--intro {
grid-column: span 2;
padding: 20px;
}
.Tile--intro h1 {
font-size: 24px;
font-weight: 300;
margin: 8px 0;
padding: 0;
}
.Tile--intro p {
font-size: 14px;
margin: 0;
}
.Tile--intro a,
.Tile--intro a:visited {
color: #0078d4;
}
================================================
FILE: assets/step.css
================================================
@import url(https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.1/css/fabric.min.css);
body {
display: flex;
box-sizing: border-box;
margin: 0;
padding: 0;
}
img {
max-width: 100%;
}
li {
margin-bottom: 3px;
}
blockquote {
background: white;
padding: 0px 5px;
}
body.ms-Fabric {
font-size: 16px;
line-height: 20px;
}
#app {
flex: 1 1 40%;
padding: 50px;
}
#app pre {
border-radius: 2px;
border: 1px solid #999;
padding: 15px;
}
#markdownReadme {
box-sizing: border-box;
flex: 1 1 60%;
background: #f3f2f1;
padding: 50px;
margin: 0 auto;
height: 100vh;
overflow: auto;
}
#markdownReadme.exercise {
background-color: #ecf6fd;
}
#markdownReadme pre {
padding: 5px;
border-radius: 3px;
background: #1e1e1e;
margin: 15px 0;
overflow: auto;
}
#markdownReadme code {
font-family: Consolas, Menlo, Monaco, monospace;
font-size: 0.9em;
background-color: white;
padding: 0.2em 0.4em;
border-radius: 5px;
}
#markdownReadme code.hljs {
background-color: inherit;
font-weight: bold;
}
/**
* highlight.js style
*/
/*
* Visual Studio 2015 dark style
* Author: Nicolas LLOBERA npm testin the command line.
npm testin the command line.
${highlighted}`;
};
marked.setOptions({ renderer });
if (div) {
const response = await fetch(div.dataset['src'] || '../README.md');
const markdownText = await response.text();
div.innerHTML = marked(markdownText);
restoreScroll(div);
div.addEventListener('scroll', evt => {
saveScroll(div);
});
window.addEventListener('resize', evt => {
saveScroll(div);
});
}
}
const scrollKey = `${window.location.pathname}_scrolltop`;
function saveScroll(div: HTMLElement) {
window.localStorage.setItem(scrollKey, String(div.scrollTop));
}
function restoreScroll(div: HTMLElement) {
const scrollTop = window.localStorage.getItem(scrollKey);
if (scrollTop) {
div.scrollTop = parseInt(scrollTop);
}
}
run();
================================================
FILE: package.json
================================================
{
"name": "bootcamp",
"version": "1.0.0",
"description": "",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/frontend-bootcamp"
},
"main": "index.js",
"scripts": {
"start:client": "webpack-dev-server --mode development --progress --open",
"test": "jest --watch",
"build": "rimraf docs && webpack --progress --mode production",
"start:server": "nodemon -w server server/index.js",
"start": "run-p start:server start:client",
"deploy-ghpages": "git push origin :gh-pages && git subtree push --prefix docs origin gh-pages"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/cors": "^2.8.4",
"@types/enzyme": "^3.9.0",
"@types/express": "^4.16.1",
"@types/jest": "^23.3.13",
"@types/node": "~10.12.21",
"@types/react": "^16.7.20",
"@types/react-dom": "^16.0.11",
"@types/react-redux": "^7.0.0",
"@types/redux": "^3.6.0",
"@types/uuid": "^3.4.4",
"body-parser": "^1.18.3",
"copy-webpack-plugin": "^4.6.0",
"cors": "^2.8.5",
"css-loader": "^2.1.0",
"fork-ts-checker-async-overlay-webpack-plugin": "^0.1.0",
"fork-ts-checker-webpack-plugin": "^0.5.2",
"html-webpack-plugin": "^4.0.0-beta.5",
"jest": "^24.1.0",
"nodemon": "^1.18.9",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"style-loader": "^0.23.1",
"ts-jest": "^24.0.0",
"ts-loader": "^5.3.3",
"tslint": "^5.13.0",
"typescript": "^3.3.3",
"uuid": "^3.3.2",
"webpack": "^4.28.4",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"@uifabric/fluent-theme": "^0.14.1",
"@uifabric/theme-samples": "^0.1.4",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.9.1",
"express": "^4.16.4",
"highlight.js": "^9.14.2",
"immer": "^1.12.1",
"marked": "^0.6.1",
"office-ui-fabric-react": "^6.144.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",
"redux-starter-kit": "^0.4.3",
"redux-thunk": "^2.3.0"
}
}
================================================
FILE: playground/index.html
================================================
================================================
FILE: prettier.config.js
================================================
module.exports = {
singleQuote: true,
tabWidth: 2,
printWidth: 140
};
================================================
FILE: server/index.js
================================================
// @ts-check
const fs = require('fs');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const store = {
/** @type {any} */
read() {
if (fs.existsSync('tmp.json')) {
store.todos = JSON.parse(fs.readFileSync('tmp.json').toString());
} else {
store.todos = {};
}
return store.todos;
},
save() {
fs.writeFileSync('tmp.json', JSON.stringify(store.todos));
},
todos: {}
};
app.use(bodyParser.json());
app.use(cors());
app.get('/todos', (req, res) => {
res.json(store.read());
});
app.put('/todos/:id', (req, res) => {
store.todos[req.params.id] = req.body;
store.save();
res.json('ok');
});
app.post('/todos/:id', (req, res) => {
store.todos[req.params.id] = req.body;
store.save();
res.json('ok');
});
app.delete('/todos/:id', (req, res) => {
delete store.todos[req.params.id];
store.save();
res.json('ok');
});
app.post('/todos', (req, res) => {
store.todos = req.body;
store.save();
res.json('ok');
});
app.get('/hello', (req, res) => {
res.send('world');
});
app.listen(process.env.NODE_ENV === 'production' ? undefined : 3000, () => {
console.log('Listening at http://localhost:3000');
});
================================================
FILE: server/now.json
================================================
{
"version": 2,
"name": "todo-server",
"builds": [{ "src": "*.js", "use": "@now/node-server" }],
"env": {
"NODE_ENV": "production"
}
}
================================================
FILE: step1-01/demo/index.html
================================================
This is a paragraph about why semantic HTML is important.
<html>
<head>
<title>Intro to HTML</title>
<link rel="stylesheet" href="./style.css" />
<style>
hr {
margin: 40px;
}
</style>
</head>
</html>
<body>
<header>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<nav></nav>
</header>
<main>
<article></article>
<aside></aside>
</main>
<footer></footer>
</body>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Officia, vero! Eum optio veniam nisi, assumenda ea velit in corrupti vel eos reprehenderit beatae libero rem iusto, maiores, corporis sunt laborum.
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Reiciendis porro consequuntur exercitationem, perspiciatis nam saepe, odit enim omnis qui commodi cupiditate in eveniet. Nemo maxime ipsam recusandae consectetur voluptatum non?
// This is a pre tag -- It respects spacing and tabs
<ul>
<li>Unordered</li>
<li>list</li>
<li>items</li>
</ul>
// But actual code still needs to be escaped
<ul>
<li>Unordered</li>
<li>list</li>
<li>items</li>
</ul>
b tag em tag i tag sub tag sup tab code tag
| Column 1 header | Column 2 header |
|---|---|
| The table body | with two columns |
| Another table row | with two columns |
| Row spanning both columns | |
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
Burning off most of the liquid gives you nice, hearty, sticky beans. If the beans get too dry, you can always add beer!
/*
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 header, main, footer, headings (h1/h2 etc), paragraphs, lists
3. Use ordered and unordered lists appropriately
4. Add the `baked_beans.jpg` image: https://raw.githubusercontent.com/Microsoft/frontend-bootcamp/master/step1-01/exercise/baked_beans.jpg
5. Add an anchor tag around 'Wisconsin Beer Brats'
> Note that CodePen takes care of the `HTML` and `Body` tags, so you can simply start with the content
## 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
3 ground garlic cloves
4 Tablespoons of mustard
3 Tablespoons of molasses
4 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
The first day provides an introduction to the fundamentals of the web: HTML, CSS and JavaScript.
On the second day we'll dive into more advanced topics like TypeScript, testing, and state management.
/* 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="https://github.com/microsoft/frontend-bootcamp/blob/master/assets/fabric.jpg?raw=true" 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 */
<!-- Without changing the HTML markup, apply the styles asked for in the markup. Do not apply styles that a tag doesn't ask for. -->
<section>
<h2>1. Text Color: Red</h2>
<div>2. Color Green (hint: Sibling Selector)</div>
<main>
<ul class="myList">
<li>
3. Border Green
</li>
</ul>
<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>