-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat(Templates): add search functionality for user templates #901
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ | |
| <li> | ||
| <a href="#" data-target="templates-user" data-i18n="templates.user.heading">My Templates</a> | ||
| </li> | ||
| <li class="templates-search"> | ||
| <label for="templates-search-input" class="visually-hidden" data-i18n="templates.search.label">Search templates</label> | ||
| <input id="templates-search-input" type="search" placeholder="Filter languages..." aria-label="Filter templates by language" /> | ||
| </li> | ||
|
Comment on lines
+13
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move search input out of the tab list for proper semantic structure. Placing the search input as an Recommend restructuring to place the search input in a dedicated container outside the tab list (e.g., above or below the tabs, or in a separate section). Consider restructuring like this: <ul id="templates-tabs" class="modal-tabs">
<li class="active">
<a href="#" data-target="templates-starter" data-i18n="templates.starter.heading">
Starter Templates
</a>
</li>
<li>
<a href="#" data-target="templates-user" data-i18n="templates.user.heading">My Templates</a>
</li>
- <li class="templates-search">
- <label for="templates-search-input" class="visually-hidden" data-i18n="templates.search.label">Search templates</label>
- <input id="templates-search-input" type="search" placeholder="Filter languages..." aria-label="Filter templates by language" />
- </li>
</ul>
+ <div class="templates-search-container">
+ <label for="templates-search-input" class="visually-hidden" data-i18n="templates.search.label">Search templates</label>
+ <input id="templates-search-input" type="search" placeholder="Filter languages..." aria-label="Filter templates by language" />
+ </div>Adjust CSS styling as needed to position the search container appropriately within the templates modal layout.
π€ Prompt for AI AgentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the search input should not be added as a new tab, since it affects the other tabs. The suggestion by CodeRabbit AI is reasonable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hatemhosny Thank you for confirming! Moving the search input outside the tab list will maintain proper semantic structure and ensure the tabs remain independent of the filtering functionality. The suggested refactoring will improve both accessibility and the overall architecture of the component. |
||
| </ul> | ||
|
|
||
| <div id="templates-starter" class="tab-content active"> | ||
|
|
@@ -28,3 +32,24 @@ | |
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Inline: emit a "templates:filter" event with the current query so other scripts can perform filtering --> | ||
| <script> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can move the logic to src/livecodes/UI/templates.ts. Also if you do that, you can directly manipulate DOM elements e.g. add |
||
| (function () { | ||
| var input = document.getElementById('templates-search-input'); | ||
| if (!input) return; | ||
|
|
||
| var emit = function (value) { | ||
| var ev = new CustomEvent('templates:filter', { detail: { query: value } }); | ||
| document.getElementById('templates-container').dispatchEvent(ev); | ||
| }; | ||
|
|
||
| var timeout = null; | ||
| input.addEventListener('input', function (e) { | ||
| var val = e.target.value || ''; | ||
| // debounce to avoid excessive events while typing | ||
| clearTimeout(timeout); | ||
| timeout = setTimeout(function () { emit(val.trim()); }, 150); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a debounce function here that you can re-use. |
||
| }); | ||
| })(); | ||
| </script> | ||
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.
Let's change
"Filter languages..."to"Search templates...". And then we can search by title, languages and others (e.g. tags).Also, after you finish your edits, please run
npm run i18n-exportto regenerate the i18n json and fix this build error.