From 2bc3bd43c02ec93858392bad715d24d3cae3b0e4 Mon Sep 17 00:00:00 2001 From: Kubadaleko <7757535@mail.ru> Date: Fri, 15 Apr 2022 18:36:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BC=D0=B0=D1=88=D0=BD=D0=B5?= =?UTF-8?q?=D0=B5=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 49 +++++ lesson2/.idea/.gitignore | 5 + lesson2/.idea/lesson2.iml | 12 + lesson2/.idea/modules.xml | 8 + lesson2/index.html | 18 ++ lesson2/project/css/normalize.css | 349 ++++++++++++++++++++++++++++++ lesson2/project/css/style.css | 77 +++++++ lesson2/project/index.html | 19 ++ lesson2/project/js/main.js | 98 +++++++++ lesson2/script.js | 55 +++++ 10 files changed, 690 insertions(+) create mode 100644 .idea/workspace.xml create mode 100644 lesson2/.idea/.gitignore create mode 100644 lesson2/.idea/lesson2.iml create mode 100644 lesson2/.idea/modules.xml create mode 100644 lesson2/index.html create mode 100644 lesson2/project/css/normalize.css create mode 100644 lesson2/project/css/style.css create mode 100644 lesson2/project/index.html create mode 100644 lesson2/project/js/main.js create mode 100644 lesson2/script.js diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..648227a --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 1640364164486 + + + + + + \ No newline at end of file diff --git a/lesson2/.idea/.gitignore b/lesson2/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/lesson2/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/lesson2/.idea/lesson2.iml b/lesson2/.idea/lesson2.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/lesson2/.idea/lesson2.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/lesson2/.idea/modules.xml b/lesson2/.idea/modules.xml new file mode 100644 index 0000000..7d7f18f --- /dev/null +++ b/lesson2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson2/index.html b/lesson2/index.html new file mode 100644 index 0000000..49c6d2c --- /dev/null +++ b/lesson2/index.html @@ -0,0 +1,18 @@ + + + + + Lesson 2 + + + + +

+ + + +

