-
Notifications
You must be signed in to change notification settings - Fork 20
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
Search frontend #505
base: master
Are you sure you want to change the base?
Search frontend #505
Conversation
Closes #500
www/public/app/js/modules/search.js
Outdated
|
||
this.elements.closer && this.elements.closer.addEventListener('click', () => this.hide()); | ||
|
||
const delayedSearch = codex.core.throttle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут нужно использовать debounce, а не throttle
www/public/app/js/modules/search.js
Outdated
const MIN_SEARCH_LENGTH = 3; | ||
const SEARCH_TIMEOUT = 500; | ||
|
||
const search = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
используй класс и напиши доки
|
||
if ($success) { | ||
/** | ||
* Return Model_Page[] to user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
странный комментарий
position: absolute; | ||
box-sizing: border-box; | ||
z-index: 6; | ||
top: 143px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это точно на всех экранах будет норм выглядеть? может в vh задать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Помнится, в чате была пачка комментов по UI. Займусь ими и это заодно пофикшу
margin-left: -30px; | ||
border-radius: 50%; | ||
border: 3px solid #ccc; | ||
border-top-color: #7b8999; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вынеси цвета в переменные прямо в этом файле
www/public/app/js/modules/search.js
Outdated
|
||
/** | ||
* Perform search on user input | ||
* @param value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не описано
www/public/app/js/modules/search.js
Outdated
if (this.elements.modal) { | ||
|
||
this.elements.modal.removeAttribute('hidden'); | ||
document.body.style.overflow = 'hidden'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это надо вынести в метод
www/public/app/js/modules/search.js
Outdated
|
||
const loader = document.createElement('div'); | ||
|
||
loader.classList.add('loader'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
класс захардкожен
* @returns {HTMLDivElement} | ||
*/ | ||
createLoader() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем столько пустых строк?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Линтер))
www/public/app/js/modules/search.js
Outdated
/** | ||
* Adjust related DOM elements appearance | ||
*/ | ||
this.elements.placeholder.setAttribute('hidden', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
снова какие-то стили хардкодятся. Это все должно быть в методах
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вынести в метод не сложно. А это не будет over-engineering? Метод будет вызван всего один раз именно с этими параметрами
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хотя в принципе можно и стили через setAttribute добавлять. Тогда будет смысл
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чтобы скрыть плейсхолдер js вообще можно не использовать. Это можно сделать на css.
www/public/app/js/modules/search.js
Outdated
/** | ||
* Adjust related DOM elements appearance | ||
*/ | ||
this.elements.placeholder.setAttribute('hidden', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чтобы скрыть плейсхолдер js вообще можно не использовать. Это можно сделать на css.
www/public/app/js/modules/search.js
Outdated
* Adjust related DOM elements appearance | ||
*/ | ||
this.elements.placeholder.setAttribute('hidden', true); | ||
this.elements.searchResults.removeAttribute('hidden'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем скрывается блок с результатами? это и есть оверинжениринг.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Юз-кейс: пользователь закрыл модалку поиска и открыл заново — поисковой выдачи быть не должно. Можно убрать элемент из DOM, можно скрыть при помощи CSS, повесив класс на родителя. Это всего лишь один из способов.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо очищать выдачу, а не удалять обертку
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В принципе норм — можно сделать три стейта:
- Поле поиска пустое (либо меньше трех символов введено) — поисковая выдача пустая
- Поле поиска не пустое — поисковая выдача есть
- Поле поиска не пустое — в поисковой выдаче сообщение, что результатов нет
Если поле было не пустое, а пользователь его стер, снова поисковая выдача пустая, без заглушки.
resolve #500