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
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"dist"
],
"rules": {
"sort-imports": [
"error",
{
"allowSeparatedGroups": true
}
],
"@typescript-eslint/consistent-type-imports": [
2,
{
Expand Down Expand Up @@ -65,4 +71,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CssBaseline, ThemeProvider } from "@mui/material"
import type { FC } from "react"

import theme from "./app/theme"
import Router from "./router"
import theme from "./app/theme"

const App: FC = () => {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/api/authFactor.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
type AuthFactor,
getReadAuthFactorEndpoints,
urls,
type AuthFactor,
} from "codeforlife/api"
import {
buildUrl,
tagData,
type CreateArg,
type CreateResult,
type DestroyArg,
type DestroyResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"

import api from "."
Expand Down
6 changes: 3 additions & 3 deletions src/api/klass.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getReadClassEndpoints, urls, type Class } from "codeforlife/api"
import { type Class, getReadClassEndpoints, urls } from "codeforlife/api"
import {
buildUrl,
tagData,
type CreateArg,
type CreateResult,
type DestroyArg,
type DestroyResult,
type UpdateArg,
type UpdateResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"

import api from "."
Expand Down
6 changes: 3 additions & 3 deletions src/api/school.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getReadSchoolEndpoints, urls, type School } from "codeforlife/api"
import {
buildUrl,
tagData,
type CreateArg,
type CreateResult,
type UpdateArg,
type UpdateResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type School, getReadSchoolEndpoints, urls } from "codeforlife/api"

import api from "."

Expand Down
6 changes: 3 additions & 3 deletions src/api/schoolTeacherInvitation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { type User } from "codeforlife/api"
import {
buildUrl,
tagData,
type Arg,
type CreateArg,
type CreateResult,
Expand All @@ -14,7 +11,10 @@ import {
type RetrieveResult,
type UpdateArg,
type UpdateResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type User } from "codeforlife/api"

import api from "."

Expand Down
2 changes: 1 addition & 1 deletion src/api/sso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
type Student,
type User,
} from "codeforlife/api"
import { type SessionMetadata } from "codeforlife/hooks"
import { type Arg } from "codeforlife/utils/api"
import { type SessionMetadata } from "codeforlife/hooks"

import api from "."

Expand Down
4 changes: 2 additions & 2 deletions src/api/student.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { urls, type Student, type User } from "codeforlife/api"
import {
tagData,
type Arg,
type BulkCreateArg,
type BulkCreateResult,
type BulkDestroyArg,
type BulkDestroyResult,
type BulkUpdateArg,
type BulkUpdateResult,
tagData,
} from "codeforlife/utils/api"
import { type Student, type User, urls } from "codeforlife/api"

import api from "."

Expand Down
6 changes: 3 additions & 3 deletions src/api/teacher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { urls, type Teacher, type User } from "codeforlife/api"
import {
buildUrl,
tagData,
type Arg,
type CreateResult,
type DestroyArg,
type DestroyResult,
type UpdateArg,
type UpdateResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type Teacher, type User, urls } from "codeforlife/api"

import api from "."

Expand Down
6 changes: 3 additions & 3 deletions src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getReadUserEndpoints, urls, type User } from "codeforlife/api"
import {
buildUrl,
tagData,
type Arg,
type CreateArg,
type CreateResult,
type DestroyArg,
type DestroyResult,
type UpdateArg,
type UpdateResult,
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type User, getReadUserEndpoints, urls } from "codeforlife/api"

import api from "."

Expand Down
1 change: 1 addition & 0 deletions src/app/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// for importing and re-exporting the typed versions of hooks.
/* eslint-disable @typescript-eslint/no-restricted-imports */
import { useDispatch, useSelector } from "react-redux"

import type { AppDispatch, RootState } from "./store"

// Use throughout your app instead of plain `useDispatch` and `useSelector`
Expand Down
2 changes: 1 addition & 1 deletion src/app/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Schema, type StringSchema, string as YupString } from "yup"
import CryptoJS from "crypto-js"
import { string as YupString, type Schema, type StringSchema } from "yup"

type Options<S extends Schema, Extras = {}> = Partial<{ schema: S } & Extras>

Expand Down
1 change: 0 additions & 1 deletion src/app/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Action, ThunkAction } from "@reduxjs/toolkit"
import { combineSlices } from "@reduxjs/toolkit"

import { makeStore } from "codeforlife/utils/store"

import api from "../api"
Expand Down
3 changes: 1 addition & 2 deletions src/app/theme.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
type ThemeOptions,
createTheme,
responsiveFontSizes,
type ThemeOptions,
} from "@mui/material"

import { themeOptions as cflThemeOptions } from "codeforlife/theme"

// Unpack the base options to extend the theme
Expand Down
39 changes: 39 additions & 0 deletions src/components/Introduction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { FC, ReactNode } from "react"
import {
Unstable_Grid2 as Grid,
type GridDirection,
Stack,
Typography,
} from "@mui/material"
import { Image } from "codeforlife/components"
import type { ResponsiveStyleValue } from "@mui/system"

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 (
<>
<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
5 changes: 2 additions & 3 deletions src/components/OpenInEmailButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { MailOutline as MailOutlineIcon } from "@mui/icons-material"
import { Stack } from "@mui/material"
import { type FC } from "react"

import { LinkButton } from "codeforlife/components/router"
import { MailOutline as MailOutlineIcon } from "@mui/icons-material"
import { Stack } from "@mui/material"

export interface OpenInEmailButtonsProps {
gmailFilters: string
Expand Down
3 changes: 1 addition & 2 deletions src/components/form/LastNameField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { TextField, type TextFieldProps } from "codeforlife/components/form"
import { type FC } from "react"
import { string as YupString } from "yup"

import { TextField, type TextFieldProps } from "codeforlife/components/form"

export type LastNameFieldProps = Omit<
TextFieldProps,
"type" | "name" | "schema"
Expand Down
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.
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from "react-redux"
import React from "react"
import { createRoot } from "react-dom/client"
import { Provider } from "react-redux"

import App from "./App"
import store from "./app/store"
Expand Down
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 { Stack, Typography } from "@mui/material"
import { type FC } from "react"

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 (
<>
<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
99 changes: 99 additions & 0 deletions src/pages/codingClubs/CodingClubs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as page from "codeforlife/components/page"
import { Link, LinkButton } from "codeforlife/components/router"
import { Typography, useTheme } from "@mui/material"
import { Download as DownloadIcon } from "@mui/icons-material"
import { type FC } from "react"

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

export interface CodingClubProps {}

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

return (
<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
Loading
Loading