Skip to content

Commit

Permalink
feat(videodetail): set share button conditional to config
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Jun 14, 2021
1 parent 7d96945 commit 322b1fe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/components/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@
height: 20px;
width: 20px;
fill: currentColor;
@include responsive.tablet-only() {
width: 18px;
height: 18px;
}
}
}
4 changes: 2 additions & 2 deletions src/components/Video/Video.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
.otherButtons {
display: flex;
justify-content: center;
width: 100%;
> button {
margin-right: 8px;
width: 33%;
width: 100%;
}
> button:last-child {
margin-right: 0px;
Expand All @@ -74,7 +75,6 @@
> button:first-child {
margin-bottom: 8px;
margin-right: 0px;
width: 100%;
}
> button:not(:first-child) {
flex: 1;
Expand Down
1 change: 1 addition & 0 deletions src/components/Video/Video.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('<Video>', () => {
play
hasShared={false}
onShareClick={() => null}
enableSharing
/>,
);

Expand Down
16 changes: 10 additions & 6 deletions src/components/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = {
startPlay: () => void;
goBack: () => void;
poster: Poster;
enableSharing: boolean;
hasShared: boolean;
onShareClick: () => void;
relatedShelf?: JSX.Element;
Expand All @@ -37,6 +38,7 @@ const Video: React.FC<Props> = ({
startPlay,
goBack,
poster,
enableSharing,
hasShared,
onShareClick,
relatedShelf,
Expand Down Expand Up @@ -90,12 +92,14 @@ const Video: React.FC<Props> = ({
fullWidth={breakpoint < Breakpoint.sm}
/>
<Button label={t('video:favorite')} startIcon={<Favorite />} onClick={() => null} />
<Button
label={hasShared ? t('video:copied_url') : t('video:share')}
startIcon={hasShared ? <Check /> : <Share />}
onClick={onShareClick}
active={hasShared}
/>
{enableSharing && (
<Button
label={hasShared ? t('video:copied_url') : t('video:share')}
startIcon={hasShared ? <Check /> : <Share />}
onClick={onShareClick}
active={hasShared}
/>
)}
</div>
</div>
<div
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const Video = ({ playlistId, videoType, episodeId, mediaId }: VideoProps): JSX.E
const play = new URLSearchParams(location.search).get('play') === '1';
const config: Config = useContext(ConfigContext);
const [hasShared, setHasShared] = useState<boolean>(false);
const posterFading: boolean = config ? config.options.posterFading === true : false;
const enableSharing: boolean = config.options.enableSharing === true;
const posterFading: boolean = config.options.posterFading === true;

const { isLoading, error, data: { playlist } = { playlist: [] } } = usePlaylist(playlistId);

Expand Down Expand Up @@ -69,6 +70,7 @@ const Video = ({ playlistId, videoType, episodeId, mediaId }: VideoProps): JSX.E
startPlay={startPlay}
goBack={goBack}
poster={posterFading ? 'fading' : 'normal'}
enableSharing={enableSharing}
hasShared={hasShared}
onShareClick={onShareClick}
relatedShelf={
Expand Down

0 comments on commit 322b1fe

Please sign in to comment.