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

Add Geolocation component #336

Merged
merged 13 commits into from
Nov 18, 2022
Merged

Add Geolocation component #336

merged 13 commits into from
Nov 18, 2022

Conversation

yen-tt
Copy link
Contributor

@yen-tt yen-tt commented Nov 16, 2022

This PR adds Geolocation component to the repo, with jest tests and storybook stories.

Note: waiting on product to get SVG design for the default geolocation icon. Edit: Will update in another PR

J=SLAP-2396,SLAP-2397,SLAP-2398
TEST=manual&auto

  • tested manually through test site in Products page
  • jest tests passed and storybook stories display component as expected

@yen-tt yen-tt requested a review from a team as a code owner November 16, 2022 17:09
@coveralls
Copy link

coveralls commented Nov 16, 2022

Coverage Status

Coverage increased (+0.2%) to 84.55% when pulling e65db00 on dev/geolocation into 3748b15 on develop.

import { YextIcon } from '../icons/YextIcon';

/**
* The CSS class interface for the Geolocation component.
Copy link
Contributor Author

@yen-tt yen-tt Nov 16, 2022

Choose a reason for hiding this comment

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

I cannot use {@link Geolocation} here due to an issue with API Extractor adding _2 suffix to duplicate interface/class names. In search-ui-react, Geolocation from Typescript's "lib.dom.d.ts" file conflicts with Geolocation component.
See: microsoft/rushstack#2534 and microsoft/rushstack#2976
Open PR: microsoft/rushstack#2608

Screen Shot 2022-11-16 at 12 15 08 PM

It does make it a little odd in the doc but the signature of the component is correct. What to know if the team have any thoughts on this. A work around, which is a little hacky, is to add a script to manually update the files generated from API extractor.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with it, the api extractor docs aren't made to be extremely beginner friendly

Copy link
Contributor

Choose a reason for hiding this comment

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

could we link to Geolocation_2? or would that not resolve correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would link correctly in the doc pages but we would see this in search-ui-react.api.md file:
Screen Shot 2022-11-16 at 3 28 29 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

oh ok, I'm fine leaving it without a link

package.json Show resolved Hide resolved
src/components/Geolocation.tsx Outdated Show resolved Hide resolved
tests/components/Geolocation.stories.tsx Show resolved Hide resolved
tests/components/Geolocation.test.tsx Outdated Show resolved Hide resolved
@oshi97
Copy link
Contributor

oshi97 commented Nov 16, 2022

is there something up with the code coverage github action? it's not passing but haven't investigated why

src/components/Geolocation.tsx Outdated Show resolved Hide resolved
src/components/Geolocation.tsx Outdated Show resolved Hide resolved
tests/components/Geolocation.test.tsx Outdated Show resolved Hide resolved
@yen-tt
Copy link
Contributor Author

yen-tt commented Nov 17, 2022

is there something up with the code coverage github action? it's not passing but haven't investigated why

code coverage has been failing for the past couple PRs, I believe there's an issue with the visual-coverage script killing the process before it can run the rest of the commands for generating lcov coverage and moving files to the expected directory. That will be fix in another item/PR.

src/hooks/useGeolocationHandler.ts Outdated Show resolved Hide resolved
*/
radius?: number,
/** Custom handler function to call after user's position is successfully determined. */
handleUserPosition?: (position: GeolocationPosition) => void
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small nit: I'm not wild about the names handleUserPosition or setIsFetchingLocation. I think the latter is a bit long and convoluted. The former is a bit vague: handleUserPosition doesn't sound like a callback that fires when the user's position is obtained.

Copy link
Contributor Author

@yen-tt yen-tt Nov 17, 2022

Choose a reason for hiding this comment

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

setIsFetchingLocation is following the common pattern -- setIsBlah -- we use for a boolean setter function of react useState (e.g. setIsFeedbackProvided or setIsOptionsDisabled) so I thought the naming here would make things consistent. Outside of the pattern, maybe setIsUserLocationFound or updateGetLocationStatus but I don't think it conveys that it can be set to a boolean true, regardless if the location was determined successfully or not, as long as the fetching process is done? Similarly with our callbacks handleBlah pattern. Let me know if you have other names you prefer!

edit: end up moving setIsFetchingLocation > setIsFetchingUserLocation into the hook instead of having the component pass it in

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't totally agree with the idea that we should never use the word "on" and always use "handle". I think if done correctly, we could use both and each could convey a different meaning. But, that's a higher-level team convo.

src/hooks/useGeolocationHandler.ts Outdated Show resolved Hide resolved
@tmeyer2115 tmeyer2115 self-requested a review November 18, 2022 15:46
@yen-tt yen-tt merged commit ff5293e into develop Nov 18, 2022
@cea2aj cea2aj mentioned this pull request May 9, 2023
@cea2aj cea2aj mentioned this pull request Jun 29, 2023
cea2aj added a commit that referenced this pull request Jun 29, 2023
# Version 1.3.0

### Features
- Introduce new Facet components including the new Facets (#360), StandardFacet (#370), NumericalFacet (#375), and HierarchicalFacet (#373) components which support more customizability than the previous Facet components. 
- Support the new RichTextV2 (Lexical) and Markdown fields which have been converted to HTML as FeaturedSnippetDirectAnswers (#379)
- Remove the Yext logo from the search bar (#376)
- Deprecate LocationBias (#338) component in favor of the new Geolocation component (#336)

### Bug fixes
- Improve the UX of the search bar when long autocomplete text is returned which includes the truncation of long text (#378)
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.

6 participants