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

fix(BMJ Logo Accessibility) #1561

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions app/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export default function Footer({
<div className="flex flex-col flex-col-reverse sm:flex-row gap-y-8 gap-x-16">
{image?.url && (
<div>
<Image
url={image.url}
width={120}
alternativeText={image.alternativeText}
/>
<Image {...image} width={120} />
</div>
)}
<div className="ds-stack-8">
Expand Down
16 changes: 15 additions & 1 deletion app/components/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import SVG from "react-inlinesvg";

export type ImageProps = Readonly<{
url?: string;
ext?: string;
width?: number;
height?: number;
alternativeText?: string;
Expand All @@ -8,7 +11,18 @@ export type ImageProps = Readonly<{

function Image({ url, width, height, alternativeText, ...props }: ImageProps) {
if (!url) return null;
return (
// Need to inline SVG components for accessibility
const isSvg = props.ext === ".svg";
return isSvg ? (
<SVG
{...props}
src={url}
width={width}
title={alternativeText}
role="img"
height={"auto"}
/>
) : (
<img
{...props}
src={url}
Expand Down
10 changes: 8 additions & 2 deletions app/services/cms/models/StrapiImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const getImageProps = (
cmsData: StrapiImage | null,
): ImageProps | undefined => {
if (!cmsData) return undefined;
const { url, width, height, alternativeText } = cmsData;
return { url, width, height, alternativeText: alternativeText ?? undefined };
const { url, width, height, alternativeText, ext } = cmsData;
return {
url,
width,
ext,
height,
alternativeText: alternativeText ?? undefined,
};
};
1 change: 1 addition & 0 deletions app/services/cms/models/__test__/StrapiImage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("getImageProps", () => {

expect(result).toEqual({
url: "url",
ext: ".ext",
width: 1,
height: 2,
alternativeText: "alternativeText",
Expand Down
1 change: 1 addition & 0 deletions app/services/security/cspHeader.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const cspHeader = (args: {
"connect-src": [
"'self'",
"eu.i.posthog.com",
"https://a2j-rechtsantragstelle-infra-public-assets-bucket.obs.eu-de.otc.t-systems.com",
...(args.additionalConnectSrc ?? []),
],
"img-src": [
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"react-collapsed": "^4.1.2",
"react-dom": "^18.3.1",
"react-imask": "^7.6.1",
"react-inlinesvg": "^4.1.5",
"react-select": "^5.9.0",
"remix-validated-form": "^5.1.5",
"samlify": "^2.8.11",
Expand Down
Loading