codeforlife 2.6.15 → 2.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "dist",
19
19
  "src/scripts",
20
20
  "**/*.d.ts",
21
- "vite.config.js"
21
+ "vite.config.*"
22
22
  ],
23
23
  "rules": {
24
24
  "@typescript-eslint/consistent-type-imports": [
@@ -14,7 +14,7 @@ jobs:
14
14
  uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-javascript-code.yaml@main
15
15
  secrets: inherit
16
16
  with:
17
- node-version: 18
17
+ node-version: 22
18
18
 
19
19
  release:
20
20
  needs: [test]
@@ -40,4 +40,4 @@ jobs:
40
40
  secrets: inherit
41
41
  needs: [release]
42
42
  with:
43
- node-version: 18
43
+ node-version: 22
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [2.6.16](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v2.6.15...v2.6.16) (2025-05-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Allow for 2 buttons in Banner ([#83](https://github.com/ocadotechnology/codeforlife-package-javascript/issues/83)) ([d203986](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/d2039869c1359906090b9973f2094753991a79ba))
7
+ * Node 22 ([#86](https://github.com/ocadotechnology/codeforlife-package-javascript/issues/86)) ([e66e1ca](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/e66e1caa61fcaaf28afc5d2df8b05a6908590fe2))
8
+
1
9
  ## [2.6.15](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v2.6.14...v2.6.15) (2025-04-24)
2
10
 
3
11
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "codeforlife",
3
3
  "description": "Common frontend code",
4
4
  "private": false,
5
- "version": "2.6.15",
5
+ "version": "2.6.16",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "cli": "VITE_CONFIG=./vite.config.ts ../scripts/frontend/cli $@"
@@ -1,28 +1,36 @@
1
- import { Button, Stack, Typography, type ButtonProps } from "@mui/material"
2
- import { type FC } from "react"
1
+ import { Stack, Typography } from "@mui/material"
3
2
 
3
+ import { LinkButton, type LinkButtonProps } from "../router"
4
4
  import { primary, secondary, tertiary } from "../../theme/colors"
5
5
  import palette from "../../theme/palette"
6
6
  import Image, { type ImageProps } from "../Image"
7
7
  import Section from "./Section"
8
8
 
9
- export interface BannerProps {
9
+ export interface BannerProps<
10
+ Button1State extends Record<string, any> = Record<string, any>,
11
+ Button2State extends Record<string, any> = Record<string, any>,
12
+ > {
10
13
  header: string
11
14
  subheader?: string
12
15
  textAlign?: "start" | "center"
13
16
  imageProps?: ImageProps
14
- buttonProps?: ButtonProps
17
+ button1Props?: LinkButtonProps<"to", Button1State>
18
+ button2Props?: LinkButtonProps<"to", Button2State>
15
19
  bgcolor?: "primary" | "secondary" | "tertiary"
16
20
  }
17
21
 
18
- const Banner: FC<BannerProps> = ({
22
+ const Banner = <
23
+ Button1State extends Record<string, any> = Record<string, any>,
24
+ Button2State extends Record<string, any> = Record<string, any>,
25
+ >({
19
26
  header,
20
27
  subheader,
21
28
  textAlign = "start",
22
29
  imageProps,
23
- buttonProps,
30
+ button1Props,
31
+ button2Props,
24
32
  bgcolor = "primary",
25
- }) => {
33
+ }: BannerProps<Button1State, Button2State>) => {
26
34
  // @ts-expect-error guaranteed to be in palette
27
35
  const contrastText = palette[bgcolor].contrastText
28
36
 
@@ -61,12 +69,15 @@ const Banner: FC<BannerProps> = ({
61
69
  <Typography
62
70
  color={contrastText}
63
71
  variant="h4"
64
- mb={buttonProps !== undefined ? undefined : 0}
72
+ mb={button1Props !== undefined ? undefined : 0}
65
73
  >
66
74
  {subheader}
67
75
  </Typography>
68
76
  )}
69
- {buttonProps !== undefined && <Button {...buttonProps} />}
77
+ <Stack direction="row" gap={2}>
78
+ {button1Props !== undefined && <LinkButton {...button1Props} />}
79
+ {button2Props !== undefined && <LinkButton {...button2Props} />}
80
+ </Stack>
70
81
  </Stack>
71
82
  {imageProps !== undefined && (
72
83
  <Image