Skip to content

Commit

Permalink
Merge branch 'develop' into feat/sprint-4-fixes-and-improvements
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/Button/Button.module.scss
#	src/components/CardGrid/CardGrid.tsx
#	src/components/Header/Header.tsx
#	src/components/Layout/Layout.tsx
#	src/components/Shelf/Shelf.tsx
#	src/screens/Home/Home.tsx
#	src/screens/Series/Series.tsx
  • Loading branch information
ChristiaanScheermeijer committed Jun 24, 2021
2 parents 27616cb + 5290a41 commit 5216923
Show file tree
Hide file tree
Showing 37 changed files with 267 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 140
"printWidth": 150
}
22 changes: 4 additions & 18 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
},
"content": [
{
"backgroundColor": "#C105FA",
"enableText": true,
"featured": true,
"playlistId": "CJE23b5T"
},
{
"backgroundColor": "#C105FA",
"enableText": true,
"playlistId": "sR5VypYk"
},
{
"backgroundColor": "#C105FA",
"enableText": true,
"playlistId": "o45EkQBf"
}
Expand All @@ -38,24 +35,13 @@
"options": {
"dynamicBlur": true,
"posterFading": true,
"backgroundColor": "#D42828",
"enableAddToHome": false,
"backgroundColor": null,
"shelveTitles": true,
"enableContinueWatching": true,
"enableCookieNotice": false,
"enableHeader": true,
"enableInVideoSearch": false,
"highlightColor": "#CCCCCC",
"rightRail": {
"enabled": true
},
"showcaseContentOnly": false,
"useRecommendationsPlaylist": true,
"videoTitlePosition": "above"
"highlightColor": null
},
"player": "7xMa4gNw",
"recommendationsPlaylist": "fuD6TWcf",
"searchPlaylist": "tQ832H1H",
"siteName": "Blender",
"theme": "dark",
"version": "2"
"siteName": "Blender"
}
17 changes: 11 additions & 6 deletions src/components/Animation/Animation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,31 @@ const Animation = ({
const seconds = duration / 1000;
const transition = `transform ${seconds}s ease-out`; // todo: -webkit-transform;

const timeout = useRef<NodeJS.Timeout>();
const timeout2 = useRef<NodeJS.Timeout>();
const timeout = useRef<number>();
const timeout2 = useRef<number>();

useEffect(() => {
if (timeout.current) clearTimeout(timeout.current);
if (timeout2.current) clearTimeout(timeout2.current);
if (open) {
setHasOpenedBefore(true);
timeout.current = setTimeout(() => setStatus('opening'), delay);
timeout2.current = setTimeout(() => {
timeout.current = window.setTimeout(() => setStatus('opening'), delay);
timeout2.current = window.setTimeout(() => {
setStatus('open');
onOpenAnimationEnd && onOpenAnimationEnd();
}, duration + delay);
} else if (hasOpenedBefore) {
timeout.current = setTimeout(() => setStatus('closing'), delay);
timeout2.current = setTimeout(() => {
timeout.current = window.setTimeout(() => setStatus('closing'), delay);
timeout2.current = window.setTimeout(() => {
setStatus('closed');
onCloseAnimationEnd && onCloseAnimationEnd();
}, duration + delay);
}

return () => {
clearTimeout(timeout.current);
clearTimeout(timeout2.current);
};
}, [duration, delay, transition, open, onOpenAnimationEnd, onCloseAnimationEnd, hasOpenedBefore, setHasOpenedBefore]);

if (!open && status === 'closed') {
Expand Down
30 changes: 18 additions & 12 deletions src/components/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ $large-button-height: 40px;
cursor: pointer;
transition: background-color 0.1s ease, transform 0.1s ease;

@media (hover: hover) and (pointer: fine) {
&:hover,
&:focus {
transform: scale(1.1);
}
&:focus:not(:focus-visible):not(:hover) {
transform: scale(1);
}
&:focus-visible {
transform: scale(1.1);
}
}

&.large {
height: $large-button-height;
}
Expand All @@ -35,15 +48,15 @@ $large-button-height: 40px;
}

&.primary {
color: var(--highlight-contrast-color, white);
background-color: var(--highlight-color, black);
color: var(--highlight-contrast-color, theme.$btn-primary-color);
background-color: var(--highlight-color, theme.$btn-primary-bg);
}

&.outlined {
border: 1px solid rgba(255, 255, 255, 0.3);

&.active,
&:focus {
&:focus-visible {
color: var(--highlight-contrast-color, white);
background-color: var(--highlight-color, black);
border-color: var(--highlight-color);
Expand All @@ -54,10 +67,10 @@ $large-button-height: 40px;
background: none;
opacity: 0.7;

&.active {
&.active,
&:focus {
opacity: 1;
}

&:hover {
z-index: 1;
background: theme.$btn-default-bg;
Expand All @@ -79,13 +92,6 @@ $large-button-height: 40px;
width: 18px;
height: 18px;
}

@media (hover: hover) and (pointer: fine) {
&:hover,
&:focus {
transform: scale(1.06);
}
}
}

.startIcon {
Expand Down
8 changes: 5 additions & 3 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Props = {
size?: 'medium' | 'large';
to?: string;
role?: string;
className?: string;
} & React.AriaAttributes;

const Button: React.FC<Props> = ({
Expand All @@ -34,9 +35,10 @@ const Button: React.FC<Props> = ({
size = 'medium',
to,
onClick,
className,
...rest
}: Props) => {
const className = classNames(styles.button, [styles[color]], [styles[variant]], {
const combinedClassNames = classNames(styles.button, className, [styles[color]], [styles[variant]], {
[styles.active]: active,
[styles.fullWidth]: fullWidth,
[styles.large]: size === 'large',
Expand All @@ -46,13 +48,13 @@ const Button: React.FC<Props> = ({
const span = <span className={styles.buttonLabel}>{label}</span>;

return to ? (
<NavLink className={className} to={to} activeClassName={styles.active} {...rest} exact>
<NavLink className={combinedClassNames} to={to} activeClassName={styles.active} {...rest} exact>
{icon}
{span}
{children}
</NavLink>
) : (
<button className={className} onClick={onClick} {...rest}>
<button className={combinedClassNames} onClick={onClick} {...rest}>
{icon}
{span}
{children}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
}

&.featured {

.title {
height: 1.1em;
padding-right: 8px;
Expand Down Expand Up @@ -129,7 +128,6 @@ $aspects: ((1, 1), (2, 1), (2, 3), (4, 3), (5, 3), (16, 9), (9, 16));
}

.title {

height: 2.4em;
overflow: hidden;
color: var(--card-color);
Expand Down Expand Up @@ -170,6 +168,7 @@ $aspects: ((1, 1), (2, 1), (2, 3), (4, 3), (5, 3), (16, 9), (9, 16));
font-family: var(--body-font-family);
font-weight: 600;
font-size: 13px;
white-space: nowrap;
background-color: rgba(variables.$black, 0.6);
border-radius: 4px;
@include responsive.mobile-only {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CardProps = {
loading?: boolean;
isCurrent?: boolean;
currentLabel?: string;
enableTitle?: boolean;
};

function Card({
Expand All @@ -35,6 +36,7 @@ function Card({
episodeNumber,
progress,
posterAspect = '16:9',
enableTitle = true,
featured = false,
disabled = false,
loading = false,
Expand Down Expand Up @@ -82,7 +84,7 @@ function Card({
{isCurrent && <div className={styles.currentLabel}>{currentLabel}</div>}
{!loading && (
<div className={styles.meta}>
{featured && !disabled && <div className={classNames(styles.title, { [styles.loading]: loading })}>{title}</div>}
{featured && !disabled && enableTitle && <div className={classNames(styles.title, { [styles.loading]: loading })}>{title}</div>}
{renderTag()}
</div>
)}
Expand All @@ -92,7 +94,7 @@ function Card({
</div>
) : null}
</div>
{!featured && !disabled && (
{!featured && !disabled && enableTitle && (
<div className={styles.titleContainer}>
<div className={classNames(styles.title, { [styles.loading]: loading })}>{title}</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions src/components/CardGrid/CardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ const defaultCols: Breakpoints = {
type CardGridProps = {
playlist: PlaylistItem[];
onCardHover?: (item: PlaylistItem) => void;
onCardClick: (item: PlaylistItem) => void;
onCardClick: (item: PlaylistItem, playlistId?: string) => void;
watchHistory?: { [key: string]: number };
isLoading: boolean;
enableCardTitles?: boolean;
cols?: Breakpoints;
currentCardItem?: PlaylistItem;
currentCardLabel?: string;
Expand All @@ -33,6 +34,7 @@ function CardGrid({
onCardClick,
onCardHover,
watchHistory,
enableCardTitles = true,
isLoading = false,
cols = defaultCols,
currentCardItem,
Expand All @@ -55,13 +57,14 @@ function CardGrid({
<Card
key={mediaid}
title={title}
enableTitle={enableCardTitles}
duration={duration}
posterSource={findPlaylistImageForWidth(playlistItem, imageSourceWidth)}
progress={watchHistory ? watchHistory[mediaid] : undefined}
seriesId={seriesId}
episodeNumber={episodeNumber}
seasonNumber={seasonNumber}
onClick={() => onCardClick(playlistItem)}
onClick={() => onCardClick(playlistItem, playlistItem.feedid)}
onHover={typeof onCardHover === 'function' ? () => onCardHover(playlistItem) : undefined}
loading={isLoading}
isCurrent={currentCardItem && currentCardItem.mediaid === mediaid}
Expand All @@ -74,7 +77,7 @@ function CardGrid({

return (
<div className={styles.container}>
<VirtualizedGrid rowCount={rows.length} cols={cols} cellRenderer={cellRenderer} spacing={50} />
<VirtualizedGrid rowCount={rows.length} cols={cols} cellRenderer={cellRenderer} spacing={enableCardTitles ? 50 : 4} />
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/CollapsibleText/CollapsibleText.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

&.collapsed {
mask-image: linear-gradient(-180deg, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 0) 100%);
-webkit-mask-image: linear-gradient(-180deg, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 0) 100%); /* stylelint-disable-line */
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/CollapsibleText/CollapsibleText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ const CollapsibleText: React.FC<Props> = ({ text, className, maxHeight = 'none'

const ariaLabel = expanded ? 'Collapse' : 'Expand';

const clippablePixels = 4;

useEffect(() => {
divRef.current &&
setDoesFlowOver(
divRef.current.scrollHeight > divRef.current.offsetHeight || (maxHeight < divRef.current.offsetHeight && maxHeight !== 'none'),
divRef.current.scrollHeight > divRef.current.offsetHeight + clippablePixels ||
(maxHeight < divRef.current.offsetHeight && maxHeight !== 'none'),
);
}, [maxHeight, text, breakpoint]);

Expand Down
7 changes: 4 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactFragment } from 'react';
import React, { ReactFragment, useState } from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -38,6 +38,7 @@ const Header: React.FC<Props> = ({
onCloseSearchButtonClick,
}) => {
const { t } = useTranslation('menu');
const [logoLoaded, setLogoLoaded] = useState(false);
const breakpoint = useBreakpoint();
const headerClassName = classNames(styles.header, styles[headerType], {
[styles.mobileSearchActive]: searchActive && breakpoint <= Breakpoint.sm,
Expand Down Expand Up @@ -87,11 +88,11 @@ const Header: React.FC<Props> = ({
</div>
{logoSrc && (
<div className={styles.brand}>
<Logo src={logoSrc} />
<Logo src={logoSrc} onLoad={() => setLogoLoaded(true)} />
</div>
)}
<nav className={styles.nav} aria-label="menu">
{children}
{logoLoaded ? children : null}
</nav>
<div className={styles.search}>{searchEnabled ? search : null}</div>
</div>
Expand Down
12 changes: 1 addition & 11 deletions src/components/Header/__snapshots__/Header.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,7 @@ exports[`<Header /> renders header 1`] = `
<nav
aria-label="menu"
class="nav"
>
<a
aria-current="page"
class="button default outlined active"
href="/"
>
<span>
Home
</span>
</a>
</nav>
/>
<div
class="search"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.layout {
display: flex;
flex-direction: column;
min-height: 100vh;
min-height: calc(100vh - calc(100vh - 100%));
}
.main {
flex: 1;
Expand Down
12 changes: 1 addition & 11 deletions src/components/Layout/__snapshots__/Layout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,7 @@ exports[`<Layout /> renders layout 1`] = `
<nav
aria-label="menu"
class="nav"
>
<a
aria-current="page"
class="button default text active"
href="/"
>
<span>
home
</span>
</a>
</nav>
/>
<div
class="search"
/>
Expand Down
Loading

0 comments on commit 5216923

Please sign in to comment.