-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
1adb639
to
4e519fe
Compare
src/components/LocationSelect.tsx
Outdated
<div className="location-select"> | ||
<h2 className="location-select__title">Pick a Location</h2> | ||
|
||
<select className="location-select__menu" name="location" id="location"> |
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.
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.
src/components/LocationSelect.tsx
Outdated
locations: Location[]; | ||
}; | ||
|
||
function LocationSelect({ locations }: LocationSelectProps) { |
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 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.
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.
Updated in 3217ecf.
src/components/LocationSelect.tsx
Outdated
|
||
return ( | ||
<div className="location-select"> | ||
<h2 className="location-select__title">Pick a Location</h2> |
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 scanned the page with axe DevTools and found one critical issue.
I think we need to replace this with a label
and update the styles if necessary.
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.
Updated in f5f7392.
src/components/LocationSelect.tsx
Outdated
|
||
<select className="location-select__menu" name="location" id="location"> | ||
<option className="location-select__option" value="all"> | ||
All Places |
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.
See the note about replacing instances of "place" with "location" in the requirements #432!
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.
Updated in d69acaf.
src/components/HomeHeader.tsx
Outdated
<LocationSelect locations={locations} /> | ||
|
||
<div className="home-header__button"> | ||
<a className="button__header-primary" href="/places/new"> |
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.
Can we replace this with a React Router Link?
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.
Updated in 0bb1a96.
src/components/LocationSelect.tsx
Outdated
const allCities = locations.map((location) => location.city); | ||
const uniqueCities = [...new Set(allCities)]; |
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.
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.
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.
Updated in 7e978d4.
src/components/LocationSelect.tsx
Outdated
<div className="location-select"> | ||
<h2 className="location-select__title">Pick a Location</h2> | ||
|
||
<select className="location-select__menu" name="location" id="location"> |
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 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>"); |
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 great. What was your reasoning for changing this to an SVG?
float: right; | ||
height: 0.5em; | ||
width: 0.5em; | ||
transform: rotate(135deg); |
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.
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.
Address ins #432.
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.
src/scss/components/_subtitle.scss
Outdated
@@ -1,4 +1,4 @@ | |||
.sparkeats-subtitle { | |||
.subtitle { |
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.
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?
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.
Updated in d97c677.
src/components/Subtitle.tsx
Outdated
sparkboxers review food and | ||
<br /> | ||
drink places so you can eat right |
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 think we should change the wording here to be more general since the audience is no longer only people at Sparkbox.
sparkboxers review food and | |
<br /> | |
drink places so you can eat right | |
Sparkeats restaurant reviews | |
<br /> | |
so you can eat right |
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.
Updated in d97c677.
src/components/HomeHeader.tsx
Outdated
|
||
<div className="home-header__button"> | ||
<a className="button__header-primary" href="/places/new"> | ||
Add a Review |
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.
Add a Review | |
Add a Location |
This should change because it will go to /locations/new
not /reviews/new
.
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.
Updated in d69acaf.
@arnest00, thanks for all the work you did building the Home Header! I'll address the remaining issues and get it merged. |
d97c677
to
9b6294b
Compare
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
9b6294b
to
e4a413a
Compare
This pull request addresses issue #402.
What changed?
HomeHeader
componentLocationSelect
componentSubtitle
componentTaking some cues from this article about using custom select menus, I opted to use a native
select
menu inLocationSelect
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?
Screenshots