Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat: attempting transparent image background for episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2000 committed May 11, 2020
1 parent b5e6e9d commit 0b9dc0e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 21 deletions.
28 changes: 11 additions & 17 deletions packages/client/src/components/episodes/EpisodeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@ export function EpisodeItem(props: EpisodeItemProps) {
const { episode } = props;

return (
<Grid container>
<Grid item>
<img src={episode.image} height="200" width="200" />
</Grid>

<Grid item>
<Grid container>
<Grid item>
<Typography variant="h5">{episode.title}</Typography>
</Grid>
<>
<Grid container>
<Grid item xs>
<Typography variant="h5">{episode.title}</Typography>
</Grid>
<Grid container>
<Grid item>
<Typography variant="body2">
{ReactHtmlParser(episode.description)}
</Typography>
</Grid>
</Grid>
<Grid container>
<Grid item xs>
<Typography variant="body2">
{ReactHtmlParser(episode.description)}
</Typography>
</Grid>
</Grid>
</Grid>
</>
);
}
49 changes: 45 additions & 4 deletions packages/client/src/components/episodes/EpisodeList.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,65 @@
import React from 'react';
import { EpisodeConnection } from '../../interfaces';
import { Grid } from '@material-ui/core';
import { Grid, GridProps } from '@material-ui/core';
import { EpisodeItem } from './EpisodeItem';
import { makeStyles, Theme } from '@material-ui/core/styles';

interface EpisodeListProps {
episodes: EpisodeConnection;
}

interface StyleProps {
backgroundImage: string;
}

const useStyles = makeStyles((theme: Theme) => ({
episode: {
flexGrow: 1,
'&:before': {
content: ' ',
display: 'block',
position: 'absolute',
top: 0,
left: 0,
height: '100%',
width: '100%',
backgroundImage: (props: StyleProps) => `url(${props.backgroundImage})`,
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: '50% 0',
opacity: 0.6,
zIndex: 1,
},
},
}));

function GridBackground(props: StyleProps & Omit<GridProps, keyof StyleProps>) {
const { backgroundImage, children, ...other } = props;
const classes = useStyles({ backgroundImage: backgroundImage });

return (
<Grid className={classes.episode} {...other}>
{children}
</Grid>
);
}

export function EpisodeList(props: EpisodeListProps) {
const { episodes } = props;

return (
<>
{episodes ? (
episodes.edges.map((episode) => (
<Grid container key={`episode-row-${episode.node.id}`}>
<Grid item key={`episode-col-${episode.node.id}`}>
<GridBackground
backgroundImage={episode.node.image}
container
key={`episode-row-${episode.node.id}`}
>
<Grid item key={`episode-col-${episode.node.id}`} xs>
<EpisodeItem episode={episode.node} />
</Grid>
</Grid>
</GridBackground>
))
) : (
<h2>No Episodes</h2>
Expand Down

0 comments on commit 0b9dc0e

Please sign in to comment.