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

feat: HomeHeader has been rebuilt #430

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

arnest00
Copy link
Contributor

@arnest00 arnest00 commented Oct 24, 2022

This pull request addresses issue #402.

What changed?

  • Create HomeHeader component
  • Create LocationSelect component
  • Create Subtitle component

Taking some cues from this article about using custom select menus, I opted to use a native select menu in LocationSelect for this work. The arrow icon is also now an SVG instead of a transformed <div> element. Open to feedback, however - I know that rebuilding that component has its own issue now in #432 so we can address it then.

How did you test the changes?

  • Manually

Screenshots

Screenshot 2022-10-29 at 1 49 42 PM

Screenshot 2022-10-29 at 2 00 40 PM

src/App.tsx Outdated Show resolved Hide resolved
@arnest00 arnest00 force-pushed the feat--rebuild-homepage-header branch 2 times, most recently from 1adb639 to 4e519fe Compare October 29, 2022 21:02
@arnest00 arnest00 requested a review from yosevu October 29, 2022 21:06
@arnest00 arnest00 marked this pull request as ready for review October 29, 2022 21:06
<div className="location-select">
<h2 className="location-select__title">Pick a Location</h2>

<select className="location-select__menu" name="location" id="location">
Copy link
Contributor

@yosevu yosevu Oct 30, 2022

Choose a reason for hiding this comment

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

Most often the result is not fully accessible; browser and assistive technology is inconsistent; and implementations vary across the web. This is why it’s always better to use native selects with HTML/web.

I this is the right idea, but I disagree with the conclusion that it is always better to use native select elements. I think it depends on goals, time, capabilities etc. Although accessibility is a higher priority than design, I think we can also meet both needs by using both a native select and keeping the custom one to display. I found this article, which I think is a good overview of the rationale and approach.

This is potentially another reason to rebuild this component in #432.

What do you think?


Complete LocationMenu filtering in #432.

locations: Location[];
};

function LocationSelect({ locations }: LocationSelectProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I updated the name of this component to LocationMenu in the requirements and #413 because I thought it was more precise, but I think the article I shared about custom vs native select makes a good case for either.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in 3217ecf.


return (
<div className="location-select">
<h2 className="location-select__title">Pick a Location</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

I scanned the page with axe DevTools and found one critical issue.

Screenshot 2022-10-30 at 12 25 15 PM

I think we need to replace this with a label and update the styles if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in f5f7392.


<select className="location-select__menu" name="location" id="location">
<option className="location-select__option" value="all">
All Places
Copy link
Contributor

Choose a reason for hiding this comment

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

See the note about replacing instances of "place" with "location" in the requirements #432!

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in d69acaf.

<LocationSelect locations={locations} />

<div className="home-header__button">
<a className="button__header-primary" href="/places/new">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we replace this with a React Router Link?

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in 0bb1a96.

Comment on lines 8 to 9
const allCities = locations.map((location) => location.city);
const uniqueCities = [...new Set(allCities)];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, but can we move the to locations.ts? The main reason is to keep the logic and data derived from it coming from a single source and Sparkeats doesn't have enough for this to make a significant difference in performance or maintenance. This way only need to pass the component the prop that it needs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in 7e978d4.

<div className="location-select">
<h2 className="location-select__title">Pick a Location</h2>

<select className="location-select__menu" name="location" id="location">
Copy link
Contributor

Choose a reason for hiding this comment

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

We will also need state for the selected city and an onChange event handler to update the selected city and filter the location cards, however, this can be done in #432.

background-repeat: no-repeat;
background-position: calc(100% - 0.5rem);
background-size: 1rem auto;
background-image: url("data:image/svg+xml,<svg viewBox='0 0 30 20' xmlns='http://www.w3.org/2000/svg'><path d='M4.5 1 15 11.3 25.5 1l3.8 3.9L15 19 .7 4.8 4.5.9Z' fill='%23C92400'/></svg>");
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great. What was your reasoning for changing this to an SVG?

float: right;
height: 0.5em;
width: 0.5em;
transform: rotate(135deg);
Copy link
Contributor

Choose a reason for hiding this comment

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

The arrow no longer transforms when the menu is open, will this not work the same way now?

 &__button[aria-expanded='true'] .location-dropdown {
    &__button-arrow {
      transform: rotate(-45deg);
    }
  }

Screenshot 2022-10-30 at 2 44 00 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Address ins #432.

Copy link
Contributor

@yosevu yosevu left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @arnest00! Especially opening the native select discussion. A few discussion points and changes to make depending on what you have time/want to do. The rest can be done in #432.

@@ -1,4 +1,4 @@
.sparkeats-subtitle {
.subtitle {
Copy link
Contributor

@yosevu yosevu Oct 30, 2022

Choose a reason for hiding this comment

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

The name Subtitle has been bothering me. It feels to general, like it needs to be qualified. Would SiteSubtitle be a better name for the component and related styles that would align more with SiteHeader. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in d97c677.

Comment on lines 4 to 6
sparkboxers review food and
<br />
drink places so you can eat right
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should change the wording here to be more general since the audience is no longer only people at Sparkbox.

Suggested change
sparkboxers review food and
<br />
drink places so you can eat right
Sparkeats restaurant reviews
<br />
so you can eat right

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in d97c677.


<div className="home-header__button">
<a className="button__header-primary" href="/places/new">
Add a Review
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Add a Review
Add a Location

This should change because it will go to /locations/new not /reviews/new.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated in d69acaf.

@yosevu yosevu linked an issue Oct 30, 2022 that may be closed by this pull request
@yosevu yosevu added this to the Home Page milestone Oct 30, 2022
@yosevu
Copy link
Contributor

yosevu commented Dec 5, 2022

@arnest00, thanks for all the work you did building the Home Header! I'll address the remaining issues and get it merged.

@yosevu yosevu force-pushed the feat--rebuild-homepage-header branch from d97c677 to 9b6294b Compare December 5, 2022 12:43
@yosevu yosevu self-requested a review December 9, 2022 11:40
feat: create Subtitle component

feat: create LocationSelect component

feat: create HomeHeader component

style: fix linting errors

refactor: rename LocationSelect to LocationMenu

fix(a11y): select element must have an accessible name

fix(a11y): document does not have a main landmark

refactor: use consistent naming

Add a Review to Add a Location
All Places to All Locations

refactor: use React Router Link

refactor: move uniqueCities to locations data

refactor: rename Subtitle to SiteSubtitle

fix: update location data
@yosevu yosevu force-pushed the feat--rebuild-homepage-header branch from 9b6294b to e4a413a Compare December 9, 2022 11:45
@yosevu yosevu merged commit e4a413a into sparkbox:main Dec 9, 2022
@yosevu yosevu temporarily deployed to production December 9, 2022 11:54 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rebuild Home Header
2 participants