Skip to content

Conversation

@mr9d
Copy link
Owner

@mr9d mr9d commented Apr 14, 2024

PR for code review

<body>

<p>Здесь HTML-код компонента.</p>
<div class="module__upload"></div>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Инициализация модуля через один <div> элемент - это прекрасное минималистичное решение. Но просьба выбрать более специфичное имя для базового класса, например: multiple-issues-upload.

Плюс к этому, если используется методология БЭМ, то класс module__upload как "элемент" обязан находиться внутри элемента с классом module как "блока". Так что предлагаю либо отказаться от использования БЭМ в принципе (для такого маленького проекта он не нужен), либо пересмотреть нейминг: https://cssguidelin.es/#bem-like-naming

Copy link
Owner Author

Choose a reason for hiding this comment

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

Стоит добавить один дата-атрибут для определения числа выпусков в комиксе: data-issues-count чтобы правильно нумеровать новые страницы.

Comment on lines 10 to 11
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="modal.css">
Copy link
Owner Author

Choose a reason for hiding this comment

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

Если можно, это лучше объединить в один файл, чтобы модуль было проще подключать.

@@ -0,0 +1,290 @@
(function () {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Если везде используются стрелочные функции, то и тут можно.

@@ -0,0 +1,290 @@
(function () {
const Page = `
Copy link
Owner Author

Choose a reason for hiding this comment

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

Нейминг. Константы (не путать с константными переменными) в программировании называются капсом, например: PAGE_HTML_TEMPLATE;

<a href="#" class="upload__card__button upload__card__button_move-left upload__card__button_move-left-${index}">
<img class="image-fit" src="images/left-arrow.svg" alt="Передвинуть влево">
</a>
<h5 class="upload__card__title">${name}</h5>
Copy link
Owner Author

Choose a reason for hiding this comment

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

${name} - это потенциальное место для XSS-атаки. Все данные, которые приходит от пользователя, нужно вставлять через https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText

files_.push(createFile(elem));
count++;
}
dropbox.classList.add("upload__dropbox-disabled");
Copy link
Owner Author

Choose a reason for hiding this comment

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

Зону загрузки точно нужно отключать после первой пачки файлов? А если автор решит закинуть еще что-то?


const createFileCard = (elem, index) => {
const card = document.createElement("div");
card.className = `upload__card upload__card-${index}`;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Кажется, класс upload__card upload__card-${index} нигде не используется. Я рекомендую сохранить индекс через дата-атрибут и использовать его дальше в коде (например, в обработчиках кнопок).

return card;
}

const createFile = (file, name = "", description = "") => {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Кажется, параметры name = "", description = "" нигде не используются.

formElement.setAttribute('action', '/action/manageAddIssue');
formElement.enctype = 'multipart/form-data';

const idComic = document.createElement('input');
Copy link
Owner Author

Choose a reason for hiding this comment

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

Нейминг. Переменные называются по правилам английского языка: в английском существительные ставятся в обратном порядке: например, идентификатор комикса - это "comicsId" а не "idComics"

list.items.add(elem.file);
image.files = list.files;

image.setAttribute('data-limit', '2097152')
Copy link
Owner Author

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