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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
// for example media object known from OOCSS.
@import 'scss/objects/review-page';
@import 'scss/objects/homepage';
@import 'scss/objects/home-header';

// =====================================================================
// 6. Components
Expand All @@ -76,9 +77,9 @@
@import 'scss/components/review-header';
@import 'scss/components/review-nav';
@import 'scss/components/review-submission';
@import 'scss/components/sparkeats-subtitle';
@import 'scss/components/location-dropdown';
@import 'scss/components/site-subtitle';
@import 'scss/components/location-new';
@import 'scss/components/location-select';

// =====================================================================
// 7. Vendors
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SiteHeader } from './components/SiteHeader';

export function App() {
return (
<div>
<main>
<SiteHeader />
<Outlet />
</div>
</main>
);
}
21 changes: 21 additions & 0 deletions src/components/HomeHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Link } from 'react-router-dom';
import SiteSubtitle from './SiteSubtitle';
import LocationMenu from './LocationMenu';

function HomeHeader() {
return (
<div className="home-header">
<SiteSubtitle />

<LocationMenu />

<div className="home-header__button">
<Link className="button__header-primary" to="/locations/new">
Add a Location
</Link>
</div>
</div>
);
}

export default HomeHeader;
3 changes: 2 additions & 1 deletion src/components/HomePage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import HomeHeader from '../HomeHeader';
import { LocationCards } from './LocationCards';
import { useLocations } from '../../useLocations';

Expand All @@ -6,7 +7,7 @@ export function HomePage() {

return (
<div className="homepage">
<header>Home Header</header>
<HomeHeader />
<LocationCards locations={locations} />
</div>
);
Expand Down
24 changes: 24 additions & 0 deletions src/components/LocationMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { uniqueCities } from '../locations';

function LocationMenu() {
return (
<div className="location-select">
<h2 className="location-select__title">
<label htmlFor="location">Select a Location</label>
</h2>

<select className="location-select__menu" name="location" id="location">
<option className="location-select__option" value="all">
All Cities
</option>
{uniqueCities.map((city: string) => (
<option key={city} value={city}>
{city}
</option>
))}
</select>
</div>
);
}

export default LocationMenu;
5 changes: 5 additions & 0 deletions src/components/SiteSubtitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function SiteSubtitle() {
return <p className="site-subtitle">Food reviews and restaurant ratings</p>;
}

export default SiteSubtitle;
9 changes: 8 additions & 1 deletion src/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ function transformLocations(legacyPlaces: LegacyPlace[]): Locations {
.reduce(mapLocation, {});
}

function getUniqueCities(locations: Locations): string[] {
return Array.from(
new Set(Object.values(locations).map((location) => location.city))
);
}

const locations = transformLocations(legacyPlaces);
const uniqueCities = getUniqueCities(locations);

export { locations };
export { locations, uniqueCities };
87 changes: 0 additions & 87 deletions src/scss/components/_location-dropdown.scss

This file was deleted.

45 changes: 45 additions & 0 deletions src/scss/components/_location-select.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.location-select {
@media (min-width: $bp-grid-three-col) {
width: 33%;
}

&__title {
font-family: $roboto-stack;
font-size: 1rem;
margin-bottom: 0.5rem;
}

&__menu {
appearance: none;
cursor: pointer;
box-sizing: border-box;
width: 100%;
border: 1px solid #4f4f4f;
padding: 0.5rem;
background-color: $tertiary-color;
font-family: $roboto-stack;
text-transform: capitalize;
letter-spacing: inherit;
word-spacing: inherit;
line-height: 120%;

// Custom select arrow
padding-right: 1.5rem;
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?

}

&__button .location-select {
&__button-arrow {
display: block;
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.

border: solid $accent-color;
border-width: 0.15rem 0.15rem 0 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.sparkeats-subtitle {
.site-subtitle {
font-family: $oswald-stack;
font-size: 2rem;
font-weight: $oswald-bold;
Expand Down
12 changes: 12 additions & 0 deletions src/scss/objects/_home-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.home-header {
margin: 4rem auto 5rem;
width: 80%;

&__button {
margin-top: 2rem;

@media (min-width: 64rem) {
width: 33%;
}
}
}
5 changes: 0 additions & 5 deletions src/scss/objects/_homepage.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
.homepage {
padding-top: 1px;

&__header {
margin: 4rem auto 5rem;
width: 80%;
}

&__cards {
margin: 2rem auto 4rem;
width: 80%;
Expand Down