-
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.
major changes. add a lot of conditional rendering, change components,…
… add mocks, add utils
- Loading branch information
Showing
35 changed files
with
548 additions
and
258 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import classNames from 'classnames'; | ||
import {useBookmarkButton} from '../../hooks/use-bookmark-button.ts'; | ||
import {BookmarkButtonVariants} from '../../types/variants.ts'; | ||
|
||
type BookmarkButtonProps = { | ||
inFavorites?: boolean; | ||
variant: BookmarkButtonVariants; | ||
} | ||
|
||
function BookmarkButton({inFavorites, variant}: BookmarkButtonProps): JSX.Element { | ||
const { | ||
buttonMainClassName, | ||
buttonActiveClassName, | ||
svgClassName, | ||
svgWidth, | ||
svgHeight | ||
} = useBookmarkButton({variant}); | ||
|
||
const buttonFullClassName = classNames( | ||
buttonMainClassName, | ||
{[`${buttonActiveClassName}`]: inFavorites} | ||
); | ||
|
||
return ( | ||
<button className={buttonFullClassName} type="button"> | ||
<svg className={svgClassName} width={svgWidth} height={svgHeight}> | ||
<use xlinkHref="#icon-bookmark"></use> | ||
</svg> | ||
<span className="visually-hidden">To bookmarks</span> | ||
</button> | ||
); | ||
} | ||
|
||
export default BookmarkButton; |
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
19 changes: 0 additions & 19 deletions
19
src/components/favorite-mark-button/favorite-mark-button.tsx
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
src/components/favorite-place-card/favorite-place-card.tsx
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
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 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,20 @@ | ||
import {Link} from 'react-router-dom'; | ||
import {AppRoute} from '../../const.ts'; | ||
import classNames from 'classnames'; | ||
|
||
type LogoHeaderProps = { | ||
isActive?: boolean; | ||
} | ||
|
||
function LogoHeader({isActive} : LogoHeaderProps) : JSX.Element { | ||
const className = classNames('header__logo-link' , {'header__logo-link--active' : isActive}); | ||
return ( | ||
<div className="header__left"> | ||
<Link to={AppRoute.Main} className={className}> | ||
<img className="header__logo" src="/img/logo.svg" alt="6 cities logo" width="81" height="41"/> | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export default LogoHeader; |
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,31 @@ | ||
import {City} from '../../types/city.ts'; | ||
import {useEffect, useRef} from 'react'; | ||
import useMap from '../../hooks/use-map.ts'; | ||
import {Locations} from '../../types/location.ts'; | ||
import leaflet from 'leaflet'; | ||
import 'leaflet/dist/leaflet.css'; | ||
|
||
type MapProps = { | ||
city: City; | ||
points: Locations; | ||
}; | ||
|
||
function Map({city, points} : MapProps) : JSX.Element { | ||
const mapRef = useRef(null); | ||
const map = useMap({mapRef, center:city.location}); | ||
|
||
useEffect(() => { | ||
if (map) { | ||
points.forEach((point) => { | ||
leaflet | ||
.marker({ | ||
lat: point.latitude, | ||
lng: point.longitude, | ||
}).addTo(map); | ||
}); | ||
} | ||
}, [map, points]); | ||
return <section className="cities__map map" ref={mapRef}></section>; | ||
} | ||
|
||
export default Map; |
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,63 @@ | ||
import {OfferShort} from '../../../types/offers/offer-short.ts'; | ||
import PremiumSign from '../../premium-sign/premium-sign.tsx'; | ||
import BookmarkButton from '../../bookmark-button/bookmark-button.tsx'; | ||
import {Link} from 'react-router-dom'; | ||
import {AppRoute} from '../../../const.ts'; | ||
import Rating from '../../rating/rating.tsx'; | ||
import OfferCardPrice from './offer-card-price.tsx'; | ||
import OfferCardTitle from './offer-card-title.tsx'; | ||
import {useOfferCard} from '../../../hooks/use-offer-card.ts'; | ||
import {OfferCardVariants} from '../../../types/variants.ts'; | ||
|
||
type PlaceCardProps = { | ||
placeShortInfo: OfferShort; | ||
variant: OfferCardVariants; | ||
} | ||
|
||
function OfferCard({placeShortInfo, variant}: PlaceCardProps): JSX.Element { | ||
const { | ||
id, | ||
title, | ||
type, | ||
price, | ||
isFavorite, | ||
isPremium, | ||
rating, | ||
previewImage | ||
} = placeShortInfo; | ||
|
||
const { | ||
placeCardClassName, | ||
cardInfoClassName, | ||
imageWrapperClassName, | ||
imageWidth, | ||
imageHeight | ||
} = useOfferCard({variant}); | ||
|
||
return ( | ||
<article className={placeCardClassName}> | ||
<PremiumSign show={isPremium} variant={'card'}/> | ||
<div className={imageWrapperClassName}> | ||
<Link to={`${AppRoute.Offer}/${id}`}> | ||
<img | ||
className="place-card__image" | ||
src={previewImage} | ||
width={imageWidth} | ||
height={imageHeight} | ||
alt="Place image" | ||
/> | ||
</Link> | ||
</div> | ||
<div className={cardInfoClassName}> | ||
<div className="place-card__price-wrapper"> | ||
<OfferCardPrice price={price}/> | ||
<BookmarkButton inFavorites={isFavorite} variant={'card'}/> | ||
</div> | ||
<Rating value={rating} variant={'card'}/> | ||
<OfferCardTitle type={type} name={title} id={id}/> | ||
</div> | ||
</article> | ||
); | ||
} | ||
|
||
export default OfferCard; |
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,19 @@ | ||
type OfferGalleryProps = { | ||
images: string[]; | ||
} | ||
|
||
function OfferGallery({ images } : OfferGalleryProps) { | ||
return ( | ||
<div className="offer__gallery-container container"> | ||
<div className="offer__gallery"> | ||
{images.map((imageLink) => ( | ||
<div key={imageLink} className="offer__image-wrapper"> | ||
<img className="offer__image" src={imageLink} alt="Photo studio"/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default OfferGallery; |
Oops, something went wrong.