-
Notifications
You must be signed in to change notification settings - Fork 55
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
13 changed files
with
192 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@use '../../styles/variables'; | ||
@use '../../styles/theme'; | ||
@use '../../styles/mixins/responsive'; | ||
|
||
.header { | ||
display: flex; | ||
margin-bottom: variables.$base-spacing * 1.5; | ||
} | ||
|
||
h3 { | ||
margin-right: variables.$base-spacing * 1.5; | ||
font-weight: bold; | ||
font-size: 34px; | ||
font-style: normal; | ||
line-height: 36px; | ||
letter-spacing: 0.25px; | ||
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.14), 0 3px 4px rgba(0, 0, 0, 0.12), 0 1px 5px rgba(0, 0, 0, 0.2); | ||
} |
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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import QueryProvider from '../../providers/QueryProvider'; | ||
import { PersonalShelf } from '../../enum/PersonalShelf'; | ||
import PlaylistContainer from '../../containers/Playlist/PlaylistContainer'; | ||
|
||
import Favorites from './Favorites'; | ||
|
||
describe('<Favorites>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render( | ||
<QueryProvider> | ||
<PlaylistContainer playlistId={PersonalShelf.Favorites}> | ||
{({ playlist, error, isLoading }) => ( | ||
<Favorites | ||
playlist={playlist.playlist} | ||
error={error} | ||
isLoading={isLoading} | ||
onCardClick={() => null} | ||
onCardHover={() => null} | ||
onClearFavoritesClick={() => null} | ||
/> | ||
)} | ||
</PlaylistContainer> | ||
</QueryProvider>, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,60 @@ | ||
import React, { useContext } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import type { PlaylistItem } from 'types/playlist'; | ||
import type { Config } from 'types/Config'; | ||
|
||
import { ConfigContext } from '../../providers/ConfigProvider'; | ||
import Button from '../Button/Button'; | ||
import CardGrid from '../CardGrid/CardGrid'; | ||
import LoadingOverlay from '../LoadingOverlay/LoadingOverlay'; | ||
import ErrorPage from '../ErrorPage/ErrorPage'; | ||
import { Breakpoint, Breakpoints } from '../../hooks/useBreakpoint'; | ||
|
||
import styles from './Favorites.module.scss'; | ||
|
||
type Props = { | ||
playlist: PlaylistItem[]; | ||
error: unknown; | ||
isLoading: boolean; | ||
onCardClick: (item: PlaylistItem) => void; | ||
onCardHover: (item: PlaylistItem) => void; | ||
onClearFavoritesClick: () => void; | ||
}; | ||
|
||
const cols: Breakpoints = { | ||
[Breakpoint.xs]: 2, | ||
[Breakpoint.sm]: 3, | ||
[Breakpoint.md]: 3, | ||
[Breakpoint.lg]: 3, | ||
[Breakpoint.xl]: 3, | ||
}; | ||
|
||
const Favorites = ({ playlist, error, isLoading, onCardClick, onCardHover, onClearFavoritesClick }: Props): JSX.Element => { | ||
const { t } = useTranslation('user'); | ||
const config: Config = useContext(ConfigContext); | ||
|
||
if (isLoading) return <LoadingOverlay />; | ||
|
||
if (error || !playlist) { | ||
return <ErrorPage title={t('favorites.not_found')} />; | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className={styles.header}> | ||
<h3>{t('favorites.title')}</h3> | ||
<Button label={t('favorites.clear')} onClick={onClearFavoritesClick} /> | ||
</div> | ||
<CardGrid | ||
playlist={playlist} | ||
onCardClick={onCardClick} | ||
onCardHover={onCardHover} | ||
cols={cols} | ||
isLoading={isLoading} | ||
enableCardTitles={config.options.shelveTitles} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Favorites; |
3 changes: 3 additions & 0 deletions
3
src/components/Favorites/__snapshots__/Favorites.test.tsx.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Favorites> renders and matches snapshot 1`] = `<div />`; |
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
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,30 +1,33 @@ | ||
{ | ||
"account": { | ||
"email": "Email", | ||
"about_you": "About you", | ||
"edit_account": "Edit account", | ||
"security": "Security", | ||
"password": "Password", | ||
"edit_information": "Edit information", | ||
"edit_password": "Edit password", | ||
"about_you": "About you", | ||
"email": "Email", | ||
"firstname": "First name", | ||
"lastname": "Last name", | ||
"edit_information": "Edit information", | ||
"terms_and_tracking": "Terms & tracking", | ||
"password": "Password", | ||
"security": "Security", | ||
"update_consents": "Update consents" | ||
}, | ||
"favorites": { | ||
"clear": "Clear favorites", | ||
"not_found": "Favorites not found!", | ||
"title": "Favorites" | ||
}, | ||
"payment": { | ||
"subscription_details": "Subscription details", | ||
"card_number": "Card number", | ||
"cvc_cvv": "CVC / CVV", | ||
"edit_subscription": "Edit subscription", | ||
"expiry_date": "Expiry date", | ||
"month": "month", | ||
"monthly_subscription": "Monthly subscription", | ||
"more_transactions": "{{ amount }} more transactions", | ||
"next_billing_date_on": "Next billing date is on", | ||
"month": "month", | ||
"edit_subscription": "Edit subscription", | ||
"payment_method": "Payment method", | ||
"card_number": "Card number", | ||
"expiry_date": "Expiry date", | ||
"cvc_cvv": "CVC / CVV", | ||
"transactions": "Transactions", | ||
"price_payed_with_card": "Price payed with card", | ||
"more_transactions": "{{ amount }} more transactions", | ||
"show_all": "Show all" | ||
"subscription_details": "Subscription details", | ||
"transactions": "Transactions" | ||
} | ||
} |
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,30 +1,33 @@ | ||
{ | ||
"account": { | ||
"email": "", | ||
"about_you": "", | ||
"edit_account": "", | ||
"security": "", | ||
"password": "", | ||
"edit_information": "", | ||
"edit_password": "", | ||
"about_you": "", | ||
"email": "", | ||
"firstname": "", | ||
"lastname": "", | ||
"edit_information": "", | ||
"terms_and_tracking": "", | ||
"password": "", | ||
"security": "", | ||
"update_consents": "" | ||
}, | ||
"favorites": { | ||
"clear": "", | ||
"not_found": "", | ||
"title": "" | ||
}, | ||
"payment": { | ||
"subscription_details": "", | ||
"card_number": "", | ||
"cvc_cvv": "", | ||
"edit_subscription": "", | ||
"expiry_date": "", | ||
"month": "", | ||
"monthly_subscription": "", | ||
"more_transactions": "", | ||
"next_billing_date_on": "", | ||
"month": "", | ||
"edit_subscription": "", | ||
"payment_method": "", | ||
"card_number": "", | ||
"expiry_date": "", | ||
"cvc_cvv": "", | ||
"transactions": "", | ||
"price_payed_with_card": "", | ||
"more_transactions": "", | ||
"show_all": "" | ||
"subscription_details": "", | ||
"transactions": "" | ||
} | ||
} |
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