├── .DS_Store
├── API_Management.md
├── BuildingResponsiveComponents.md
├── ClientSideStorage.md
├── Git.md
├── Git2.md
├── LayOutNavBar.md
├── RefiningSQLQueries.md
├── SCSS.md
├── SCSSFeatures.md
├── SCSSInYourProject.md
├── SQL1.md
├── SQL2.md
├── SuperTest.md
├── TDDWithInteractiveComponent.md
├── TDDWithTestingLibrary.md
├── TestingAnAsyncrounousComponent.md
├── TestingFEComponents.md
├── UsingBEM.md
└── readme.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/werner33/AdvancedBasicsForWeb/07fca7ae269dbffe98531f7403dd3a707684aa9a/.DS_Store
--------------------------------------------------------------------------------
/API_Management.md:
--------------------------------------------------------------------------------
1 |
2 | 1. API Calls Overview
3 |
4 | An API call is a request for some resources passed to us over the web. Modern web conventions have many APIs returning JavaScript Object Notation (JSON) that we can consume in a web application.
5 |
6 | In a typical React app we make an API call from the front end like this:
7 |
8 | ``` javascript
9 |
10 | fetch('https://catfact.ninja/fact')
11 | .then(res => res.json()
12 | .then(data => {
13 | console.log(data)
14 | });
15 |
16 | ```
17 |
18 | We might use a library like Axios to save ourselves some work, but [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) is build right into JavaScript.
19 |
20 | API calls have five HTTP Methods: GET, POST, PUT, PATCH and DELETE. We won't get into each of them now, but in very basic terms, we use GET to fetch information and we use POST to save information. The other three types are less common.
21 |
22 | A great breakdown of how an API is accessed via an HTTP request can be found [here.](https://blog.uptrends.com/technology/the-anatomy-of-an-api-call/)
23 |
24 |
25 | 2. Setting Request Headers
26 |
27 | We may want to make a call with special information or parameters. We can set a number of properties by specifying the Request Headers. Request headers are key/value pairs, passed as a second argument in a `fetch` request.
28 |
29 | ``` javascript
30 |
31 | fetch('https://catfact.ninja/fact', {method: 'POST'}) // we can add many other request headers here
32 | .then(res => res.json()
33 | .then(data => {
34 | console.log(data)
35 | });
36 |
37 | ```
38 |
39 | [In this article](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#supplying_request_options) you can see a more fulsome example of how you supply request options.
40 |
41 |
42 | 3. Where Should Calls Be Made in an Application?
43 |
44 | In a React application, components are structured in a heirarchy. An API calls should typically be made at the highest level where the data is needed.
45 |
46 | Here is a small example:
47 |
48 | Imagine we are writing an app that will show the names of all students in the school and also, a schedule of after-school activities.
49 |
50 | There are three main components structured like this:
51 |
52 | App\
53 | |----- StudentCollection\
54 | |----- Schedule
55 |
56 | The respective API calls should be made from the component showing the data.
57 |
58 | App\
59 | |----- StudentCollection\
60 | - fetch student data here\
61 | |----- Schedule\
62 | - fetch schedule of events here
63 |
64 | 4. Code Splitting in React
65 |
66 | When we send our React project to a client or browser, the whole application is sent by default. The components are not all rendered but the code is all included in the `bundle.js`. This is fine for a small application, but as our application grows, we should see if we can avoid sending code that a user may not use. One strategy we can employ is [Code Splitting](https://reactjs.org/docs/code-splitting.html).
67 |
68 | Let's look at an example where we 'split' one of our routes into its own bundle.
69 |
70 |
71 | ``` javascript
72 | const About = React.lazy(() => import('../about/About'));
73 |
74 | ...
75 |
76 |
77 |
` element would be blue. On any screen wider than 440px, the color would be the default black.
22 |
23 | You can read more about media queries [here](https://www.w3schools.com/css/css_rwd_mediaqueries.asp).
24 |
25 | # Building a Responsive Nav Bar
26 |
27 | In this lesson, we will create a new React app and build a responsive nav bar with a logo and a list of nav links.
28 |
29 | To begin:
30 |
31 | 1. Open a terminal and start a new React project: `npx create-react-app responsive-navbar`.
32 |
33 | 2. Move into the directory you just created: `cd responsive-navbar`
34 |
35 | 3. Install SCSS: `npm install sass`
36 |
37 | 4. Run the project: `npm start`
38 |
39 | 5. After you have verified that the project is running properly, remove all the code in the `
8 | [HTML](https://github.com/joinpursuit/Pursuit-Core-Web/tree/master/html_css_dom/html_introduction_combined)
9 | [CSS](https://github.com/joinpursuit/Pursuit-Core-Web/tree/master/html_css_dom/css_intro)
10 | [Building a React Application](https://github.com/joinpursuit/Pursuit-Core-Web/blob/master/react/README.md)
11 |
12 | You can review any of those things at their respective links.
13 |
14 | # SCSS
15 |
16 | SCSS (called Sass, as in, don't give me that sass!) is a CSS engine that allows us to nest our css, similar to how we nest HTML elements. Before we implement it in a React project, let's give it try by starting out on [Codepen](https://codepen.io/).
17 |
18 | First, in the CSS box, select the gear icon:
19 |
20 |
21 |
22 | This will open a settings panel. You can see this is in the following image:
23 |
24 |
25 |
26 | Click the dropdown and select SCSS from the list of pre-processors.
27 |
28 |
29 | Let's build a simple component with a title and a bit of text:
30 |
31 |
32 |
33 | First, let's write out all the HTML. We'll use the component we built in the first part of this lession:
34 |
35 | ``` HTML
36 |
37 |
79 |
80 | 2) Create a query to join Order with OrderDetail, getting the sum of the quantity of total items in the order.
81 |
82 | The beginning of the result will look like this:
83 |
84 |
85 |
86 | ## Questions about Joins
87 |
88 | 1) Given a database with Customers and Orders, where each order has a CustomerId, What kind of join would you use to find all Customers who have never placed an order?
89 |
90 | 2) What is the difference between a Left Join and a Right Join?
91 |
92 |
93 | ### More Exercises for W3
94 |
95 | 1. The boss has offered a prize to whichever employee packed more items in the month of August of 1996. Please write a query that shows all employees by their first and last names and how many total items (not unique items, but overall quantity) that they packed in August from most to least packed.
96 |
97 | 
98 |
99 |
100 | ### Articles on SQL, Query Management and ORMS
101 |
102 | [Why You Should Avoid ORMs](https://blog.logrocket.com/why-you-should-avoid-orms-with-examples-in-node-js-e0baab73fa5/).
103 |
104 | [ORMS are Awesome](https://chanind.github.io/2020/01/13/awesome-orms.html)
105 |
106 | ### Fun SQL Resources
107 |
108 | [W3 SQL](https://www.w3schools.com/sql/default.asp) - This is a real treasure as a reference.
109 |
110 | [LeetCode](https://leetcode.com/problemset/database/)
111 |
112 | [SQL Murder Mystery](https://mystery.knightlab.com/) - a great free game with lots of practice in more complex SQL queries.
113 |
114 | [SQL ZOO](https://sqlzoo.net/wiki/SQL_Tutorial) - lots of practice starting with very easy SQL to much more advanced.
115 |
116 | [SQL Police Department](https://sqlpd.com/) - This game only has a few levels for free and can feel a bit elementary, but fun none-the-less.
117 |
--------------------------------------------------------------------------------
/SuperTest.md:
--------------------------------------------------------------------------------
1 | Generate express app
2 |
3 | Install jest as global dev dependency
4 |
5 | Set up utils directory with one simple function
6 |
7 | Set up test directory with one test
8 |
9 | run test
10 |
11 | make pass
12 |
13 | write tests/make pass
14 |
15 | Move onto harder problem, follow same pattern
16 |
17 | Create a route taking in query params and printing out some data
18 |
19 | incorporate util function
20 |
21 | add supertest
22 |
23 | write a test for the route
24 |
25 | make pass
26 |
27 | do this for several variations
28 |
29 | done.
30 |
--------------------------------------------------------------------------------
/TDDWithInteractiveComponent.md:
--------------------------------------------------------------------------------
1 | # Testing an Interactive Component
2 |
3 | So far we've looked at the basic react app out of the box, then we moved on to testing a custom component. In this section, let's move into testing a component that has some interactivity. In the last section we'll include interactivity.
4 |
5 | 1. Create a New Component for a Counter
6 |
7 | You already know the drill: in the same project create a new directory called `/counter`. Like last time, let's start with the nested folder called `__test__`. And of course next well create our test file called `Counter.test.js`.
8 |
9 | As with last time, we'll start by just writing a test to make sure our component renders properly, however, this time we will integrate one more Jest function, `describe`:
10 |
11 | ``` javascript
12 | import { render } from '@testing-library/react';
13 | import Counter from '../Counter';
14 |
15 | describe('the counter has a button to increment the count by one each time its clicked', () => {
16 |
17 | test('renders Counter', () => {
18 | render(
17 | .
18 | +-- src
19 | | +-- infoCard
20 | +-- __test__
21 | +-- InfoCard.test.js
22 |
23 |
24 | 2. Let's Write Our First Test
25 |
26 | Open `InfoCard.test.js`. Let's follow the example of our previous code and write our first test just to test if the component is rendering properly.
27 |
28 | ``` javascript
29 | import { render, screen } from '@testing-library/react';
30 | import InfoCard from '.././InfoCard';
31 |
32 | test('renders InfoCard', () => {
33 | render(