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

Commit b5e6e9d

Browse files
committed
feat: add html rendering for episode description
1 parent bd968e6 commit b5e6e9d

File tree

5 files changed

+73
-12
lines changed

5 files changed

+73
-12
lines changed

packages/client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@types/node": "^13.13.5",
2020
"@types/react": "^16.9.34",
2121
"@types/react-dom": "^16.9.7",
22+
"@types/react-html-parser": "^2.0.1",
2223
"@types/react-router": "^5.1.7",
2324
"@types/react-router-dom": "^5.1.5",
2425
"@types/webpack": "^4.41.12",
@@ -64,6 +65,7 @@
6465
"react": "^16.13.1",
6566
"react-dom": "^16.13.1",
6667
"react-hook-form": "^5.6.3",
68+
"react-html-parser": "^2.0.2",
6769
"react-router": "^5.1.2",
6870
"react-router-dom": "^5.1.2"
6971
}
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import { Episode } from '../../interfaces';
3+
import { Grid, Typography } from '@material-ui/core';
4+
import ReactHtmlParser from 'react-html-parser';
35

46
interface EpisodeItemProps {
57
episode: Episode;
@@ -8,5 +10,26 @@ interface EpisodeItemProps {
810
export function EpisodeItem(props: EpisodeItemProps) {
911
const { episode } = props;
1012

11-
return <h4>{episode.title}</h4>;
13+
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>
24+
</Grid>
25+
<Grid container>
26+
<Grid item>
27+
<Typography variant="body2">
28+
{ReactHtmlParser(episode.description)}
29+
</Typography>
30+
</Grid>
31+
</Grid>
32+
</Grid>
33+
</Grid>
34+
);
1235
}

packages/client/src/interfaces/episode.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { PageInfo } from './pageinfo';
22

33
export interface Episode {
4-
id: Number;
5-
title: String;
6-
description: String;
7-
duration: String;
8-
image: String;
4+
id: number;
5+
title: string;
6+
description: string;
7+
duration: string;
8+
image: string;
99
}
1010

1111
export interface EpisodeEdge {
1212
node: Episode;
13-
cursor: String;
13+
cursor: string;
1414
}
1515

1616
export interface EpisodeConnection {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface PageInfo {
2-
hasNextPage: Boolean;
3-
hasPreviousPage: Boolean;
4-
startCursor: String;
5-
endCursor: String;
2+
hasNextPage: boolean;
3+
hasPreviousPage: boolean;
4+
startCursor: string;
5+
endCursor: string;
66
}

yarn.lock

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,18 @@
17971797
dependencies:
17981798
"@types/express" "*"
17991799

1800+
"@types/domhandler@*":
1801+
version "2.4.1"
1802+
resolved "https://registry.yarnpkg.com/@types/domhandler/-/domhandler-2.4.1.tgz#7b3b347f7762180fbcb1ece1ce3dd0ebbb8c64cf"
1803+
integrity sha512-cfBw6q6tT5sa1gSPFSRKzF/xxYrrmeiut7E0TxNBObiLSBTuFEHibcfEe3waQPEDbqBsq+ql/TOniw65EyDFMA==
1804+
1805+
"@types/domutils@*":
1806+
version "1.7.2"
1807+
resolved "https://registry.yarnpkg.com/@types/domutils/-/domutils-1.7.2.tgz#89422e579c165994ad5c09ce90325da596cc105d"
1808+
integrity sha512-Nnwy1Ztwq42SSNSZSh9EXBJGrOZPR+PQ2sRT4VZy8hnsFXfCil7YlKO2hd2360HyrtFz2qwnKQ13ENrgXNxJbw==
1809+
dependencies:
1810+
"@types/domhandler" "*"
1811+
18001812
"@types/eslint-visitor-keys@^1.0.0":
18011813
version "1.0.0"
18021814
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
@@ -1897,6 +1909,15 @@
18971909
"@types/tapable" "*"
18981910
"@types/webpack" "*"
18991911

1912+
"@types/htmlparser2@*":
1913+
version "3.10.1"
1914+
resolved "https://registry.yarnpkg.com/@types/htmlparser2/-/htmlparser2-3.10.1.tgz#1e65ba81401d53f425c1e2ba5a3d05c90ab742c7"
1915+
integrity sha512-fCxmHS4ryCUCfV9+CJZY1UjkbR+6Al/EQdX5Jh03qBj9gdlPG5q+7uNoDgE/ZNXb3XNWSAQgqKIWnbRCbOyyWA==
1916+
dependencies:
1917+
"@types/domhandler" "*"
1918+
"@types/domutils" "*"
1919+
"@types/node" "*"
1920+
19001921
"@types/http-assert@*":
19011922
version "1.5.1"
19021923
resolved "https://registry.yarnpkg.com/@types/http-assert/-/http-assert-1.5.1.tgz#d775e93630c2469c2f980fc27e3143240335db3b"
@@ -2076,6 +2097,14 @@
20762097
dependencies:
20772098
"@types/react" "*"
20782099

2100+
"@types/react-html-parser@^2.0.1":
2101+
version "2.0.1"
2102+
resolved "https://registry.yarnpkg.com/@types/react-html-parser/-/react-html-parser-2.0.1.tgz#2d9002ac5bf1adf9aff8eae77ace5488bd78c98d"
2103+
integrity sha512-Lyw0AtG3gahw78CX2pzmzhKaoZCfJNzzuhhPsFVhzFrylMv8NaCmzYaPKglMv3RRHpwBbHuMOkVx0HiwGZKgSA==
2104+
dependencies:
2105+
"@types/htmlparser2" "*"
2106+
"@types/react" "*"
2107+
20792108
"@types/react-router-dom@^5.1.5":
20802109
version "5.1.5"
20812110
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.5.tgz#7c334a2ea785dbad2b2dcdd83d2cf3d9973da090"
@@ -6272,7 +6301,7 @@ html-webpack-plugin@^4.3.0:
62726301
tapable "^1.1.3"
62736302
util.promisify "1.0.0"
62746303

6275-
htmlparser2@^3.3.0:
6304+
htmlparser2@^3.3.0, htmlparser2@^3.9.0:
62766305
version "3.10.1"
62776306
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f"
62786307
integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==
@@ -9883,6 +9912,13 @@ react-hook-form@^5.6.3:
98839912
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-5.6.3.tgz#fb807450730daab8020d18cf7106754baa33e7d3"
98849913
integrity sha512-qqcoDM5UD69aUMQejhx90XM4gXUAlVRH3mDRa9TDZINK6FAM7EjReJKjiIZzU9mShjjKTQl3RpiHKaKzZqI7RA==
98859914

9915+
react-html-parser@^2.0.2:
9916+
version "2.0.2"
9917+
resolved "https://registry.yarnpkg.com/react-html-parser/-/react-html-parser-2.0.2.tgz#6dbe1ddd2cebc1b34ca15215158021db5fc5685e"
9918+
integrity sha512-XeerLwCVjTs3njZcgCOeDUqLgNIt/t+6Jgi5/qPsO/krUWl76kWKXMeVs2LhY2gwM6X378DkhLjur0zUQdpz0g==
9919+
dependencies:
9920+
htmlparser2 "^3.9.0"
9921+
98869922
react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4:
98879923
version "16.13.1"
98889924
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"

0 commit comments

Comments
 (0)