Skip to content

Commit 26b56c9

Browse files
committed
feat: 2주차 실습 문제 추가
1 parent 1bec52b commit 26b56c9

File tree

115 files changed

+2375
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2375
-25
lines changed

.pnp.cjs

+982-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
"workspaces": [
99
"apps/*",
1010
"tools/*",
11-
"packages/*"
11+
"packages/**/*"
1212
],
1313
"scripts": {
1414
"docs": "yarn workspace docs",
1515
"lint": "eslint .",
1616
"pre-commit": "lint-staged --config .lintstagedrc.js",
1717
"test": "jest",
18+
"practice:fe-cafe": "yarn workspace @practice/fecrash-cafe",
1819
"example": "yarn workspace @nutshell/example"
1920
},
2021
"devDependencies": {

packages/practice/fecrash-cafe/app.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var shopping_cart = []
2+
var shopping_cart_total = 0
3+
4+
document.querySelectorAll('button').forEach((button) =>
5+
button.addEventListener('click', ({ target }) => {
6+
const name = target.parentNode.querySelector('.menu-name').textContent
7+
const category = target.parentNode.querySelector('.category').textContent
8+
const price = target.parentNode.querySelector('.price').textContent
9+
10+
add_item_to_cart({ name, category, price })
11+
}),
12+
)
13+
14+
function add_item_to_cart(item) {
15+
shopping_cart.push(item)
16+
console.log(shopping_cart)
17+
calc_cart_total()
18+
}
19+
20+
function calc_cart_total() {
21+
shopping_cart_total = 0
22+
for (var i = 0; i < shopping_cart.length; i++) {
23+
var item = shopping_cart[i]
24+
shopping_cart_total += item.price
25+
}
26+
set_cart_total_dom()
27+
update_shipping_icons()
28+
update_tax_dom()
29+
}
30+
31+
function set_cart_total_dom() {
32+
document.querySelector('.total-price').textContent = shopping_cart_total
33+
}
34+
35+
function update_shipping_icons() {
36+
var buy_buttons = get_buy_buttons_dom()
37+
for (var i = 0; i < buy_buttons.length; i++) {
38+
var item = buy_buttons[i]
39+
console.log(item)
40+
if (item.price + shopping_cart_total >= 20) item.show_free_shopping_icon()
41+
else item.hide_free_shopping_icon()
42+
}
43+
}
44+
45+
function get_buy_buttons_dom() {
46+
var buttons = []
47+
48+
for (var i = 0; i < shopping_cart.length; i++) {
49+
var item = shopping_cart[i]
50+
item.show_free_shopping_icon = function () {
51+
console.log('DOM 의 아이콘을 보여줍니다')
52+
}
53+
item.hide_free_shopping_icon = function () {
54+
console.log('DOM 의 아이콘을 숨깁니다')
55+
}
56+
buttons.push(item)
57+
}
58+
59+
return buttons
60+
}
61+
62+
function update_tax_dom() {
63+
set_tax_dom(shopping_cart_total * 0.1)
64+
}
65+
66+
function set_tax_dom(value) {
67+
document.querySelector('.total-price').textContent = value
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
}
5+
6+
body {
7+
background-color: #F2EEE9;
8+
font: normal 13px/1.5 Georgia, Serif;
9+
color: #333;
10+
}
11+
12+
.wrapper {
13+
width: 705px;
14+
margin: 20px auto;
15+
padding: 20px;
16+
}
17+
18+
.carts {
19+
display: flex;
20+
align-items: flex-end;
21+
flex-direction: column;
22+
}
23+
24+
h1 {
25+
display: inline-block;
26+
background-color: #333;
27+
color: #fff;
28+
font-size: 20px;
29+
font-weight: normal;
30+
text-transform: uppercase;
31+
padding: 4px 20px;
32+
float: left;
33+
}
34+
35+
.clear {
36+
clear: both;
37+
}
38+
39+
.items {
40+
display: block;
41+
margin: 20px 0;
42+
}
43+
44+
.item {
45+
background-color: #fff;
46+
float: left;
47+
margin: 0 10px 10px 0;
48+
width: 205px;
49+
padding: 10px;
50+
height: 310px;
51+
}
52+
53+
.item img {
54+
display: block;
55+
margin: auto;
56+
}
57+
58+
h2 {
59+
font-size: 16px;
60+
display: block;
61+
border-bottom: 1px solid #ccc;
62+
margin: 0 0 10px 0;
63+
padding: 10px 0;
64+
}
65+
66+
button {
67+
border: none;
68+
border-radius: 8px;
69+
padding: 4px 14px;
70+
background-color: #00A29E;
71+
color: #ffffff;
72+
text-transform: uppercase;
73+
float: right;
74+
margin: 10px 0 5px;
75+
font-weight: bold;
76+
cursor: pointer;
77+
transition: 0.2s ease-in-out;
78+
}
79+
80+
.icons:hover {
81+
cursor: pointer;
82+
}
83+
84+
button:hover {
85+
background-color: #00C6C2;
86+
}
87+
88+
button:active {
89+
background-color: #005857;
90+
}
91+
92+
span {
93+
float: right;
94+
}
95+
96+
.shopping-cart {
97+
display: inline-block;
98+
background: url('http://cdn1.iconfinder.com/data/icons/jigsoar-icons/24/_cart.png') no-repeat 0 0;
99+
width: 24px;
100+
height: 24px;
101+
margin: 0 10px 0 0;
102+
}
103+
104+
.category {
105+
border-radius: 8px;
106+
background-color: #fff;
107+
border: 1px solid #00A29E;
108+
color: #00A29E;
109+
padding: 6px;
110+
}
111+
112+
p, .price {
113+
height: 20px;
114+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* http://meyerweb.com/eric/tools/css/reset/
2+
v2.0 | 20110126
3+
License: none (public domain)
4+
*/
5+
6+
html, body, div, span, applet, object, iframe,
7+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8+
a, abbr, acronym, address, big, cite, code,
9+
del, dfn, em, img, ins, kbd, q, s, samp,
10+
small, strike, strong, sub, sup, tt, var,
11+
b, u, i, center,
12+
dl, dt, dd, ol, ul, li,
13+
fieldset, form, label, legend,
14+
table, caption, tbody, tfoot, thead, tr, th, td,
15+
article, aside, canvas, details, embed,
16+
figure, figcaption, footer, header, hgroup,
17+
menu, nav, output, ruby, section, summary,
18+
time, mark, audio, video {
19+
margin: 0;
20+
padding: 0;
21+
border: 0;
22+
font-size: 100%;
23+
font: inherit;
24+
vertical-align: baseline;
25+
}
26+
27+
/* HTML5 display-role reset for older browsers */
28+
article, aside, details, figcaption, figure,
29+
footer, header, hgroup, menu, nav, section {
30+
display: block;
31+
}
32+
33+
body {
34+
line-height: 1;
35+
}
36+
37+
ol, ul {
38+
list-style: none;
39+
}
40+
41+
blockquote, q {
42+
quotes: none;
43+
}
44+
45+
blockquote:before, blockquote:after,
46+
q:before, q:after {
47+
content: '';
48+
content: none;
49+
}
50+
51+
table {
52+
border-collapse: collapse;
53+
border-spacing: 0;
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { defineConfig } = require('cypress');
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
screenshotOnRunFailure: false,
6+
video: false,
7+
},
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
describe('FECrash 카페', () => {
2+
beforeEach(() => {
3+
cy.visit({
4+
url: 'http://localhost:5500/packages/practice/fecrash-cafe/index.html',
5+
method: 'GET',
6+
})
7+
})
8+
9+
context('최초 렌더링 시', () => {
10+
it('장바구니 총 가격은 0원이어야 한다.', () => {
11+
cy.get('.total-price').should('have.text', '0원')
12+
})
13+
})
14+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add('login', (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/e2e.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)