-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: add facility search bar component #925
Conversation
✅ Deploy Preview for findadoc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
c162923
to
6876e77
Compare
caf7037
to
76868b7
Compare
4f9af4d
to
e079011
Compare
a7229f2
to
7dd87cd
Compare
1c09d77
to
1d8f78a
Compare
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.
lots of great work in here! Complex dropdowns have a lot of UX and logic. Great work on making one for findadoc 🚀
Introduces a new search component to search for existing facilities. Handles input changes, searches through `facilitiesStore.facilityData`, and displays the best matches. Users can select a facility using the mouse or arrow keys + Enter. Pressing the Esc key or blurring the search input clears the input field. Uses a store to keep the results, accessible via `useFacilitySearchbarStore().selectedFacilities`. Adds a `.gitignore` rule for VS Code settings: `.vscode`.
1d8f78a
to
28da14d
Compare
Requested changes:
After changes: Recording.2024-12-22.003601.mp4 |
This commit introduces the following changes: - Extracts a new component `ModSearchBar` from `ModFacilitySearchBar`. - Replaces specific class colors with theme colors for consistency. - Displays the search results count directly in the search bar. - Improves the search results display with a scrollbar and removes the results limit. - Replaces the "mousemove" event with the "mouseover" event for better performance. - Updates the active item color to `bg-primary/90` for improved visibility. - Removes unnecessary comments for cleaner code. - Adds proper identifiers (IDs and classes) to relevant `<div>` elements. - Ensures all `event.preventDefault()` calls are placed inside their respective handlers. - Limits the arrow-up key index to 0 for better navigation control. - Introduces an `isNearPageBottom` conditional to dynamically adjust the layout: - Near the page bottom, the main container uses `flex-col-reverse`. - Results now use `-translate-y-full` instead of `-top-14`. - Removes the `facilitySearchBarStore.ts` file and integrates its logic directly into the component. How to use this component now? - Easy Peasy! 1. Import `ModFacilitySearchBar`. 2. Create a ref like this: ```typescript const selectedFacilities = ref(new Set<Facility>()); ``` 3. Pass the ref to the component like this: ```html <ModFacilitySearchBar v-model="selectedFacilities" /> ``` 4. Done! 🎉 But, what about the new component (`ModSearchBar`)? - No problema! 1. Import `ModSearchBar`. 2. Create a `HTMLInputElement` ref like this: ```typescript const searchInputElement = ref<HTMLInputElement | null>(null); ``` 3. Pass the ref to the component like this for better control of the search results input: ```html <ModSearchBar v-model="searchInputElement" :items-count="filteredItems.length" /> ``` 4. Pass additional props like `place-holder-text`, `items-count`, and listen to events such as `search-input-arrow-up`, `search-input-arrow-down`, `search-input-change`, `search-input-enter`, and `search-input-blur`. 5. Done! 🎉 Additional Notes: - Updated the i18n key to use the correct snake_case format. - Added a visible index to the search results for better navigation control.
ab5d830
to
bfcbadc
Compare
nice updates @gminetoma ! Added 3 new comments and the rest look fixed! |
`ModSearchBar` is now a generic component with a search input and a results list. Type inference is implemented using 'Generics'. Learn more here: https://vuejs.org/api/sfc-script-setup.html#generics Changed i18n keys to `modHealthcareProfessionalSection`. Removed old i18n keys. Added a new prop called `fields-to-display-callback`. This callback receives the item to be displayed and returns an array of strings, allowing us to display the desired properties to the user. Fixed a bug where 'currentFacilities' was empty after a page reload. Moved 'handleSearchInputChange' to 'ModEditHealthcareProfessionalSection'.
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.
looks solid! nice work with the changes @gminetoma ! 🤜 🤛
@gminetoma FYI I added missing Vietnamese locale keys that were added from another PR merge so this one can be merged too 🚀 |
Resolves #924
🔧 What changed
Introduces a new search component to search for existing facilities.
Handles input changes, searches through
facilitiesStore.facilityData
,and displays the best matches. Users can select a facility using
the mouse or arrow keys + Enter. Pressing the Esc key or blurring
the search input clears the input field.
Uses a store to keep the results, accessible via
useFacilitySearchbarStore().selectedFacilities
.Adds a
.gitignore
rule for VS Code settings:.vscode
.📸 Screenshots
Before
N/A
After
Recording.2024-12-17.210203.mp4