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

Commit 0b9dc0e

Browse files
committed
feat: attempting transparent image background for episodes
1 parent b5e6e9d commit 0b9dc0e

File tree

2 files changed

+56
-21
lines changed

2 files changed

+56
-21
lines changed

packages/client/src/components/episodes/EpisodeItem.tsx

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@ export function EpisodeItem(props: EpisodeItemProps) {
1111
const { episode } = props;
1212

1313
return (
14-
<Grid container>
15-
<Grid item>
16-
<img src={episode.image} height="200" width="200" />
17-
</Grid>
18-
19-
<Grid item>
20-
<Grid container>
21-
<Grid item>
22-
<Typography variant="h5">{episode.title}</Typography>
23-
</Grid>
14+
<>
15+
<Grid container>
16+
<Grid item xs>
17+
<Typography variant="h5">{episode.title}</Typography>
2418
</Grid>
25-
<Grid container>
26-
<Grid item>
27-
<Typography variant="body2">
28-
{ReactHtmlParser(episode.description)}
29-
</Typography>
30-
</Grid>
19+
</Grid>
20+
<Grid container>
21+
<Grid item xs>
22+
<Typography variant="body2">
23+
{ReactHtmlParser(episode.description)}
24+
</Typography>
3125
</Grid>
3226
</Grid>
33-
</Grid>
27+
</>
3428
);
3529
}

packages/client/src/components/episodes/EpisodeList.tsx

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,65 @@
11
import React from 'react';
22
import { EpisodeConnection } from '../../interfaces';
3-
import { Grid } from '@material-ui/core';
3+
import { Grid, GridProps } from '@material-ui/core';
44
import { EpisodeItem } from './EpisodeItem';
5+
import { makeStyles, Theme } from '@material-ui/core/styles';
56

67
interface EpisodeListProps {
78
episodes: EpisodeConnection;
89
}
910

11+
interface StyleProps {
12+
backgroundImage: string;
13+
}
14+
15+
const useStyles = makeStyles((theme: Theme) => ({
16+
episode: {
17+
flexGrow: 1,
18+
'&:before': {
19+
content: ' ',
20+
display: 'block',
21+
position: 'absolute',
22+
top: 0,
23+
left: 0,
24+
height: '100%',
25+
width: '100%',
26+
backgroundImage: (props: StyleProps) => `url(${props.backgroundImage})`,
27+
backgroundRepeat: 'no-repeat',
28+
backgroundSize: 'cover',
29+
backgroundPosition: '50% 0',
30+
opacity: 0.6,
31+
zIndex: 1,
32+
},
33+
},
34+
}));
35+
36+
function GridBackground(props: StyleProps & Omit<GridProps, keyof StyleProps>) {
37+
const { backgroundImage, children, ...other } = props;
38+
const classes = useStyles({ backgroundImage: backgroundImage });
39+
40+
return (
41+
<Grid className={classes.episode} {...other}>
42+
{children}
43+
</Grid>
44+
);
45+
}
46+
1047
export function EpisodeList(props: EpisodeListProps) {
1148
const { episodes } = props;
1249

1350
return (
1451
<>
1552
{episodes ? (
1653
episodes.edges.map((episode) => (
17-
<Grid container key={`episode-row-${episode.node.id}`}>
18-
<Grid item key={`episode-col-${episode.node.id}`}>
54+
<GridBackground
55+
backgroundImage={episode.node.image}
56+
container
57+
key={`episode-row-${episode.node.id}`}
58+
>
59+
<Grid item key={`episode-col-${episode.node.id}`} xs>
1960
<EpisodeItem episode={episode.node} />
2061
</Grid>
21-
</Grid>
62+
</GridBackground>
2263
))
2364
) : (
2465
<h2>No Episodes</h2>

0 commit comments

Comments
 (0)