Skip to content

Commit e14fdea

Browse files
authored
Accessibility issues resolved (#113)
* RA - changed main colour code to that of the dark hex for colour accessibiblity in dark mode * RA dark theme main colour now the same as light theme dark colour. dark theme dark colour made darker to pass accessibility with white text. old diamond theme kept. breadcrumbs and user components updated to use dark colouring * RA lighter blue changed so that breadcrumb has better contrast in light mode * RA prettier fix * RA - resolved accessibility errors * RA resolving test fails * RA resolving prettier CI errors * RA removed unused import from themeing files * RA reverting type import to resolve pipeline * RA created new DataBoxList wrapper component in order for dl tags to wrap all content inside DataBox and not each databox * RA lint fix ran * RA reverting DataBoxList changes
1 parent bd82d51 commit e14fdea

File tree

12 files changed

+141
-38
lines changed

12 files changed

+141
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@storybook/react": "^8.4.4",
6666
"@storybook/react-webpack5": "^8.4.4",
6767
"@storybook/test": "^8.4.4",
68-
"@testing-library/jest-dom": "^6.6.3",
68+
"@testing-library/jest-dom": "^6.9.1",
6969
"@testing-library/react": "^16.1.0",
7070
"@types/node": "^20.19.21",
7171
"@types/react": "^18.3.12",

pnpm-lock.yaml

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/controls/ScrollableImages.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ const ScrollableImages = ({
169169
>
170170
{renderButtons && (
171171
<Button
172+
aria-label="Previous Image"
172173
onClick={handlePrev}
173174
size="small"
174175
sx={{ minWidth: 36, width: 36, height: 36 }}
@@ -220,6 +221,7 @@ const ScrollableImages = ({
220221

221222
{renderButtons && (
222223
<Button
224+
aria-label="Next Image"
223225
onClick={handleNext}
224226
size="small"
225227
sx={{ minWidth: 36, width: 36, height: 36 }}
@@ -232,6 +234,7 @@ const ScrollableImages = ({
232234
{renderNumbers && (
233235
<Box sx={{ display: "flex" }}>
234236
<Box
237+
aria-label="Total Images Numeration"
235238
data-testid="numeration"
236239
component="input"
237240
type="number"

src/components/controls/User.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const User = ({
136136
onClick={handleLogin}
137137
startIcon={<MdLogin />}
138138
sx={{
139-
backgroundColor: theme.palette.primary.light,
139+
backgroundColor: theme.palette.primary.main,
140140
color: theme.palette.primary.contrastText,
141141
}}
142142
>

src/components/helpers/jsonforms/components/DataBox.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,28 @@ export const DataOrEmpty = ({ data }: { data?: string | null }) =>
1919
const DataBox = ({ label, data }: DataBoxProps) => (
2020
<Box className="data-box">
2121
<Stack direction="column">
22-
<Box className="data-box-label">
23-
<Typography
24-
component="dt"
25-
variant="h6"
26-
sx={{
27-
fontWeight: "bold",
28-
textTransform: "capitalize",
29-
fontSize: "smaller",
30-
}}
31-
>
32-
{label}
33-
</Typography>
34-
</Box>
22+
{/* tag needed for JSON Forms accessibility check */}
23+
<dl>
24+
<Box className="data-box-label">
25+
<Typography
26+
component="dt"
27+
variant="h6"
28+
sx={{
29+
fontWeight: "bold",
30+
textTransform: "capitalize",
31+
fontSize: "smaller",
32+
}}
33+
>
34+
{label}
35+
</Typography>
36+
</Box>
3537

36-
<Box className="data-box-data">
37-
<Typography component="dd">
38-
<DataOrEmpty data={data} />
39-
</Typography>
40-
</Box>
38+
<Box className="data-box-data">
39+
<Typography component="dd">
40+
<DataOrEmpty data={data} />
41+
</Typography>
42+
</Box>
43+
</dl>
4144
</Stack>
4245
</Box>
4346
);

src/components/helpers/jsonforms/controls/TextDateTimeControl.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
schemaMatches,
77
ControlProps,
88
} from "@jsonforms/core";
9-
109
import { DataBox } from "../components/DataBox";
1110

1211
const TextDateTimeControlTester = rankWith(

src/components/navigation/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const BarStyled = styled(Bar)<BarSlotsProps>(({ theme }) => ({
8888
position: "relative",
8989
bottom: 0,
9090
marginTop: "auto",
91-
backgroundColor: theme.vars.palette.primary.light,
91+
backgroundColor: theme.vars.palette.primary.main,
9292
}));
9393

9494
interface FooterProps extends BarSlotsProps {

src/components/navigation/Navbar.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { MemoryRouter, Link } from "react-router-dom";
99
describe("Navbar", () => {
1010
it("should render", async () => {
1111
renderWithProviders(<Navbar />);
12-
expect(await screen.findByRole("banner")).toBeInTheDocument();
12+
expect(await screen.findByTestId("navbar")).toBeInTheDocument();
1313
});
1414

1515
it("should render with styles", async () => {
1616
const borderStyle = "1px solid orange";
1717
renderWithProviders(<Navbar style={{ border: borderStyle }} />);
1818

1919
const headerComputedStyle = window.getComputedStyle(
20-
await screen.findByRole("banner"),
20+
await screen.findByTestId("navbar"),
2121
);
2222

2323
// check new style is set

src/components/navigation/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const Navbar = ({
152152
}: NavbarProps) => {
153153
return (
154154
<BarStyled
155-
role="banner"
155+
data-testid="navbar"
156156
{...props}
157157
leftSlot={
158158
<>

src/themes/DiamondTheme.old

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { createTheme, Theme } from "@mui/material/styles";
2+
3+
import { mergeThemeOptions } from "./ThemeManager";
4+
5+
import logoImageDark from "../public/diamond/logo-dark.svg";
6+
import logoImageLight from "../public/diamond/logo-light.svg";
7+
import logoShort from "../public/diamond/logo-short.svg";
8+
9+
const dlsLogoBlue = "#202740";
10+
const dlsLogoYellow = "#facf07";
11+
12+
const DiamondThemeOptions = mergeThemeOptions({
13+
logos: {
14+
normal: {
15+
src: logoImageDark, // Use the dark image for light backgrounds
16+
srcDark: logoImageLight, // Use the light image for dark backgrounds
17+
alt: "Diamond Light Source Logo",
18+
width: "100",
19+
},
20+
short: {
21+
src: logoShort,
22+
alt: "Diamond Light Source Logo",
23+
width: "35",
24+
},
25+
},
26+
colorSchemes: {
27+
// https://zenoo.github.io/mui-theme-creator/
28+
light: {
29+
palette: {
30+
primary: {
31+
main: dlsLogoBlue,
32+
light: "#4C5266", // dark grey
33+
dark: "#161B2C", // dark blue
34+
contrastText: "#ffffff", // white
35+
},
36+
secondary: {
37+
main: dlsLogoYellow,
38+
light: "#FBD838", // light yellow
39+
dark: "#AF9004", // dark yellow
40+
contrastText: "#000000", // black
41+
},
42+
text: {
43+
secondary: "#161B2C",
44+
},
45+
},
46+
},
47+
dark: {
48+
palette: {
49+
primary: {
50+
main: "#6175bd", //lightened version of {dlsLogoBlue}
51+
light: "#8090CA", // lighter blue
52+
dark: "#435184", // mid blue
53+
contrastText: "#ffffff", // white
54+
},
55+
secondary: {
56+
main: dlsLogoYellow,
57+
light: "#FBD838", // light yellow
58+
dark: "#AF9004", // dark yellow
59+
contrastText: "#000000", // black
60+
},
61+
text: {
62+
secondary: "#8090CA",
63+
},
64+
},
65+
},
66+
},
67+
components: {
68+
MuiButton: {
69+
styleOverrides: {
70+
root: ({ theme }: { theme: Theme }) => ({
71+
textTransform: "none",
72+
"&.MuiButton-contained": {},
73+
"&.default": {
74+
color: theme.palette.primary.contrastText,
75+
backgroundColor: theme.palette.primary.dark,
76+
"&:hover": {
77+
backgroundImage: "linear-gradient(rgb(0 0 0/30%) 0 0)",
78+
"&:disabled": {
79+
backgroundColor: theme.palette.primary.light,
80+
},
81+
},
82+
},
83+
"&.onBlue": {
84+
color: theme.palette.secondary.light,
85+
borderColor: theme.palette.secondary.light,
86+
border: "1px solid",
87+
fontSize: "0.875rem",
88+
"&:hover": {
89+
color: theme.palette.primary.dark,
90+
backgroundColor: theme.palette.secondary.light,
91+
},
92+
},
93+
}),
94+
},
95+
},
96+
},
97+
});
98+
99+
const DiamondTheme: Theme = createTheme(DiamondThemeOptions);
100+
101+
export { DiamondTheme, DiamondThemeOptions };

0 commit comments

Comments
 (0)