+ + + + diff --git a/lesson2/project/css/normalize.css b/lesson2/project/css/normalize.css new file mode 100644 index 0000000..192eb9c --- /dev/null +++ b/lesson2/project/css/normalize.css @@ -0,0 +1,349 @@ +/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers. + */ + +body { + margin: 0; +} + +/** + * Render the `main` element consistently in IE. + */ + +main { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Remove the gray background on active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * 1. Remove the bottom border in Chrome 57- + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10. + */ + +img { + border-style: none; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers. + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * Correct the inability to style clickable types in iOS and Safari. + */ + +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Remove the default vertical scrollbar in IE 10+. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10. + * 2. Remove the padding in IE 10. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in Edge, IE 10+, and Firefox. + */ + +details { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Misc + ========================================================================== */ + +/** + * Add the correct display in IE 10+. + */ + +template { + display: none; +} + +/** + * Add the correct display in IE 10. + */ + +[hidden] { + display: none; +} diff --git a/lesson2/project/css/style.css b/lesson2/project/css/style.css new file mode 100644 index 0000000..b2c5c40 --- /dev/null +++ b/lesson2/project/css/style.css @@ -0,0 +1,77 @@ +body{ + font-family: 'SF Pro Display', sans-serif; +} +header{ + display: flex; + background-color: #2f2a2d; + justify-content: space-between; + color: #fafafa; + padding: 30px 80px; +} +button{ + outline: none; +} +.logo{ + + text-transform: uppercase; + font-weight: bold; +} +.btn-cart{ + background-color: #fafafa; + padding: 10px 20px; + border: 1px solid transparent; + color: #2f2a2d; + border-radius: 5px; + transition: all ease-in-out .4s; + cursor: pointer; +} +.btn-cart:hover{ + background-color: transparent; + border-color: #fafafa; + color: #fafafa; +} +.btn-cart, .logo{ + align-self: center; +} +.products{ + column-gap: 30px; + display: grid; + grid-template-columns: repeat(auto-fit, 200px); + grid-template-rows: 1fr; + padding: 40px 80px; + justify-content: space-between; +} +p { + margin: 0 0 5px 0; +} +.product-item{ + display: flex; + flex-direction: column; + width: 200px; + border-radius: 5px; + overflow: hidden; + margin: 20px 0; +} +img { + max-width: 100%; + height: auto +} +.desc { + border: 1px solid #c0c0c040; + padding: 15px +} +.buy-btn{ + margin-top: 5px; + background-color: #2f2a2d; + padding: 10px 20px; + border: 1px solid transparent; + color: #fafafa; + border-radius: 5px; + transition: all ease-in-out .4s; + cursor: pointer; +} +.buy-btn:hover{ + background-color: transparent; + border-color: #2f2a2d; + color: #2f2a2d; +} \ No newline at end of file diff --git a/lesson2/project/index.html b/lesson2/project/index.html new file mode 100644 index 0000000..7bd9d9c --- /dev/null +++ b/lesson2/project/index.html @@ -0,0 +1,19 @@ + + + + + Интернет-магазин + + + + +
+ + +
+
+
+
+ + + diff --git a/lesson2/project/js/main.js b/lesson2/project/js/main.js new file mode 100644 index 0000000..81f2dc3 --- /dev/null +++ b/lesson2/project/js/main.js @@ -0,0 +1,98 @@ +class ProductList { + constructor(container = '.products') { + this.container = document.querySelector(container); + this._goods = []; + this._productsObjects = []; + this._fetchGoods(); + this._render(); + console.log(this.sumPrice()); + + } + + _fetchGoods() { + this._goods = [ + {id: 1, title: 'Notebook', price: 20000}, + {id: 2, title: 'Mouse', price: 1500}, + {id: 3, title: 'Keyboard', price: 5000}, + {id: 4, title: 'Gamepad', price: 4500}, + ]; + } + + _render() { + for (const product of this._goods) { + const productObject = new ProductItem(product); + console.log(productObject); + this._productsObjects.push(productObject); + this.container.insertAdjacentHTML('beforeend', productObject.getHTMLString()); + } + } + + sumPrice() { + let total = 0; + for (let i in this._productsObjects) { + total += this._productsObjects[i].price; + } + return total; + } + // let total = 0; + // for (let i = 0; i < this._productsObjects.length; i++) { + // total +=this._productsObjects[i].price; + // } + // return total; + // } + // let total = 0; + // for (let i in this._productsObjects) { + // total += this._productsObjects[i].price; + // } + // return total; + // } + + // sumPrice() { return this._productsObjects.reduce((total, good) => total + good.price, 0) + // } + +} + +class ProductItem { + constructor(product, img = 'https://via.placeholder.com/200x150') { + this.id = product.id; + this.title = product.title; + this.price = product.price; + this.img = img; + } + + getHTMLString() { + return `
+ Some img +
+

${this.title}

+

${this.price} \u20bd

+ +
+
`; + } +} + +const list = new ProductList(); + +// const products = [ +// {id: 1, title: 'Notebook', price: 20000}, +// {id: 2, title: 'Mouse', price: 1500}, +// {id: 3, title: 'Keyboard', price: 5000}, +// {id: 4, title: 'Gamepad', price: 4500}, +// ]; +// +// const renderProduct = (item, img='https://via.placeholder.com/200x150') => `
+// Some img +//
+//

${item.title}

+//

${item.price} \u20bd

+// +//
+//
`; +// +// const renderProducts = list => { +// document.querySelector('.products').insertAdjacentHTML('beforeend', list.map(item => renderProduct(item)).join('')); +// }; +// +// renderProducts(products); + diff --git a/lesson2/script.js b/lesson2/script.js new file mode 100644 index 0000000..25a7159 --- /dev/null +++ b/lesson2/script.js @@ -0,0 +1,55 @@ +// let user = { +// name: 'Vasya', +// age: 30, +// } + +// ES5 +// function Person(name, yearOfBirth) { +// this.name = name; +// this.yearOfBirth = yearOfBirth; +// // this.calcAge = function () { +// // return new Date().getFullYear() - this.yearOfBirth; +// // }; +// } +// +// Person.prototype.calcAge = function () { +// return new Date().getFullYear() - this.yearOfBirth; +// }; +// +// function Teacher(name, yearOfBirth, subject) { +// Person.call(this, name, yearOfBirth); +// this.subject = subject; +// } +// +// console.log(Teacher.prototype.constructor); +// +// Teacher.prototype = Object.create(Person.prototype); +// console.log(Teacher.prototype.constructor); +// Teacher.prototype.constructor = Teacher; +// console.log(Teacher.prototype.constructor); +// +// var vasya = new Person('Vasya', 1990); +// var ann = new Teacher('Ann', 2000, 'Math'); + +// ES6 + +// class Person { +// constructor(name, yearOfBirth) { +// this.name = name; +// this.yearOfBirth = yearOfBirth; +// } +// +// calcAge() { +// return new Date().getFullYear() - this.yearOfBirth; +// } +// } +// +// class Teacher extends Person { +// constructor(name, yearOfBirth, subject) { +// super(name, yearOfBirth); +// this.subject = subject; +// } +// } + +// let vasya = new Person('Vasya', 1990); +// let ann = new Teacher('Ann', 2000, 'Math');