Skip to content

Conversation

@44yu5h
Copy link

@44yu5h 44yu5h commented Apr 10, 2025

Feat: Search

  • Search in both title and description
  • Real-time filter
  • Reuse CSS to decrease bloat

Screenshot From 2025-04-10 10-27-24
Alt: UI

Screenshot From 2025-04-10 10-26-51
Alt: Searching in description

Closes #35

@kelson42 kelson42 requested a review from rgaudin April 10, 2025 07:09
@kelson42
Copy link
Member

kelson42 commented Apr 10, 2025

I would not recommend to do that in javascript only.

@rgaudin
Copy link
Member

rgaudin commented Apr 10, 2025

Thank you @44yu5h ; I'll review it in a few days.

Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

Thank you for the PR ; it works well.
Beside inline comments I see a couple of things to fix:

  • focus color on text field is missing. Just set it to whatever and we'll choose one but on my computer, it uses the default bright blue which is harsh.
  • there is no text filter on mobile mode while that's probably where it would be most useful. You have to duplicate the field, as we did for the other filters.

order_dir = 'desc';
only_lang = '';
only_category = '';
only_search = '';
Copy link
Member

Choose a reason for hiding this comment

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

Rename to only_pattern which is more clear

<label
for="search-bar"
class="hidden lg:inline-block kiwix-{{page }}-filter-label text-[0.9em] me-[1em] dm-sans"
>Search</label>
Copy link
Member

Choose a reason for hiding this comment

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

Find as label seems more appropriate (albeit not perfect). Search word sort of implies it will look at content while this is just a free-text filter on title/desc.
@siemsie any suggestion on the label ?

<input
id="search-bar"
type="text"
placeholder="Search..."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
placeholder="Search..."
placeholder="Filter on titles and descriptions…"

id="search-bar"
type="text"
placeholder="Search..."
class="select select-bordered select-sm max-w-xs dm-sans h-[2.25rem]"
Copy link
Member

Choose a reason for hiding this comment

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

We cannot have dm-sans here as this is free text and users can input any char while dmsans is latin only.

visible = false;
if (visible && this.only_search.trim() !== '') {
const nameAttr = elems[i].getAttribute('data-name').toLowerCase();
const descAttr = elems[i].getAttribute('data-desc') ? elems[i].getAttribute('data-desc').toLowerCase() : '';
Copy link
Member

Choose a reason for hiding this comment

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

Can you retrieve the description from the DOM below instead? This would force duplicating the descriptions

data-name="{{ package.title }}"
data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}">
data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}"
data-desc="{{ package.description|default('')|escape }}"
Copy link
Member

Choose a reason for hiding this comment

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

See comment above

data-langs="{% if package.langs %}{% for lang in package.langs %}{{ lang.alpha_3 }} {% endfor %}{% endif %}"
data-name="{{ package.title }}"
data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}"
data-desc="{{ package.description|default('')|escape }}"
Copy link
Member

Choose a reason for hiding this comment

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

See comment above

@rgaudin
Copy link
Member

rgaudin commented Apr 30, 2025

@siemsie test

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.

Dashboard should propose an easy free search

3 participants