Skip to content

Commit

Permalink
Merge pull request #25 from dgmstuart/video-url-to-config
Browse files Browse the repository at this point in the history
Move video list url to config
  • Loading branch information
dgmstuart authored Apr 23, 2024
2 parents bfe433d + ec1e7a3 commit 03b92fa
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 18 deletions.
14 changes: 11 additions & 3 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import type { ButtonClickHandler } from "../clickHandler";

const Card: React.FC<{
id: string;
name: string;
name?: string;
url: string;
wordList: string[];
}> = ({ id, name, url, wordList }) => {
videoListUrl?: string;
}> = ({ id, name, url, wordList, videoListUrl }) => {
const [cellDataList, toggleStamped, setNewWords, clearAllCells] = useCard(
id,
wordList,
Expand Down Expand Up @@ -42,7 +43,14 @@ const Card: React.FC<{
);
const body = <Grid cellPropsList={cellPropsList} />;

return <MainLayout name={name} headerContent={headerContent} body={body} />;
return (
<MainLayout
name={name}
headerContent={headerContent}
body={body}
videoListUrl={videoListUrl}
/>
);
};

export default Card;
13 changes: 11 additions & 2 deletions src/components/DynamicCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ import flattenWordList from "../lib/flattenWordList";
import type { KeyedConfig } from "../loaders/configLoaders";

const DynamicCard: React.FC = () => {
const { id, name = "", url, wordList } = useLoaderData() as KeyedConfig;
const { id, name, url, wordList, videoListUrl } =
useLoaderData() as KeyedConfig;

if (wordList.length > 0) {
// Card saves the word list to the session, so don't render a card if the
// word list hasn't loaded yet
const words = flattenWordList(wordList);
return <Card wordList={words} name={name} url={url} id={id} />;
return (
<Card
wordList={words}
name={name}
url={url}
id={id}
videoListUrl={videoListUrl}
/>
);
}
};

Expand Down
20 changes: 11 additions & 9 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import "./Footer.css";
import { Link } from "react-router-dom";
import classNames from "classnames";

const Footer: React.FC<{ className?: string }> = ({ className }) => {
const Footer: React.FC<{ className?: string; videoListUrl?: string }> = ({
className,
videoListUrl,
}) => {
const { t } = useTranslation();

return (
Expand All @@ -14,14 +17,13 @@ const Footer: React.FC<{ className?: string }> = ({ className }) => {
<li>
<Link to="word_list">{t("footer.wordList")}</Link>
</li>
<li>
<a
href="https://www.youtube.com/playlist?list=PLgsIo5h4KQoYzMCvcuBFTy7-qW8VgsFpT"
className="external"
>
{t("footer.videoList")}
</a>
</li>
{videoListUrl && (
<li>
<a href={videoListUrl} className="external">
{t("footer.videoList")}
</a>
</li>
)}
<li>
<a
href="https://dgmstuart.github.io/blog/2022/02/18/building-a-bingo-app-in-react/"
Expand Down
1 change: 1 addition & 0 deletions src/data/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type Config = {
name?: string;
url: string;
videoListUrl?: string;
wordList: WordListData;
};
export type WordListData = WordListGroupData[];
Expand Down
1 change: 1 addition & 0 deletions src/data/teamLindy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Team Lindy",
"url": "https://bit.ly/lindybingocard",
"videoListUrl": "https://www.youtube.com/playlist?list=PLgsIo5h4KQoYzMCvcuBFTy7-qW8VgsFpT",
"wordList": [
{
"title": "Formations",
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/ContentLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Config } from "../data/config";

const ContentLayout: React.FC = () => {
const { t } = useTranslation();
const { name = "" } = useLoaderData() as Config;
const { name, videoListUrl } = useLoaderData() as Config;

const headerContent = (
<>
Expand All @@ -26,6 +26,7 @@ const ContentLayout: React.FC = () => {
headerContent={headerContent}
body={body}
footerClass="Content-footer"
videoListUrl={videoListUrl}
/>
);
};
Expand Down
7 changes: 4 additions & 3 deletions src/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import Footer from "../components/Footer";
import LanguagePicker from "../components/LanguagePicker";

const MainLayout: React.FC<{
name: string;
name?: string;
headerContent: ReactNode;
body: ReactNode;
footerClass?: string;
}> = ({ name, headerContent, body, footerClass }) => {
videoListUrl?: string;
}> = ({ name, headerContent, body, footerClass, videoListUrl }) => {
return (
<div>
<section className="Card">
Expand All @@ -30,7 +31,7 @@ const MainLayout: React.FC<{

{body}
</section>
<Footer className={footerClass} />
<Footer className={footerClass} videoListUrl={videoListUrl} />
<LanguagePicker />
</div>
);
Expand Down

0 comments on commit 03b92fa

Please sign in to comment.