Skip to content

Commit 03b92fa

Browse files
authored
Merge pull request #25 from dgmstuart/video-url-to-config
Move video list url to config
2 parents bfe433d + ec1e7a3 commit 03b92fa

File tree

7 files changed

+41
-18
lines changed

7 files changed

+41
-18
lines changed

src/components/Card.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import type { ButtonClickHandler } from "../clickHandler";
1010

1111
const Card: React.FC<{
1212
id: string;
13-
name: string;
13+
name?: string;
1414
url: string;
1515
wordList: string[];
16-
}> = ({ id, name, url, wordList }) => {
16+
videoListUrl?: string;
17+
}> = ({ id, name, url, wordList, videoListUrl }) => {
1718
const [cellDataList, toggleStamped, setNewWords, clearAllCells] = useCard(
1819
id,
1920
wordList,
@@ -42,7 +43,14 @@ const Card: React.FC<{
4243
);
4344
const body = <Grid cellPropsList={cellPropsList} />;
4445

45-
return <MainLayout name={name} headerContent={headerContent} body={body} />;
46+
return (
47+
<MainLayout
48+
name={name}
49+
headerContent={headerContent}
50+
body={body}
51+
videoListUrl={videoListUrl}
52+
/>
53+
);
4654
};
4755

4856
export default Card;

src/components/DynamicCard.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ import flattenWordList from "../lib/flattenWordList";
55
import type { KeyedConfig } from "../loaders/configLoaders";
66

77
const DynamicCard: React.FC = () => {
8-
const { id, name = "", url, wordList } = useLoaderData() as KeyedConfig;
8+
const { id, name, url, wordList, videoListUrl } =
9+
useLoaderData() as KeyedConfig;
910

1011
if (wordList.length > 0) {
1112
// Card saves the word list to the session, so don't render a card if the
1213
// word list hasn't loaded yet
1314
const words = flattenWordList(wordList);
14-
return <Card wordList={words} name={name} url={url} id={id} />;
15+
return (
16+
<Card
17+
wordList={words}
18+
name={name}
19+
url={url}
20+
id={id}
21+
videoListUrl={videoListUrl}
22+
/>
23+
);
1524
}
1625
};
1726

src/components/Footer.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import "./Footer.css";
55
import { Link } from "react-router-dom";
66
import classNames from "classnames";
77

8-
const Footer: React.FC<{ className?: string }> = ({ className }) => {
8+
const Footer: React.FC<{ className?: string; videoListUrl?: string }> = ({
9+
className,
10+
videoListUrl,
11+
}) => {
912
const { t } = useTranslation();
1013

1114
return (
@@ -14,14 +17,13 @@ const Footer: React.FC<{ className?: string }> = ({ className }) => {
1417
<li>
1518
<Link to="word_list">{t("footer.wordList")}</Link>
1619
</li>
17-
<li>
18-
<a
19-
href="https://www.youtube.com/playlist?list=PLgsIo5h4KQoYzMCvcuBFTy7-qW8VgsFpT"
20-
className="external"
21-
>
22-
{t("footer.videoList")}
23-
</a>
24-
</li>
20+
{videoListUrl && (
21+
<li>
22+
<a href={videoListUrl} className="external">
23+
{t("footer.videoList")}
24+
</a>
25+
</li>
26+
)}
2527
<li>
2628
<a
2729
href="https://dgmstuart.github.io/blog/2022/02/18/building-a-bingo-app-in-react/"

src/data/config.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type Config = {
22
name?: string;
33
url: string;
4+
videoListUrl?: string;
45
wordList: WordListData;
56
};
67
export type WordListData = WordListGroupData[];

src/data/teamLindy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "Team Lindy",
33
"url": "https://bit.ly/lindybingocard",
4+
"videoListUrl": "https://www.youtube.com/playlist?list=PLgsIo5h4KQoYzMCvcuBFTy7-qW8VgsFpT",
45
"wordList": [
56
{
67
"title": "Formations",

src/layouts/ContentLayout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Config } from "../data/config";
88

99
const ContentLayout: React.FC = () => {
1010
const { t } = useTranslation();
11-
const { name = "" } = useLoaderData() as Config;
11+
const { name, videoListUrl } = useLoaderData() as Config;
1212

1313
const headerContent = (
1414
<>
@@ -26,6 +26,7 @@ const ContentLayout: React.FC = () => {
2626
headerContent={headerContent}
2727
body={body}
2828
footerClass="Content-footer"
29+
videoListUrl={videoListUrl}
2930
/>
3031
);
3132
};

src/layouts/MainLayout.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import Footer from "../components/Footer";
44
import LanguagePicker from "../components/LanguagePicker";
55

66
const MainLayout: React.FC<{
7-
name: string;
7+
name?: string;
88
headerContent: ReactNode;
99
body: ReactNode;
1010
footerClass?: string;
11-
}> = ({ name, headerContent, body, footerClass }) => {
11+
videoListUrl?: string;
12+
}> = ({ name, headerContent, body, footerClass, videoListUrl }) => {
1213
return (
1314
<div>
1415
<section className="Card">
@@ -30,7 +31,7 @@ const MainLayout: React.FC<{
3031

3132
{body}
3233
</section>
33-
<Footer className={footerClass} />
34+
<Footer className={footerClass} videoListUrl={videoListUrl} />
3435
<LanguagePicker />
3536
</div>
3637
);

0 commit comments

Comments
 (0)