-
Notifications
You must be signed in to change notification settings - Fork 59
feat(docs): add an inline search field for component in list doc page #3377
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
Draft
MaxLardenois
wants to merge
51
commits into
ouds/main
Choose a base branch
from
ouds/main-ml-component-finder
base: ouds/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
41a7bbe
feat: use aria-invalid and :user-invalid instead of is-invalid and :i…
MaxLardenois cefc8ab
feat: improve css in control item and use aria-invalid/:user-invalid …
MaxLardenois 29556e0
feat: use aria-invalid and user-invalid on text inputs
MaxLardenois c0518a8
feat: use aria-invalid and user-invalid on text area
MaxLardenois f982752
fix: remove unwanted bootstrap invalid handling
MaxLardenois 52e4d24
Restore form-validation documentation page
hannahiss 65a7a8a
Restore form-validation documentation page
hannahiss d410303
Restore form-validation documentation page
hannahiss 46b80d4
fix form ids and needs validation
hannahiss cda0a68
doc
hannahiss 68b8389
ids
hannahiss 43332f8
ids
hannahiss 867db65
feat: update with :user-invalid and aria-invalid
MaxLardenois ce67984
feat(docs): add an inline search field for component in list doc page
MaxLardenois 1b31ce9
fix: typo
MaxLardenois 95efe9d
feat: add user input validity check
MaxLardenois 5a65748
feat: handle correctly aria-describedby
MaxLardenois 964130f
Merge branch 'ouds/main' into ouds/main-ml-component-finder
MaxLardenois 558f4f3
Apply suggestions from code review
MaxLardenois ab7228e
feat: after review
MaxLardenois 45c3fc2
fix: remove settimeout
MaxLardenois b122851
fix: after review
MaxLardenois 3adcefe
feat: more info on a11y
MaxLardenois e2bcaa7
oupsie button label
MaxLardenois 73b8cb0
feat(docs): double component in components cards where possible like …
MaxLardenois ff7e87c
after copilot review
MaxLardenois d72e58b
Merge branch 'ouds/main' into ouds/main-his-form-validation
MaxLardenois 0453e1e
Merge branch 'ouds/main' into ouds/main-ml-have-each-component-in-lig…
MaxLardenois c007c07
feat: update components details
MaxLardenois 4aa0d2c
feat: add headings in page
MaxLardenois 67a0798
fix: remove aria-current
MaxLardenois 8818e1a
fix: missing helper text
MaxLardenois 9833ac7
Merge branch 'ouds/main' into ouds/main-ml-component-finder
MaxLardenois 4d81394
Merge branch 'ouds/main-his-form-validation' into ouds/main-ml-compon…
MaxLardenois a69636a
Merge branch 'ouds/main-ml-have-each-component-in-light-and-dark-mode…
MaxLardenois f4d9881
fix: forgotten modif
MaxLardenois afed057
feat: add search by first letter
MaxLardenois 20418fe
feat: add inputmode
MaxLardenois 3b8a985
test input mode
MaxLardenois c55f547
test input mode 2
MaxLardenois 4831735
test input modee
MaxLardenois 4e6b946
fix: right quote
MaxLardenois b9ec773
fix: right end quote
MaxLardenois e072017
fix: again vnu
MaxLardenois ff901be
fix: legend behavior
MaxLardenois 4bfd22b
fix: to relaucnh ci
MaxLardenois ba02835
Merge branch 'ouds/main' into ouds/main-ml-component-finder
MaxLardenois 2a0b3cf
fix: remove merge errors
MaxLardenois 2ff54f2
feat: add no filter option, label on top
MaxLardenois c97d904
feat: update wording and remove flex on fieldset
MaxLardenois 2378c88
fix: reboot
MaxLardenois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| import { getVersionedDocsPath } from '@libs/path' | ||
| import { componentsDetails } from '../../../data/components-details' | ||
|
|
||
| const existingStartingLetters = [...new Set(componentsDetails.map((component) => component.name.charAt(0)))] | ||
| --- | ||
|
|
||
| <ouds-component-finder> | ||
| <form class="needs-validation mb-gridgap" novalidate onsubmit="return false"> | ||
| <div class="text-input mb-small"> | ||
| <div class="text-input-container"> | ||
| <svg aria-hidden="true"> | ||
| <use xlink:href={getVersionedDocsPath('assets/img/ouds-web-sprite.svg#search')}></use> | ||
| </svg> | ||
| <label for="oudsComponentFinderInput"> | ||
| Start typing to filter components <span class="visually-hidden">and update the component list below</span> | ||
| </label> | ||
| <input | ||
| type="search" | ||
| name="componentFinderInput" | ||
| id="oudsComponentFinderInput" | ||
| class="text-input-field" | ||
| pattern="[a-zA-Z \\-]+" | ||
| placeholder=" " | ||
| data-feedback-id="componentSearchFeedback" | ||
| inputmode="search" | ||
| /> | ||
| </div> | ||
| <p id="usernameFeedback" class="error-text">Alphabetical characters only.</p> | ||
| </div> | ||
| <fieldset class="d-md-flex align-items-center gap-xsmall" data-alpha-filter> | ||
| <legend class="my-md-none flex-shrink-0"> | ||
| <span class="visually-hidden">filter by </span>Starting letter: | ||
| </legend> | ||
| <div class="chips-container"> | ||
| <div class="chip chip-filter"> | ||
| <input type="radio" id="radioCheckAll" name="componentFinderAlpha" value="all" checked /> | ||
| <label class="chip-interactive" for="radioCheckAll">No filter</label> | ||
| </div> | ||
| { | ||
| existingStartingLetters.map((char) => ( | ||
| <div class="chip chip-filter"> | ||
| <input type="radio" id={`radioCheck${char}`} name="componentFinderAlpha" value={char.toLowerCase()} /> | ||
| <label class="chip-interactive" for={`radioCheck${char}`}> | ||
| {char} | ||
| </label> | ||
| </div> | ||
| )) | ||
| } | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| <ul class="list-unstyled row gy-large row-cols-1 row-cols-sm-2 row-cols-xl-3 row-cols-2xl-4" data-component-list> | ||
| <slot /> | ||
| </ul> | ||
| </ouds-component-finder> | ||
|
|
||
| <script> | ||
| class OudsComponentFinder extends HTMLElement { | ||
| connectedCallback() { | ||
| const searchForm = this.querySelector('form') as HTMLFormElement | ||
| if (!searchForm) return | ||
| const finderInput = searchForm.elements.namedItem('componentFinderInput') as HTMLInputElement | ||
| const finderAlpha = searchForm.elements.namedItem('componentFinderAlpha') as RadioNodeList | ||
| const alphaFieldset = this.querySelector('[data-alpha-filter]') | ||
| if (!finderInput || !alphaFieldset || !finderAlpha) return | ||
|
|
||
| finderInput.addEventListener('input', () => { | ||
| this.resetList() | ||
| this.resetAlphaFinder() | ||
| if (finderInput.value && finderInput.checkValidity()) { | ||
| this.querySelectorAll( | ||
| `ul[data-component-list] > :not([data-name*="${finderInput.value.toLowerCase()}"])` | ||
| ).forEach((elt) => elt.classList.add('d-none')) | ||
| } | ||
| }) | ||
|
|
||
| alphaFieldset.addEventListener('change', () => { | ||
| this.resetList() | ||
| if (finderAlpha.value && finderAlpha.value !== 'all') { | ||
| this.querySelectorAll(`ul[data-component-list] > :not([data-name^="${finderAlpha.value}"])`).forEach((elt) => | ||
| elt.classList.add('d-none') | ||
| ) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| resetList() { | ||
| this.querySelectorAll('ul[data-component-list] > *').forEach((elt) => elt.classList.remove('d-none')) | ||
| } | ||
|
|
||
| resetAlphaFinder() { | ||
| this.querySelectorAll('input[type=radio]').forEach((elt) => ((elt as HTMLInputElement).checked = false)) | ||
| ;(this.querySelector('input[type=radio][value="all"]') as HTMLInputElement).checked = true | ||
| } | ||
| } | ||
|
|
||
| customElements.define('ouds-component-finder', OudsComponentFinder) | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm wondering if we need the web component here, the js should work just fine even without it right ?
Uh oh!
There was an error while loading. Please reload this page.
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.
We do not per se, but it permits to constrain the JS to here. Also a thing proposed by Astro