-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added nearby places to map on OfferScreen; Refactoring
- Loading branch information
Showing
10 changed files
with
194 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {Link} from 'react-router-dom'; | ||
import {AppRoute} from '../../consts.ts'; | ||
|
||
export function Header() { | ||
return ( | ||
<header className="header"> | ||
<div className="container"> | ||
<div className="header__wrapper"> | ||
<div className="header__left"> | ||
<Link to={AppRoute.Main} className="header__logo-link"> | ||
<img | ||
className="header__logo" | ||
src="img/logo.svg" | ||
alt="6 cities logo" | ||
width={81} | ||
height={41} | ||
/> | ||
</Link> | ||
</div> | ||
<nav className="header__nav"> | ||
<ul className="header__nav-list"> | ||
<li className="header__nav-item user"> | ||
<a | ||
className="header__nav-link header__nav-link--profile" | ||
href="#" | ||
> | ||
<div className="header__avatar-wrapper user__avatar-wrapper"></div> | ||
<span className="header__user-name user__name"> | ||
[email protected] | ||
</span> | ||
<span className="header__favorite-count">3</span> | ||
</a> | ||
</li> | ||
<li className="header__nav-item"> | ||
<a className="header__nav-link" href="#"> | ||
<span className="header__signout">Sign out</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> | ||
</header> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import {Offer} from '../../types/offer.ts'; | ||
import {PlaceCard} from './place-card.tsx'; | ||
import {Nullable} from 'vitest'; | ||
import {PlaceCardType} from '../../consts.ts'; | ||
|
||
type GeneralPlaceCardListCommonProps = { | ||
offers: Offer[]; | ||
onActiveItemChange?: (id: Nullable<string>) => void; | ||
imageWidth: number; | ||
imageHeight: number; | ||
className: string; | ||
placeCardType: PlaceCardType; | ||
}; | ||
|
||
function GeneralPlaceCardList({ | ||
offers, | ||
onActiveItemChange, | ||
imageWidth, | ||
imageHeight, | ||
className, | ||
placeCardType, | ||
}: GeneralPlaceCardListCommonProps) { | ||
return ( | ||
<div className={className}> | ||
{ | ||
offers.map((offer) => ( | ||
<PlaceCard | ||
key={offer.id} | ||
{...offer} | ||
imageSrc={offer.previewImage} | ||
width={imageWidth} | ||
height={imageHeight} | ||
placeCardType={placeCardType} | ||
onActiveItemChange={onActiveItemChange} | ||
/> | ||
)) | ||
} | ||
</div> | ||
); | ||
} | ||
|
||
type PlaceCardListProps = { | ||
offers: Offer[]; | ||
onActiveItemChange?: (id: Nullable<string>) => void; | ||
} | ||
|
||
export function CityPlaceCardList(props: PlaceCardListProps) { | ||
return ( | ||
<GeneralPlaceCardList | ||
{...props} | ||
imageWidth={260} | ||
imageHeight={200} | ||
className="cities__places-list places__list tabs__content" | ||
placeCardType={PlaceCardType.City} | ||
/> | ||
); | ||
} | ||
|
||
export function NearPlaceCardList(props: PlaceCardListProps) { | ||
return ( | ||
<GeneralPlaceCardList | ||
{...props} | ||
imageWidth={260} | ||
imageHeight={200} | ||
className="near-places__list places__list" | ||
placeCardType={PlaceCardType.Near} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import {Offer} from '../../types/offer.ts'; | ||
import {FavoritesList} from '../../components/favorites-list/favorites-list.tsx'; | ||
import {FavoritePlaceCardList} from '../../components/favorites-list/favorite-place-card-list.tsx'; | ||
import {Header} from '../../components/header/header.tsx'; | ||
|
||
type FavoritesScreenProps = { | ||
offers: Offer[]; | ||
|
@@ -8,40 +9,14 @@ type FavoritesScreenProps = { | |
export function FavoritesScreen({offers}: FavoritesScreenProps) { | ||
return ( | ||
<div className="page"> | ||
<header className="header"> | ||
<div className="container"> | ||
<div className="header__wrapper"> | ||
<div className="header__left"> | ||
<a className="header__logo-link" href="main.html"> | ||
<img className="header__logo" src="img/logo.svg" alt="6 cities logo" width="81" height="41"/> | ||
</a> | ||
</div> | ||
<nav className="header__nav"> | ||
<ul className="header__nav-list"> | ||
<li className="header__nav-item user"> | ||
<a className="header__nav-link header__nav-link--profile" href="#"> | ||
<div className="header__avatar-wrapper user__avatar-wrapper"> | ||
</div> | ||
<span className="header__user-name user__name">[email protected]</span> | ||
<span className="header__favorite-count">3</span> | ||
</a> | ||
</li> | ||
<li className="header__nav-item"> | ||
<a className="header__nav-link" href="#"> | ||
<span className="header__signout">Sign out</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> | ||
</header> | ||
<Header/> | ||
|
||
<main className="page__main page__main--favorites"> | ||
<div className="page__favorites-container container"> | ||
<section className="favorites"> | ||
<h1 className="favorites__title">Saved listing</h1> | ||
<FavoritesList | ||
|
||
<FavoritePlaceCardList | ||
offers={offers} | ||
/> | ||
</section> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import {Offer} from '../../types/offer.ts'; | ||
import {OffersList} from '../../components/offers-list/offers-list.tsx'; | ||
import {Map} from '../../components/map/map.tsx'; | ||
import {useState} from 'react'; | ||
import {Nullable} from 'vitest'; | ||
import {Header} from '../../components/header/header.tsx'; | ||
import {CityPlaceCardList} from '../../components/place-card/place-card-list.tsx'; | ||
|
||
type MainScreenProps = { | ||
offers: Offer[]; | ||
|
@@ -18,34 +19,8 @@ export function MainScreen({offers}: MainScreenProps) { | |
|
||
return ( | ||
<div className="page page--gray page--main"> | ||
<header className="header"> | ||
<div className="container"> | ||
<div className="header__wrapper"> | ||
<div className="header__left"> | ||
<a className="header__logo-link header__logo-link--active"> | ||
<img className="header__logo" src="img/logo.svg" alt="6 cities logo" width="81" height="41"/> | ||
</a> | ||
</div> | ||
<nav className="header__nav"> | ||
<ul className="header__nav-list"> | ||
<li className="header__nav-item user"> | ||
<a className="header__nav-link header__nav-link--profile" href="#"> | ||
<div className="header__avatar-wrapper user__avatar-wrapper"> | ||
</div> | ||
<span className="header__user-name user__name">[email protected]</span> | ||
<span className="header__favorite-count">3</span> | ||
</a> | ||
</li> | ||
<li className="header__nav-item"> | ||
<a className="header__nav-link" href="#"> | ||
<span className="header__signout">Sign out</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> | ||
</header> | ||
<Header/> | ||
|
||
<main className="page__main page__main--index"> | ||
<h1 className="visually-hidden">Cities</h1> | ||
<div className="tabs"> | ||
|
@@ -104,9 +79,9 @@ export function MainScreen({offers}: MainScreenProps) { | |
<li className="places__option" tabIndex={0}>Top rated first</li> | ||
</ul> | ||
</form> | ||
<OffersList | ||
<CityPlaceCardList | ||
offers={offers} | ||
onActiveOfferChange={handleActiveOfferChange} | ||
onActiveItemChange={handleActiveOfferChange} | ||
/> | ||
</section> | ||
|
||
|
Oops, something went wrong.