Skip to content

Commit

Permalink
fix(home): initially disable left arrow slider
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed May 10, 2021
1 parent 33afa32 commit 9f9bcea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/components/Shelf/Shelf.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,19 @@

.arrow {
cursor: pointer;
transition: transform 0.2s ease-out, -webkit-transform 0.2s ease-out;
&:hover {
transform: scale(1.2);
}
> svg {
width: 30px;
height: 30px;
}
}
.arrowDisabled {
opacity: 0.3;
> svg {
width: 30px;
height: 30px;
}
}
21 changes: 18 additions & 3 deletions src/components/Shelf/Shelf.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import type { Playlist, PlaylistItem } from 'types/playlist';

import Card from '../Card/Card';
Expand Down Expand Up @@ -43,6 +43,7 @@ const Shelf: React.FC<ShelfProps> = ({
loading = false,
}: ShelfProps) => {
const breakpoint: Breakpoint = useBreakpoint();
const [isInitState, setIsInitState] = useState(true);
const tilesToShow: number = featured ? featuredTileBreakpoints[breakpoint] : tileBreakpoints[breakpoint];

if (!playlist) return null;
Expand All @@ -57,12 +58,26 @@ const Shelf: React.FC<ShelfProps> = ({
transitionTime={loading ? '0s' : '0.3s'}
spacing={12}
renderLeftControl={(handleClick) => (
<div className={styles.arrow} onClick={handleClick}>
<div
className={isInitState ? styles.arrowDisabled : styles.arrow}
onClick={() => {
if (!isInitState) {
setIsInitState(false);
handleClick();
}
}}
>
<ArrowLeft />
</div>
)}
renderRightControl={(handleClick) => (
<div className={styles.arrow} onClick={handleClick}>
<div
className={styles.arrow}
onClick={() => {
setIsInitState(false);
handleClick();
}}
>
<ArrowRight />
</div>
)}
Expand Down

0 comments on commit 9f9bcea

Please sign in to comment.