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

Search frontend #505

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Search frontend #505

wants to merge 15 commits into from

Conversation

PolinaShneider
Copy link
Contributor

@PolinaShneider PolinaShneider commented Nov 5, 2020

  • Search frontend initial version
  • Search engine logic corrections

resolve #500


this.elements.closer && this.elements.closer.addEventListener('click', () => this.hide());

const delayedSearch = codex.core.throttle(
Copy link
Member

Choose a reason for hiding this comment

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

тут нужно использовать debounce, а не throttle

const MIN_SEARCH_LENGTH = 3;
const SEARCH_TIMEOUT = 500;

const search = {
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

это точно на всех экранах будет норм выглядеть? может в vh задать?

Copy link
Contributor Author

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;
Copy link
Member

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 Show resolved Hide resolved
www/public/app/js/modules/search.js Show resolved Hide resolved

/**
* Perform search on user input
* @param value
Copy link
Member

Choose a reason for hiding this comment

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

не описано

if (this.elements.modal) {

this.elements.modal.removeAttribute('hidden');
document.body.style.overflow = 'hidden';
Copy link
Member

Choose a reason for hiding this comment

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

это надо вынести в метод


const loader = document.createElement('div');

loader.classList.add('loader');
Copy link
Member

Choose a reason for hiding this comment

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

класс захардкожен

* @returns {HTMLDivElement}
*/
createLoader() {

Copy link
Member

Choose a reason for hiding this comment

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

зачем столько пустых строк?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Линтер))

/**
* Adjust related DOM elements appearance
*/
this.elements.placeholder.setAttribute('hidden', true);
Copy link
Member

Choose a reason for hiding this comment

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

снова какие-то стили хардкодятся. Это все должно быть в методах

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Вынести в метод не сложно. А это не будет over-engineering? Метод будет вызван всего один раз именно с этими параметрами

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Хотя в принципе можно и стили через setAttribute добавлять. Тогда будет смысл

Copy link
Member

Choose a reason for hiding this comment

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

чтобы скрыть плейсхолдер js вообще можно не использовать. Это можно сделать на css.

/**
* Adjust related DOM elements appearance
*/
this.elements.placeholder.setAttribute('hidden', true);
Copy link
Member

Choose a reason for hiding this comment

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

чтобы скрыть плейсхолдер js вообще можно не использовать. Это можно сделать на css.

* Adjust related DOM elements appearance
*/
this.elements.placeholder.setAttribute('hidden', true);
this.elements.searchResults.removeAttribute('hidden');
Copy link
Member

Choose a reason for hiding this comment

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

зачем скрывается блок с результатами? это и есть оверинжениринг.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Юз-кейс: пользователь закрыл модалку поиска и открыл заново — поисковой выдачи быть не должно. Можно убрать элемент из DOM, можно скрыть при помощи CSS, повесив класс на родителя. Это всего лишь один из способов.

Copy link
Member

Choose a reason for hiding this comment

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

надо очищать выдачу, а не удалять обертку

Copy link
Contributor Author

Choose a reason for hiding this comment

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

В принципе норм — можно сделать три стейта:

  1. Поле поиска пустое (либо меньше трех символов введено) — поисковая выдача пустая
  2. Поле поиска не пустое — поисковая выдача есть
  3. Поле поиска не пустое — в поисковой выдаче сообщение, что результатов нет

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

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.

Добавить поиск на сайт
3 participants