Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aleksey Varov #1

Open
wants to merge 3 commits into
base: varov
Choose a base branch
from
Open

Aleksey Varov #1

wants to merge 3 commits into from

Conversation

alvar91
Copy link
Owner

@alvar91 alvar91 commented Jan 13, 2020

No description provided.

Copy link

@xnimorz xnimorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все комментарии относятся ко всему коду (т.е. замечание повторяется несколько раз)
Что понравилось: хорошее разделение на файлы, ответственность отдельный модулей

box-sizing: border-box;
width: 100%;

&__block {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Элемент блока form с названием block обычно наводить на мысль, что где-то с композицией элементов была ошибка

display: flex;
align-items: center;
}
&-error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему этот в отличие от остальных — является отдельным блоком?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется, что должен быть модификатором

@@ -0,0 +1,10 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сюда буду скидывать недочеты в интерфейсе \ логике. Провалидацию помню, поэтому не пишу.

  1. самовывоз, а адрес все равно хотят знать
    image

  2. Клик вне попапа не закрывает его. Не очень удобно

  3. На макете селект выглядит по-другому
    image

  4. Мобильный вид "едет":
    image

}

&__nav {
&-list {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

по бэм не рекомендуется делать так — это усложняет восприятие и ты описываешь list внутри nav — это получается элемент, образованный от элемента

let citiesResponse = await response.json();
return citiesResponse;
} catch (e) {
alert("Ошибка в получении данных от сервера");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что пользователь должен сделать с такой ошибкой?)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я к тому, что паттерн хорошего поведения — проверить есть ли коннект к сети, если нет, написать. Если это ошибка сервера — предложить или сделать самим запрос чуть позже

//Навешиваем обработчики на все карточки
//При клике на подложку (body) скрываем и удаляем элементы
const cards = document.querySelectorAll(".product-card");
const body = document.querySelector("#body");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше выбрать контейнер ближайший. иначе ты пытаешься трекать все

const body = document.querySelector("#body");
const handlerActive = event => {
cards.forEach(card => {
if (event.target.closest(".product-card") === card) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я говорил на практикуме — не очень хорошо завязываться на стилевые классы, для логики лучше завести специальные классы для js

}
sizeLabel.addEventListener("click", () => {
orderButton.classList.remove("button_disabled");
orderButton.disabled = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

достаточно просто disabled свойство и матчится на :disabled псевдокласс

const sendObj = {};
allElements.forEach(element => {
if(element.name === "user-name") {
sendObj["Имя пользователя"] = element.value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужно объект для отправки формировать кирилицей.
Лучше держать поля унифицированно на английском и более того, соответствие element.name предпочтительнее. Что вижу, то и получаю

} else if(element.name === "size" && element.checked){
sendObj["Выбранный размер"] = element.value;
} else if (productName) {
sendObj["Выбранный продукт"] = productName;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у форм есть готовые возможности сериализации

Comment on lines +5 to +37
if (element.name === "user-name") {
//Имя пользователя
sendObj[element.name] = element.value;
} else if (element.name === "user-email") {
//Электронный адрес пользователя
sendObj[element.name] = element.value;
} else if (element.name === "user-name") {
//Имя пользователя
sendObj[element.name] = element.value;
} else if (element.name === "code-country") {
//Код страны
sendObj[element.name] = element.value;
} else if (element.name === "mobile-number") {
//Номер мобильного телефона
sendObj[element.name] = element.value;
} else if (element.name === "delivery" && element.checked) {
//Выбранный способ получения
sendObj[element.name] = element.value;
} else if (element.name === "city") {
//Выбранный город
sendObj[element.name] = element.value;
} else if (element.value && element.name === "address") {
//Указанный адрес
sendObj[element.name] = element.value;
} else if (element.name === "pay" && element.checked) {
//Выбранный способ оплаты
sendObj[element.name] = element.value;
} else if (element.name === "sms") {
//Оповещение по sms
sendObj[element.name] = element.checked;
} else if (element.name === "size" && element.checked) {
//Выбранный размер
sendObj[element.name] = element.value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такой код сложно читается, он быстро растет и по большей части, это все выносится в разного рода конфиги

//Находим в карточке первый дочерний элемент
//если он является крестиком закрытия, то удаляем его
const orderInfo = card.firstElementChild;
if (orderInfo.classList.contains("product-card__button-close")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в некоторых местах остались стилевые классы, выполняющие бизнес-логику

<input type="radio" name="size" class="radio js-radio" value="${size}" disabled />
`;
}
templateSizes += `<span class="radio-button product-card__sizing-button">${size}</span>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логика выбора размера очень сложная с кучей вложенных условий

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants