瀏覽代碼

HW js18 final markup

Ivar 2 年之前
父節點
當前提交
ba49e1d7bb
共有 64 個文件被更改,包括 29526 次插入97 次删除
  1. 3 0
      js/18_redux-thunk-3/cart.svg
  2. 14 13
      js/18_redux-thunk-3/index.html
  3. 163 72
      js/18_redux-thunk-3/index.js
  4. 95 12
      js/18_redux-thunk-3/style.css
  5. 0 0
      js/22_react-1/package-lock.json
  6. 0 0
      js/22_react-1/package.json
  7. 0 0
      js/22_react-1/shop-2/.gitignore
  8. 0 0
      js/22_react-1/shop-2/README.md
  9. 0 0
      js/22_react-1/shop-2/package-lock.json
  10. 0 0
      js/22_react-1/shop-2/package.json
  11. 0 0
      js/22_react-1/shop-2/public/favicon.ico
  12. 0 0
      js/22_react-1/shop-2/public/index.html
  13. 0 0
      js/22_react-1/shop-2/public/logo192.png
  14. 0 0
      js/22_react-1/shop-2/public/logo512.png
  15. 0 0
      js/22_react-1/shop-2/public/manifest.json
  16. 0 0
      js/22_react-1/shop-2/public/robots.txt
  17. 0 0
      js/22_react-1/shop-2/src/App.js
  18. 0 0
      js/22_react-1/shop-2/src/App.scss
  19. 0 0
      js/22_react-1/shop-2/src/App.test.js
  20. 0 0
      js/22_react-1/shop-2/src/index.js
  21. 0 0
      js/22_react-1/shop-2/src/index.scss
  22. 0 0
      js/22_react-1/shop-2/src/logo.svg
  23. 0 0
      js/22_react-1/shop-2/src/reportWebVitals.js
  24. 0 0
      js/22_react-1/shop-2/src/setupTests.js
  25. 0 0
      js/22_react-1/shop/.gitignore
  26. 0 0
      js/22_react-1/shop/README.md
  27. 0 0
      js/22_react-1/shop/package-lock.json
  28. 0 0
      js/22_react-1/shop/package.json
  29. 0 0
      js/22_react-1/shop/public/favicon.ico
  30. 0 0
      js/22_react-1/shop/public/index.html
  31. 0 0
      js/22_react-1/shop/public/logo192.png
  32. 0 0
      js/22_react-1/shop/public/logo512.png
  33. 0 0
      js/22_react-1/shop/public/manifest.json
  34. 0 0
      js/22_react-1/shop/public/robots.txt
  35. 0 0
      js/22_react-1/shop/src/App.js
  36. 0 0
      js/22_react-1/shop/src/App.scss
  37. 0 0
      js/22_react-1/shop/src/App.test.js
  38. 0 0
      js/22_react-1/shop/src/index.js
  39. 0 0
      js/22_react-1/shop/src/index.scss
  40. 0 0
      js/22_react-1/shop/src/logo.svg
  41. 0 0
      js/22_react-1/shop/src/reportWebVitals.js
  42. 0 0
      js/22_react-1/shop/src/setupTests.js
  43. 23 0
      js/23_react_hw-2/hw/.gitignore
  44. 70 0
      js/23_react_hw-2/hw/README.md
  45. 27839 0
      js/23_react_hw-2/hw/package-lock.json
  46. 42 0
      js/23_react_hw-2/hw/package.json
  47. 二進制
      js/23_react_hw-2/hw/public/favicon.ico
  48. 43 0
      js/23_react_hw-2/hw/public/index.html
  49. 二進制
      js/23_react_hw-2/hw/public/logo192.png
  50. 二進制
      js/23_react_hw-2/hw/public/logo512.png
  51. 25 0
      js/23_react_hw-2/hw/public/manifest.json
  52. 3 0
      js/23_react_hw-2/hw/public/robots.txt
  53. 15 0
      js/23_react_hw-2/hw/src/App.js
  54. 0 0
      js/23_react_hw-2/hw/src/App.scss
  55. 8 0
      js/23_react_hw-2/hw/src/App.test.js
  56. 17 0
      js/23_react_hw-2/hw/src/index.js
  57. 13 0
      js/23_react_hw-2/hw/src/index.scss
  58. 1 0
      js/23_react_hw-2/hw/src/logo.svg
  59. 13 0
      js/23_react_hw-2/hw/src/reportWebVitals.js
  60. 5 0
      js/23_react_hw-2/hw/src/setupTests.js
  61. 1129 0
      js/23_react_hw-2/package-lock.json
  62. 5 0
      js/23_react_hw-2/package.json
  63. 0 0
      js/24_react_shop/index.html
  64. 0 0
      js/24_react_shop/index.js

