-
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.
- Loading branch information
Showing
29 changed files
with
1,089 additions
and
344 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 was deleted.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
src/components/comment-submission-form/comment-submission-form.tsx
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,132 @@ | ||
import {ChangeEvent, useState} from 'react'; | ||
|
||
function CommentSubmissionForm(): JSX.Element { | ||
const [formData, setFormData] = useState({ | ||
rating: 0, | ||
review: '', | ||
}); | ||
|
||
function handleFieldChange<T extends HTMLInputElement | HTMLTextAreaElement>(evt: ChangeEvent<T>) { | ||
const {name, value} = evt.target; | ||
setFormData({...formData, [name]: value}); | ||
} | ||
|
||
return ( | ||
<form className="reviews__form form" action="#" method="post"> | ||
<label className="reviews__label form__label" htmlFor="review"> | ||
Your review | ||
</label> | ||
<div className="reviews__rating-form form__rating"> | ||
<input | ||
onChange={handleFieldChange} | ||
className="form__rating-input visually-hidden" | ||
name="rating" | ||
defaultValue={5} | ||
id="5-stars" | ||
type="radio" | ||
/> | ||
<label | ||
htmlFor="5-stars" | ||
className="reviews__rating-label form__rating-label" | ||
title="perfect" | ||
> | ||
<svg className="form__star-image" width={37} height={33}> | ||
<use xlinkHref="#icon-star"/> | ||
</svg> | ||
</label> | ||
<input | ||
onChange={handleFieldChange} | ||
className="form__rating-input visually-hidden" | ||
name="rating" | ||
defaultValue={4} | ||
id="4-stars" | ||
type="radio" | ||
/> | ||
<label | ||
htmlFor="4-stars" | ||
className="reviews__rating-label form__rating-label" | ||
title="good" | ||
> | ||
<svg className="form__star-image" width={37} height={33}> | ||
<use xlinkHref="#icon-star"/> | ||
</svg> | ||
</label> | ||
<input | ||
className="form__rating-input visually-hidden" | ||
name="rating" | ||
defaultValue={3} | ||
id="3-stars" | ||
type="radio" | ||
/> | ||
<label | ||
htmlFor="3-stars" | ||
className="reviews__rating-label form__rating-label" | ||
title="not bad" | ||
> | ||
<svg className="form__star-image" width={37} height={33}> | ||
<use xlinkHref="#icon-star"/> | ||
</svg> | ||
</label> | ||
<input | ||
onChange={handleFieldChange} | ||
className="form__rating-input visually-hidden" | ||
name="rating" | ||
defaultValue={2} | ||
id="2-stars" | ||
type="radio" | ||
/> | ||
<label | ||
htmlFor="2-stars" | ||
className="reviews__rating-label form__rating-label" | ||
title="badly" | ||
> | ||
<svg className="form__star-image" width={37} height={33}> | ||
<use xlinkHref="#icon-star"/> | ||
</svg> | ||
</label> | ||
<input | ||
onChange={handleFieldChange} | ||
className="form__rating-input visually-hidden" | ||
name="rating" | ||
defaultValue={1} | ||
id="1-star" | ||
type="radio" | ||
/> | ||
<label | ||
htmlFor="1-star" | ||
className="reviews__rating-label form__rating-label" | ||
title="terribly" | ||
> | ||
<svg className="form__star-image" width={37} height={33}> | ||
<use xlinkHref="#icon-star"/> | ||
</svg> | ||
</label> | ||
</div> | ||
<textarea | ||
onChange={handleFieldChange} | ||
className="reviews__textarea form__textarea" | ||
id="review" | ||
name="review" | ||
placeholder="Tell how was your stay, what you like and what can be improved" | ||
defaultValue={''} | ||
/> | ||
<div className="reviews__button-wrapper"> | ||
<p className="reviews__help"> | ||
To submit review please make sure to set{' '} | ||
<span className="reviews__star">rating</span> and describe your stay with | ||
at least <b className="reviews__text-amount">50 characters</b>. | ||
</p> | ||
<button | ||
className="reviews__submit form__submit button" | ||
type="submit" | ||
disabled | ||
> | ||
Submit | ||
</button> | ||
</div> | ||
</form> | ||
|
||
); | ||
} | ||
|
||
export default CommentSubmissionForm; |
19 changes: 19 additions & 0 deletions
19
src/components/favorite-mark-button/favorite-mark-button.tsx
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 FavoriteMarkButtonProps = { | ||
inFavorites?: boolean; | ||
} | ||
|
||
function FavoriteMarkButton({ inFavorites } : FavoriteMarkButtonProps) : JSX.Element { | ||
return ( | ||
<button className={ | ||
'place-card__bookmark-button button'.concat(!inFavorites ? '' : ' place-card__bookmark-button--active') | ||
} type="button" | ||
> | ||
<svg className="place-card__bookmark-icon" width="18" height="19"> | ||
<use xlinkHref="#icon-bookmark"></use> | ||
</svg> | ||
<span className="visually-hidden">To bookmarks</span> | ||
</button> | ||
); | ||
} | ||
|
||
export default FavoriteMarkButton; |
47 changes: 47 additions & 0 deletions
47
src/components/favorite-place-card/favorite-place-card.tsx
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,47 @@ | ||
import {OfferShort} from '../../types/offers/offer-short.ts'; | ||
import PremiumSign from '../premium-sign/premium-sign.tsx'; | ||
import PlaceCardRating from '../place-card/place-card-rating.tsx'; | ||
import PlaceCardTitle from '../place-card/place-card-title.tsx'; | ||
import PlaceCardPrice from '../place-card/place-card-price.tsx'; | ||
import FavoriteMarkButton from '../favorite-mark-button/favorite-mark-button.tsx'; | ||
import {Link} from 'react-router-dom'; | ||
import {AppRoute} from '../../const.ts'; | ||
|
||
type FavoritePlaceCardProps = { | ||
placeShortInfo: OfferShort; | ||
} | ||
|
||
function FavoritePlaceCard({ placeShortInfo } : FavoritePlaceCardProps) : JSX.Element { | ||
const { | ||
id, | ||
type, | ||
title, | ||
price, | ||
previewImage, | ||
rating, | ||
isFavorite, | ||
isPremium} = placeShortInfo; | ||
|
||
return ( | ||
<article key={id} className="favorites__card place-card"> | ||
<PremiumSign show={isPremium}/> | ||
<div className="favorites__image-wrapper place-card__image-wrapper"> | ||
<Link to={`${AppRoute.Offer}/${id}`}> | ||
<img className="place-card__image" src={previewImage} width="150" height="110" | ||
alt="Place image" | ||
/> | ||
</Link> | ||
</div> | ||
<div className="favorites__card-info place-card__info"> | ||
<div className="place-card__price-wrapper"> | ||
<PlaceCardPrice price={price}/> | ||
<FavoriteMarkButton inFavorites={isFavorite}/> | ||
</div> | ||
<PlaceCardRating value={rating}/> | ||
<PlaceCardTitle type={type} name={title} id={id}/> | ||
</div> | ||
</article> | ||
); | ||
} | ||
|
||
export default FavoritePlaceCard; |
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,28 @@ | ||
import {OffersShort} from '../../types/offers/offer-short.ts'; | ||
import FavoritePlaceCard from '../favorite-place-card/favorite-place-card.tsx'; | ||
|
||
type FavoritesListElementProps = { | ||
favoritesAtCity: OffersShort; | ||
cityName: string; | ||
} | ||
|
||
function FavoritesListElement({favoritesAtCity, cityName}: FavoritesListElementProps): JSX.Element { | ||
return ( | ||
<li className="favorites__locations-items"> | ||
<div className="favorites__locations locations locations--current"> | ||
<div className="locations__item"> | ||
<a className="locations__item-link" href="#"> | ||
<span>{cityName}</span> | ||
</a> | ||
</div> | ||
</div> | ||
<div className="favorites__places"> | ||
{favoritesAtCity.map((offer) => ( | ||
<FavoritePlaceCard key={offer.id} placeShortInfo={offer}/> | ||
))} | ||
</div> | ||
</li> | ||
); | ||
} | ||
|
||
export default FavoritesListElement; |
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,32 @@ | ||
import {OffersShort} from '../../types/offers/offer-short.ts'; | ||
import {AvailableCities} from '../../const.ts'; | ||
import FavoritesListElement from './favorites-list-element.tsx'; | ||
import {Fragment} from 'react'; | ||
|
||
type FavoritesListProps = { | ||
allFavorites: OffersShort; | ||
} | ||
|
||
function FavoritesList({ allFavorites } : FavoritesListProps) : JSX.Element { | ||
const allAvailableCities = Object.keys(AvailableCities); | ||
const cityFilteredFavorites = | ||
allAvailableCities | ||
.map((city) => ( | ||
{[city]: allFavorites.filter((card) => card.city.name === city)} | ||
)) | ||
.reduce((accumulator, value) => ({...accumulator, ...value}), {}); | ||
|
||
|
||
return ( | ||
<ul className="favorites__list"> | ||
{Object.keys(cityFilteredFavorites).map((city) => ( | ||
<Fragment key={city}> | ||
{cityFilteredFavorites[city].length === 0 ? null : | ||
<FavoritesListElement favoritesAtCity={cityFilteredFavorites[city]} cityName={city}/>} | ||
</Fragment> | ||
))} | ||
</ul> | ||
); | ||
} | ||
|
||
export default FavoritesList; |
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,14 +1,17 @@ | ||
import {Link} from 'react-router-dom'; | ||
import {AppRoute} from '../../const.ts'; | ||
|
||
function HeaderNavigation(): JSX.Element { | ||
return ( | ||
<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="#"> | ||
<Link className="header__nav-link header__nav-link--profile" to={AppRoute.Favourites}> | ||
<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> | ||
</Link> | ||
</li> | ||
<li className="header__nav-item"> | ||
<a className="header__nav-link" href="#"> | ||
|
Oops, something went wrong.