Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor coding clubs page #17

Merged
merged 13 commits into from
Jul 22, 2024
40 changes: 40 additions & 0 deletions src/components/Introduction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { FC, ReactNode } from "react"
import {
type GridDirection,
Stack,
Typography,
Unstable_Grid2 as Grid,
} from "@mui/material"
import type { ResponsiveStyleValue } from "@mui/system"

import { Image } from "codeforlife/components"

const Introduction: FC<{
header: string
img: { alt: string; src: string }
children: ReactNode
direction?: ResponsiveStyleValue<GridDirection>
}> = ({ header, img, children, direction = "row" }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other comment about export props

return (

Check warning on line 18 in src/components/Introduction.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Introduction.tsx#L18

Added line #L18 was not covered by tests
<>
<Grid
container
spacing={{ xs: 2, lg: 3 }}
display="flex"
direction={direction}
>
<Grid xs={12} md={6}>
<Stack sx={{ height: "100%" }}>
<Typography variant="h5">{header}</Typography>
{children}
</Stack>
</Grid>
<Grid xs={12} md={6} className="flex-center">
<Image alt={img.alt} src={img.src} />
</Grid>
</Grid>
</>
)
}

export default Introduction
Binary file added src/images/about_us.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/coding_club_hero_hexagon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/coding_club_python_pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/pages/codingClubs/ClubAim.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { type FC } from "react"
import { Stack, Typography } from "@mui/material"

const ClubAim: FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other comment about exporting props

return (

Check warning on line 5 in src/pages/codingClubs/ClubAim.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/codingClubs/ClubAim.tsx#L4-L5

Added lines #L4 - L5 were not covered by tests
<>
<Stack>
<Typography variant="h4" textAlign="center">
Who are the club packs aimed at?
</Typography>
<Typography>
The FREE resource packs are aimed at two different groups, the first
is aimed at students ages between 7-11yrs with an interest in learning
Python. The second pack is aimed at students 12yrs and up, including
adults. This moves at a much faster pace and also introduces students
to setting up an environment on their own computer.
</Typography>
<Typography mb={0}>
Both packs are a condensed learning pathway using our game Rapid
Router alongside suggested session plan and slides.
</Typography>
</Stack>
</>
)
}

export default ClubAim
101 changes: 101 additions & 0 deletions src/pages/codingClubs/CodingClubs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { type FC } from "react"
import { Typography, useTheme } from "@mui/material"
import { Download as DownloadIcon } from "@mui/icons-material"

import * as page from "codeforlife/components/page"

import CodeClubHeroImage from "../../images/coding_club_hero_hexagon.png"
import AboutUsImage from "../../images/about_us.jpg"
import PythonClubImage from "../../images/coding_club_python_pack.png"
import Introduction from "../../components/Introduction"

import ClubAim from "./ClubAim"
import { Link, LinkButton } from "codeforlife/components/router"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort imports. Unfortunately, prettiers import sorting works differently to isort in python (prettier's behaviour is worse IMO). Prettier sorts imports by group (not as a whole). The sort order I have been following so far is:

// {default and 3rd party imports on top}
// space here
// {codeforlife imports in the middle}
// space here
// {relative imports on the bottom}

If we want to change this order, we need to so everywhere.


export interface CodingClubProps {}

const CodingClubs: FC<CodingClubProps> = () => {
const theme = useTheme()

Check warning on line 18 in src/pages/codingClubs/CodingClubs.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/codingClubs/CodingClubs.tsx#L17-L18

Added lines #L17 - L18 were not covered by tests

return (

Check warning on line 20 in src/pages/codingClubs/CodingClubs.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/codingClubs/CodingClubs.tsx#L20

Added line #L20 was not covered by tests
<page.Page>
<page.Banner
imageProps={{ alt: "codeClubHero", src: CodeClubHeroImage }}
header="Coding clubs"
subheader="A FREE set of slides and guides to run your own coding clubs"
/>
<page.Section>
<ClubAim />
</page.Section>
<page.Section boxProps={{ bgcolor: theme.palette.info.main }}>
<Introduction
header="Primary coding club"
img={{ alt: "aboutUs", src: AboutUsImage }}
>
<Typography>
Download your FREE coding club pack for students aged 7-11. This
pack introduces students to the first principles of Python at a
faster pace than the regular lesson plans. It is aimed at students
already interested in learning coding and can be used in clubs, at
home or in school, on or offline.
</Typography>
<Typography>
View the resources{" "}
<Link
to="https://code-for-life.gitbook.io/teaching-resources/v/code-club-resources-primary"
target="_blank"
>
online here
</Link>
.
</Typography>
{/*TODO: Link to GTM for analytics*/}
<LinkButton
sx={{ marginTop: "auto" }}
to="https://storage.googleapis.com/codeforlife-assets/club_packs/PrimaryCodingClub.zip"
target="_blank"
endIcon={<DownloadIcon />}
>
Download the Primary coding club pack
</LinkButton>
</Introduction>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a page component (like ) called . This will help readability - no single large components but components made of smaller components. Generally a good idea to make page sections a component. See home page as an example.

</page.Section>
<page.Section>
<Introduction
header="Python coding club"
img={{ alt: "pythonCodingClub", src: PythonClubImage }}
direction="row-reverse"
>
<Typography>
Download your FREE coding club pack for students aged 12 and above.
This pack is a fast paced introduction to Python. It is aimed at
students already interested in learning coding, individuals looking
to learn and run their own club, or adults wanting to try coding
out. It is designed to be used in face-to-face or online clubs.
</Typography>
<Typography>
View the resources{" "}
<Link
to="https://code-for-life.gitbook.io/teaching-resources/v/rapid-introduction-to-python-code-club"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an env variable starting with "VITE_LINK_". External links should be env vars so we don't need to redeploy if a link is updated. Then:

import.meta.env.VITE_LINK_EXAMPLE

target="_blank"
>
online here
</Link>
.
</Typography>
{/*TODO: Link to GTM for analytics*/}
<LinkButton
sx={{ marginTop: "auto" }}
to="https://storage.googleapis.com/codeforlife-assets/club_packs/PythonCodingClub.zip"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above comment about making this an env var

target="_blank"
endIcon={<DownloadIcon />}
>
Download the Python coding club pack
</LinkButton>
</Introduction>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a page component (like ) called . This will help readability - no single large components but components made of smaller components. Generally a good idea to make page sections a component. See home page as an example.

</page.Section>
</page.Page>
)
}

export default CodingClubs
4 changes: 2 additions & 2 deletions src/router/routes/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Route } from "react-router-dom"

import Home from "../../pages/home/Home"
// import AboutUs from '../../pages/aboutUs/AboutUs';
// import CodingClubs from '../../pages/codingClubs/CodingClubs';
import CodingClubs from "../../pages/codingClubs/CodingClubs"
// import GetInvolved from '../../pages/getInvolved/GetInvolved';
// import Contribute from '../../pages/contribute/Contribute';
// import HomeLearning from '../../pages/homeLearning/HomeLearning';
Expand All @@ -18,7 +18,7 @@ const general = (
{/* <Route path={paths.termsOfUse.tab._} element={<TermsOfUse />} /> */}
{/* <Route path={paths.homeLearning._} element={<HomeLearning />} /> */}
{/* <Route path={paths.getInvolved._} element={<GetInvolved />} /> */}
{/* <Route path={paths.codingClubs._} element={<CodingClubs />} /> */}
<Route path={paths.codingClubs._} element={<CodingClubs />} />
{/* <Route path={paths.contribute._} element={<Contribute />} /> */}
</>
)
Expand Down