+ 3 - 0
js/18_redux-thunk-3/cart.svg

@@ -0,0 +1,3 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M6 16C4.9 16 4.01 16.9 4.01 18C4.01 19.1 4.9 20 6 20C7.1 20 8 19.1 8 18C8 16.9 7.1 16 6 16ZM0 0V2H2L5.6 9.59L4.25 12.04C4.09 12.32 4 12.65 4 13C4 14.1 4.9 15 6 15H18V13H6.42C6.28 13 6.17 12.89 6.17 12.75L6.2 12.63L7.1 11H14.55C15.3 11 15.96 10.59 16.3 9.97L19.88 3.48C19.96 3.34 20 3.17 20 3C20 2.45 19.55 2 19 2H4.21L3.27 0H0ZM16 16C14.9 16 14.01 16.9 14.01 18C14.01 19.1 14.9 20 16 20C17.1 20 18 19.1 18 18C18 16.9 17.1 16 16 16Z" fill="#474030"/>
+</svg>

+ 14 - 13
js/18_redux-thunk-3/index.html

@@ -15,30 +15,31 @@
    <body>
       <div class="wrapper">
 
-        <header>
-          <a id="cartIcon" href="#/cart"></a>
+        <header class="bg-light">
 
-          <input id="findField" type="text"/>
+          <a class="logo" href="">ГЛАВНАЯ</a>
 
-          <div id="topContaner"></div>
+          <div class="head-info">
+            <a id="cartIcon" href="#/cart">
+              <img src="./cart.svg">
+              <span id="cartCounter"></span>            
+            </a>
+  
+            <input id="findField" type="text"/>
+  
+            <div id="topContaner"></div>
+          </div>
         </header>
 
   
         <div id='mainContainer'>
   
             <aside id='aside'>
-
-              <div id="loginContainer">
-
-              </div>
-              
-                Категории
+                
             </aside>    
   
-            <main id='main'>
+            <main id='main'>              
                 
-              
-                Контент
             </main>
   
         </div>

+ 163 - 72
js/18_redux-thunk-3/index.js

@@ -98,10 +98,17 @@ const actionAuthLogout = () => ({type: 'AUTH_LOGOUT'})
 
 
 function cartReducer (state={}, {type, good={}, count=1}) {
-    if (!state) {
-        return {}
-    }
 
+    // if (!state) {
+    //     return {}
+    // } 
+    if (Object.keys(state).length === 0) {
+        let currCart = JSON.parse(localStorage.cart)
+        if (currCart && Object.keys(currCart).length !== 0) {
+            state = currCart
+        } 
+    }
+    
     // только если в функции задан count по умолчанию вызывать тут
     // а так лучше вызвать в типах add и change
         // count = +count
@@ -117,30 +124,36 @@ function cartReducer (state={}, {type, good={}, count=1}) {
             if (!count) {
                 return state
             }
-            return {
+            let newState = {
                 ...state,
                 [_id]: {good, count: (count + (state[_id]?.count || 0)) < 0 ? 0 : count + (state[_id]?.count || 0)}
             }
+            localStorage.cart = JSON.stringify(newState) 
+            return newState
         },
         CART_CHANGE() {
             count = +count
             if (!count) {
                 return state
             }
-            return {
+            let newState = {
                 ...state,
                 [_id]: {good, count: count < 0 ? 0 : count}
             }
+            localStorage.cart = JSON.stringify(newState) 
+            return newState
         },
         CART_REMOVE() {           
             let { [_id]: removed, ...newState }  = state
+            localStorage.cart = JSON.stringify(newState) 
             return newState
         },
         CART_CLEAR() {
+            localStorage.cart = JSON.stringify({}) 
             return {}
         },
     }
-    if (type in types) {         
+    if (type in types) {        
         return types[type]()
     }
     return state
@@ -412,9 +425,17 @@ store.dispatch(actionRootCats())
 
 function createForm(parent, type, callback) {
     parent.innerHTML = ` 
-    <input id="login${type}" type="text"/>
-    <input id="pass${type}" type="password"/>
-    <button id="btn${type}">${type}</button>
+    <div class="form">
+        <div class="mb-3">
+            <label for="login${type}" class="form-label">Логин</label>
+            <input class="form-input form-control" id="login${type}" type="text"/>
+        </div>
+        <div class="mb-3">
+            <label for="pass${type}" class="form-label">Пароль</label>
+            <input class="form-input form-control" id="pass${type}" type="password"/>
+        </div>
+        <button class="btn btn-primary" id="btn${type}">${type}</button>
+    </div>
     `
     return () => window[`btn${type}`].onclick = () => {
                     store.dispatch(callback(window[`login${type}`].value, window[`pass${type}`].value))
@@ -429,31 +450,49 @@ const createCartPage = (parent) => {
     const {cart} = store.getState()
 
     const clearBtn = document.createElement('button')
-    clearBtn.innerText = "ОЧИСТИТЬ КОРЗИНУ";
+    clearBtn.classList = 'btn btn-primary cartBtn'
+    clearBtn.innerText = "ОЧИСТИТЬ КОРЗИНУ"
 
     if(Object.keys(cart).length !== 0) {
-        main.append(clearBtn)
+        parent.append(clearBtn)
     }
     clearBtn.onclick = () => {
         store.dispatch(actionCartClear())
     }
+
+    const cartPage  = document.createElement('div')
+    cartPage.classList = 'cartPage'
+    parent.append(cartPage)
+
+    let cartCounter = 0
     for(const item in cart) {
         const {good} = cart[item]
         const {count, good: {_id: id, name: name, price: price, images: [{url}]}} = cart[item]
+
+        cartCounter += count*price
+
         const card = document.createElement('div')
+        card.classList = 'card cartCard'    
         card.innerHTML = `
-            <div>
-                <p>${name}</p>
-                <img src="${backURL}/${url}">
-                <p>${count} шт</p>
-                <p>${price} грн</p>
-            </div>
-        `
-
+                        <div class="card-header">
+                            <h4 class="card-title">${name}</h4>
+                        </div>
+                        <img class="card-img-top" src="${backURL}/${url}" />
+                        <div class="card-body">                        
+                            <p>${count} шт</p>
+                            <p>${price} грн</p>   
+                            <h6>Итого: ${count*price} грн</h6>                                
+                        </div>
+                        `
+
+        const inputGr = document.createElement('div')
+        inputGr.classList = 'inputGr'
+        card.lastElementChild.append(inputGr)
 
         const minusBtn = document.createElement('button')
+        minusBtn.classList = 'btn btn-success'
         minusBtn.innerText = '-'
-        card.append(minusBtn)
+        inputGr.append(minusBtn)
         minusBtn.onclick = () => {
             store.dispatch(actionCartAdd(good, -1))
         }
@@ -461,33 +500,41 @@ const createCartPage = (parent) => {
         const changeCount = document.createElement('input')
         changeCount.type = 'number'
         changeCount.value = count
-        card.append(changeCount)
+        inputGr.append(changeCount)
         changeCount.oninput = () => {
             store.dispatch(actionCartChange(good, changeCount.value))
         }
 
         const plusBtn = document.createElement('button')
+        plusBtn.classList = 'btn btn-success'
         plusBtn.innerText = '+'
-        card.append(plusBtn)
+        inputGr.append(plusBtn)
         plusBtn.onclick = () => {
             store.dispatch(actionCartAdd(good))
         }
 
         const deleteGood = document.createElement('button')
+        deleteGood.classList = 'btn btn-success'
         deleteGood.innerText = 'Удалить'
         deleteGood.style.display = 'block'
-        card.append(deleteGood)
+        card.lastElementChild.append(deleteGood)
         deleteGood.onclick = () => {
             store.dispatch(actionCartRemove(good))
         }
 
-        parent.append(card)
+        cartPage.append(card)
     }
 
+    const total  = document.createElement('h5')
+    total.classList = 'totalCart'
+    total.innerText = `Всего к оплате: ${cartCounter} грн`
+    parent.append(total)
+
     const sendOrder = document.createElement('button')
+    sendOrder.classList = 'btn btn-primary cartBtn'
     sendOrder.innerText = "ОФОРМИТЬ ЗАКАЗ"
     if(Object.keys(cart).length !== 0) {
-        main.append(sendOrder)
+        parent.append(sendOrder)
     }
     const {auth} = store.getState()
     if (auth.token) {
@@ -509,11 +556,9 @@ window.onhashchange = () => {
     const routes = {
         category(){
             store.dispatch(actionCatById(_id))
-            console.log('страница категорий')           
         },
         good(){ 
             store.dispatch(actionGoodById(_id))
-            console.log('страница товара')                
         },
         register(){
             let goRegister = createForm(main, 'Register', actionFullRegister)
@@ -561,37 +606,56 @@ store.subscribe(() => {
             </div>
         </div>
         ` 
-    } else {
-        if (catById?.payload && route === 'category'){
+    } else {    
+        if (catById?.payload && route === 'category'){   
+            main.innerHTML = ''         
+            const catBody  = document.createElement('div')
+            catBody.classList = 'catBody'
+            main.append(catBody)
+
             const {name} = catById.payload;
-            main.innerHTML =    `<h1>${name}</h1>`
+            catBody.innerHTML =    `<h1 class="catHead">${name}</h1>`
         
             if (catById.payload.subCategories) {
+                const linkList  = document.createElement('div')
+                linkList.classList = 'list-group linkList'
+                catBody.append(linkList)
+
                 for(const {_id, name} of catById.payload.subCategories) {
-                    const link      = document.createElement('a');
-                    link.href       = `#/category/${_id}`;
-                    link.innerText  = name;
-                    main.append(link);
+                    const link      = document.createElement('a')
+                    link.classList = 'list-group-item list-group-item-action list-group-item-primary linkItem'
+                    link.href       = `#/category/${_id}`
+                    link.innerText  = name
+                    catBody.append(link)
                 }
             }
-            
+
             if (catById.payload.goods) {
+                const cardBody  = document.createElement('div')
+                cardBody.classList = 'cardBody'
+                main.append(cardBody)
                 for (const good of catById.payload.goods){
                     const {_id, name, price, images} = good
                     const card      = document.createElement('div')
-                    card.innerHTML = `<h2>${name}</h2>
-                                    <img src="${backURL}/${images[0].url}" />
-                                    <strong>${price} грн</strong>
-                                    <br>
-                                    <a href="#/good/${_id}">Перейти на страницу товара</a>
+                    card.classList = 'card goodCard'
+                    card.innerHTML = `
+                                    <img class="card-img-top" src="${backURL}/${images[0].url}" />
+                                    <div class="card-body">
+                                        <h4 class="card-title">${name}</h4>
+                                        <h5>${price} грн</h5>                                    
+                                        <a class="btn btn-primary" href="#/good/${_id}">
+                                            Подробнее
+                                        </a>
+                                    </div>
                                     `
                     const btnCart      = document.createElement('button')
-                    btnCart.innerText  = 'Добавить в корзину'
+                    btnCart.innerText  = 'В корзину'
+                    btnCart.classList = 'btn btn-success btnCart'
                     btnCart.onclick = () => {
                         store.dispatch(actionCartAdd(good))
                     }
-                    card.append(btnCart)
-                    main.append(card)
+                    card.lastElementChild.append(btnCart)
+                    cardBody.append(card)
                 }
             }
         }
@@ -613,17 +677,21 @@ store.subscribe(() => {
         ` 
     } else {
         if (goodById?.payload && route === 'good') {
-            main.innerHTML = '';
-            const good = goodById.payload;
+            main.innerHTML = ''
+            const good = goodById.payload
                 const {_id, name, images, price, description} = good
-                const card = document.createElement('div');
+                const card = document.createElement('div')
+                card.classList = 'goodPage'
                 card.innerHTML = `<h2>${name}</h2>
                                 <img src="${backURL}/${images[0].url}" />
-                                <strong>${price} грн</strong>
-                                <h2>${description}</h2>
-                                `;
+                                <div>                                    
+                                    <h6>${description}</h6>
+                                    <strong>Цена - ${price} грн</strong>
+                                </div>
+                                `
                 const btnCart      = document.createElement('button')
-                btnCart.innerText  = 'Добавить в корзину'
+                btnCart.innerText  = 'В корзину'
+                btnCart.classList = 'btn btn-success btnCart'
                 btnCart.onclick = () => {
                     store.dispatch(actionCartAdd(good))
                 }
@@ -672,6 +740,9 @@ store.subscribe(() => {
         if (goodByUser?.payload && route === 'orders'){
 
             main.innerHTML = ''   
+            const cardBody  = document.createElement('div')
+            cardBody.classList = 'cardBody'
+            main.append(cardBody)
     
             if (goodByUser.payload) {
                 let totalMoney = 0
@@ -679,25 +750,37 @@ store.subscribe(() => {
                 for (const order of goodByUser.payload) {
     
                     if (order.orderGoods) {
+
                         for (const {price, count, total, good} of order.orderGoods) {
                             if (price !== null && count !== null && total !== null && good !== null) {
                                 totalMoney += total                            
                                 const {_id, name, images} = good                            
     
                                 const card      = document.createElement('div')
-                                card.innerHTML  = `<h2>${name}</h2>
-                                                     <img src="${backURL}/${images[0].url}" />
-                                                     <strong>Куплено ${count} по ${price} грн. Итого: ${total} грн</strong>
-                                                     <br>
-                                                     <a href="#/good/${_id}">Перейти на страницу товара</a>
-                                                 `                                    
-                                main.append(card)
+                                card.classList = 'card goodCard'
+                                card.innerHTML = `
+                                <img class="card-img-top" src="${backURL}/${images[0].url}" />
+                                <div class="card-body">
+                                    <h4 class="card-title">${name}</h4>
+                                    <h6>
+                                        Куплено: ${count} по ${price} грн. 
+                                    </h6>  
+                                    <h6>
+                                        Итого: ${total} грн
+                                    </h6>   
+                                    <a class="btn btn-primary" href="#/good/${_id}">
+                                        Подробнее
+                                    </a>
+                                </div>
+                                `
+                                cardBody.append(card)
+
                             }
                         }
                     }
     
                 }
-                const totalBlock = document.createElement('b')
+                const totalBlock = document.createElement('h3')
                 totalBlock.innerText = 'Итого потрачено: ' + totalMoney + ' грн'
                 main.append(totalBlock)
             }
@@ -714,11 +797,10 @@ store.subscribe(() => {
     for (const key in cart) {
         counter += cart[key].count
     }
-    cartIcon.innerText  = counter
+    cartCounter.innerText  = counter
 })
 
 
-
 store.subscribe(() => {
     const {promise} = store.getState()
     const {goodFind} = promise
@@ -731,28 +813,37 @@ store.subscribe(() => {
                 <span class="visually-hidden">Loading...</span>
             </div>
         ` 
-    } else {
+    } else {            
         if (goodFind?.payload && route === 'find') {
+            main.innerHTML = ''
+            if (goodFind?.payload.length > 0) {            
+               
+                const cardBody  = document.createElement('div')
+                cardBody.classList = 'cardBody'
+                main.append(cardBody)
 
-            if (goodFind?.payload.length > 0) {
-            
-                main.innerHTML = ''
                 for (const good of goodFind.payload) {
                     const {_id, name, price, images} = good
                     const card      = document.createElement('div')
-                    card.innerHTML = `<h2>${name}</h2>
-                                    <img src="${backURL}/${images[0].url}" />
-                                    <strong>${price} грн</strong>
-                                    <br>
-                                    <a href="#/good/${_id}">Перейти на страницу товара</a>
+                    card.classList = 'card goodCard'
+                    card.innerHTML = `
+                                    <img class="card-img-top" src="${backURL}/${images[0].url}" />
+                                    <div class="card-body">
+                                        <h4 class="card-title">${name}</h4>
+                                        <h5>${price} грн</h5>                                    
+                                        <a class="btn btn-primary" href="#/good/${_id}">
+                                            Подробнее
+                                        </a>
+                                    </div>
                                     `
                     const btnCart      = document.createElement('button')
-                    btnCart.innerText  = 'Добавить в корзину'
+                    btnCart.innerText  = 'В корзину'
+                    btnCart.classList = 'btn btn-success btnCart'
                     btnCart.onclick = () => {
                         store.dispatch(actionCartAdd(good))
                     }
-                    card.append(btnCart)
-                    main.append(card)
+                    card.lastElementChild.append(btnCart)
+                    cardBody.append(card)
                 }
             } else {
                 main.innerHTML = 'Результаты не найдены'

+ 95 - 12
js/18_redux-thunk-3/style.css

@@ -1,4 +1,9 @@
 
+a {
+   display: block;
+   text-decoration: none;
+}
+
 a.btn {
    width: max-content;
 }
@@ -16,14 +21,28 @@ img {
 
 header {
    display: flex;
-   justify-content: space-around;
+   align-items: center;
+   height: 60px;
+}
+
+.head-info {
+   display: flex;
+   justify-content: space-between;
+   align-items: center;
+   height: 100%;
+   flex: 0 1 90%;
+   padding: 0 20px;
+}
+
+.logo {   
+   flex: 0 1 10%;
+   padding: 0 20px;
 }
 
 .catBtn {
    width: 100%;
    min-height: 40px;
-   margin: 5px;
-   text-decoration: none;
+   margin: 5px 0;   
    text-align: start;
    padding: 5px;
 }
@@ -37,18 +56,82 @@ header {
    }
 
    #aside {
-      width: 30%;
+      flex: 0 1 30%;
+      padding: 0 5px;
    }
 
-   #aside > a {
-      display: block;
+   #main {
+      flex: 0 1 70%;
+      padding: 0 5px;
+      display: flex;
+      flex-direction: column;
+      align-items: center;
    }
 
-   #main > a {
-      display: block;
+
+.form {
+   margin: 50px auto;
+}
+
+.cardBody {
+   width: 100%;
+   display: flex;
+   flex-wrap: wrap;
+   justify-content: start;
+   align-items: start;
+}
+
+   .goodCard {
+      flex: 0 1 25%;
+      padding: 10px;
+      margin: 20px;
    }
 
-   #loginContainer  {
-      display: flex;
-      flex-direction: column;
-   } 
+   .goodCard .btn {
+      margin: 5px;
+   }
+
+.catBody .catHead {
+   max-width: max-content;
+   margin: 10px auto;
+}
+
+.goodPage {
+   padding: 10px;
+   margin: 20px;
+}
+
+
+
+.cartPage {
+   width: 100%;
+   display: flex;
+   flex-wrap: wrap;
+   justify-content: center;
+   align-items: stretch;
+}
+
+.cartCard {
+   flex: 0 1 50%;
+   margin: 10px;
+}
+
+.cartCard .inputGr {
+   margin: 10px 0;
+}
+
+.cartCard .btn {
+   margin: 10px 0 10px auto;
+}
+
+.cartCard .inputGr .btn {
+   margin: 5px;
+}
+.cartCard .inputGr input {
+   height: 100%;
+   max-width: 50%;
+}
+
+.cartBtn {
+   margin: 20px auto;
+}

js/22_react/package-lock.json → js/22_react-1/package-lock.json


js/22_react/package.json → js/22_react-1/package.json


js/22_react/shop/.gitignore → js/22_react-1/shop-2/.gitignore


js/22_react/shop/README.md → js/22_react-1/shop-2/README.md


js/22_react/shop/package-lock.json → js/22_react-1/shop-2/package-lock.json


js/22_react/shop/package.json → js/22_react-1/shop-2/package.json


js/22_react/shop/public/favicon.ico → js/22_react-1/shop-2/public/favicon.ico


js/22_react/shop/public/index.html → js/22_react-1/shop-2/public/index.html


js/22_react/shop/public/logo192.png → js/22_react-1/shop-2/public/logo192.png


js/22_react/shop/public/logo512.png → js/22_react-1/shop-2/public/logo512.png


js/22_react/shop/public/manifest.json → js/22_react-1/shop-2/public/manifest.json


js/22_react/shop/public/robots.txt → js/22_react-1/shop-2/public/robots.txt


js/23_react-2/shop-2/src/App.js → js/22_react-1/shop-2/src/App.js


js/22_react/shop/src/App.scss → js/22_react-1/shop-2/src/App.scss


js/22_react/shop/src/App.test.js → js/22_react-1/shop-2/src/App.test.js


js/22_react/shop/src/index.js → js/22_react-1/shop-2/src/index.js


js/22_react/shop/src/index.scss → js/22_react-1/shop-2/src/index.scss


js/22_react/shop/src/logo.svg → js/22_react-1/shop-2/src/logo.svg


js/22_react/shop/src/reportWebVitals.js → js/22_react-1/shop-2/src/reportWebVitals.js


js/22_react/shop/src/setupTests.js → js/22_react-1/shop-2/src/setupTests.js


js/23_react-2/shop-2/.gitignore → js/22_react-1/shop/.gitignore


js/23_react-2/shop-2/README.md → js/22_react-1/shop/README.md


js/23_react-2/shop-2/package-lock.json → js/22_react-1/shop/package-lock.json


js/23_react-2/shop-2/package.json → js/22_react-1/shop/package.json


js/23_react-2/shop-2/public/favicon.ico → js/22_react-1/shop/public/favicon.ico


js/23_react-2/shop-2/public/index.html → js/22_react-1/shop/public/index.html


js/23_react-2/shop-2/public/logo192.png → js/22_react-1/shop/public/logo192.png


js/23_react-2/shop-2/public/logo512.png → js/22_react-1/shop/public/logo512.png


js/23_react-2/shop-2/public/manifest.json → js/22_react-1/shop/public/manifest.json


js/23_react-2/shop-2/public/robots.txt → js/22_react-1/shop/public/robots.txt


js/22_react/shop/src/App.js → js/22_react-1/shop/src/App.js


js/23_react-2/shop-2/src/App.scss → js/22_react-1/shop/src/App.scss


js/23_react-2/shop-2/src/App.test.js → js/22_react-1/shop/src/App.test.js


js/23_react-2/shop-2/src/index.js → js/22_react-1/shop/src/index.js


js/23_react-2/shop-2/src/index.scss → js/22_react-1/shop/src/index.scss


js/23_react-2/shop-2/src/logo.svg → js/22_react-1/shop/src/logo.svg


js/23_react-2/shop-2/src/reportWebVitals.js → js/22_react-1/shop/src/reportWebVitals.js


js/23_react-2/shop-2/src/setupTests.js → js/22_react-1/shop/src/setupTests.js


+ 23 - 0
js/23_react_hw-2/hw/.gitignore

@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*

+ 70 - 0
js/23_react_hw-2/hw/README.md

@@ -0,0 +1,70 @@
+# Getting Started with Create React App
+
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
+
+## Available Scripts
+
+In the project directory, you can run:
+
+### `npm start`
+
+Runs the app in the development mode.\
+Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
+
+The page will reload when you make changes.\
+You may also see any lint errors in the console.
+
+### `npm test`
+
+Launches the test runner in the interactive watch mode.\
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
+
+### `npm run build`
+
+Builds the app for production to the `build` folder.\
+It correctly bundles React in production mode and optimizes the build for the best performance.
+
+The build is minified and the filenames include the hashes.\
+Your app is ready to be deployed!
+
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
+
+### `npm run eject`
+
+**Note: this is a one-way operation. Once you `eject`, you can't go back!**
+
+If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
+
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
+
+You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
+
+## Learn More
+
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
+
+To learn React, check out the [React documentation](https://reactjs.org/).
+
+### Code Splitting
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
+
+### Analyzing the Bundle Size
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
+
+### Making a Progressive Web App
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
+
+### Advanced Configuration
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
+
+### Deployment
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
+
+### `npm run build` fails to minify
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

File diff suppressed because it is too large
+ 27839 - 0
js/23_react_hw-2/hw/package-lock.json


+ 42 - 0
js/23_react_hw-2/hw/package.json

@@ -0,0 +1,42 @@
+{
+  "name": "hw",
+  "version": "0.1.0",
+  "private": true,
+  "dependencies": {
+    "@testing-library/jest-dom": "^5.16.1",
+    "@testing-library/react": "^12.1.2",
+    "@testing-library/user-event": "^13.5.0",
+    "react": "^17.0.2",
+    "react-dom": "^17.0.2",
+    "react-redux": "^7.2.6",
+    "react-scripts": "5.0.0",
+    "redux": "^4.1.2",
+    "sass": "^1.45.1",
+    "thunk": "^0.0.1",
+    "web-vitals": "^2.1.2"
+  },
+  "scripts": {
+    "start": "react-scripts start",
+    "build": "react-scripts build",
+    "test": "react-scripts test",
+    "eject": "react-scripts eject"
+  },
+  "eslintConfig": {
+    "extends": [
+      "react-app",
+      "react-app/jest"
+    ]
+  },
+  "browserslist": {
+    "production": [
+      ">0.2%",
+      "not dead",
+      "not op_mini all"
+    ],
+    "development": [
+      "last 1 chrome version",
+      "last 1 firefox version",
+      "last 1 safari version"
+    ]
+  }
+}

二進制
js/23_react_hw-2/hw/public/favicon.ico


+ 43 - 0
js/23_react_hw-2/hw/public/index.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="theme-color" content="#000000" />
+    <meta
+      name="description"
+      content="Web site created using create-react-app"
+    />
+    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
+    <!--
+      manifest.json provides metadata used when your web app is installed on a
+      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
+    -->
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+    <!--
+      Notice the use of %PUBLIC_URL% in the tags above.
+      It will be replaced with the URL of the `public` folder during the build.
+      Only files inside the `public` folder can be referenced from the HTML.
+
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
+      work correctly both with client-side routing and a non-root public URL.
+      Learn how to configure a non-root public URL by running `npm run build`.
+    -->
+    <title>React App</title>
+  </head>
+  <body>
+    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <div id="root"></div>
+    <!--
+      This HTML file is a template.
+      If you open it directly in the browser, you will see an empty page.
+
+      You can add webfonts, meta tags, or analytics to this file.
+      The build step will place the bundled scripts into the <body> tag.
+
+      To begin the development, run `npm start` or `yarn start`.
+      To create a production bundle, use `npm run build` or `yarn build`.
+    -->
+  </body>
+</html>

二進制
js/23_react_hw-2/hw/public/logo192.png


二進制
js/23_react_hw-2/hw/public/logo512.png


+ 25 - 0
js/23_react_hw-2/hw/public/manifest.json

@@ -0,0 +1,25 @@
+{
+  "short_name": "React App",
+  "name": "Create React App Sample",
+  "icons": [
+    {
+      "src": "favicon.ico",
+      "sizes": "64x64 32x32 24x24 16x16",
+      "type": "image/x-icon"
+    },
+    {
+      "src": "logo192.png",
+      "type": "image/png",
+      "sizes": "192x192"
+    },
+    {
+      "src": "logo512.png",
+      "type": "image/png",
+      "sizes": "512x512"
+    }
+  ],
+  "start_url": ".",
+  "display": "standalone",
+  "theme_color": "#000000",
+  "background_color": "#ffffff"
+}

+ 3 - 0
js/23_react_hw-2/hw/public/robots.txt

@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:

+ 15 - 0
js/23_react_hw-2/hw/src/App.js

@@ -0,0 +1,15 @@
+import React, {useState, useEffect, useRef} from 'react'
+import logoDefault from './logo.svg';
+import './App.scss';
+import {Provider, connect}   from 'react-redux';
+import {createStore, combineReducers, applyMiddleware} from 'redux';
+import thunk from 'redux-thunk';
+
+function App() {
+  return (
+    <>
+    </>
+  );
+}
+
+export default App;

+ 0 - 0
js/23_react_hw-2/hw/src/App.scss


+ 8 - 0
js/23_react_hw-2/hw/src/App.test.js

@@ -0,0 +1,8 @@
+import { render, screen } from '@testing-library/react';
+import App from './App';
+
+test('renders learn react link', () => {
+  render(<App />);
+  const linkElement = screen.getByText(/learn react/i);
+  expect(linkElement).toBeInTheDocument();
+});

+ 17 - 0
js/23_react_hw-2/hw/src/index.js

@@ -0,0 +1,17 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+import './index.scss';
+import App from './App';
+import reportWebVitals from './reportWebVitals';
+
+ReactDOM.render(
+  <React.StrictMode>
+    <App />
+  </React.StrictMode>,
+  document.getElementById('root')
+);
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals();

+ 13 - 0
js/23_react_hw-2/hw/src/index.scss

@@ -0,0 +1,13 @@
+body {
+  margin: 0;
+  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+    sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+code {
+  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+    monospace;
+}

File diff suppressed because it is too large
+ 1 - 0
js/23_react_hw-2/hw/src/logo.svg


+ 13 - 0
js/23_react_hw-2/hw/src/reportWebVitals.js

@@ -0,0 +1,13 @@
+const reportWebVitals = onPerfEntry => {
+  if (onPerfEntry && onPerfEntry instanceof Function) {
+    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+      getCLS(onPerfEntry);
+      getFID(onPerfEntry);
+      getFCP(onPerfEntry);
+      getLCP(onPerfEntry);
+      getTTFB(onPerfEntry);
+    });
+  }
+};
+
+export default reportWebVitals;

+ 5 - 0
js/23_react_hw-2/hw/src/setupTests.js

@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';

File diff suppressed because it is too large
+ 1129 - 0
js/23_react_hw-2/package-lock.json


+ 5 - 0
js/23_react_hw-2/package.json

@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "create-react-app": "^5.0.0"
+  }
+}

js/24/index.html → js/24_react_shop/index.html


js/24/index.js → js/24_react_shop/index.js