Skip to content

Commit

Permalink
fix(Inline SVG Fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer6497 committed Dec 24, 2024
1 parent 9b4fa62 commit 464e901
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/components/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ function Image({ url, width, height, alternativeText, ...props }: ImageProps) {
return isSvg ? (
<SVG
{...props}
id="svg-image"
src={url}
width={width}
title={alternativeText}
role="img"
height={"auto"}
height="100%"
/>
) : (
<img
Expand Down
28 changes: 28 additions & 0 deletions app/components/__test__/Image.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { render } from "@testing-library/react";
import Image from "../Image";

describe("Image", () => {
const altText = "Alt Text";
it("should not render if the url is not provided", () => {
const { queryByAltText } = render(<Image alternativeText={altText} />);
expect(queryByAltText(altText)).not.toBeInTheDocument();
});

it("should render an image as an <img> tag", () => {
const { getByAltText } = render(
<Image url="photo.jpg" alternativeText={altText} />,
);
const image = getByAltText(altText);
expect(image).toBeInTheDocument();
expect(image).toBeInstanceOf(HTMLImageElement);
});

it("should render an svg image inline instead of as an <img> tag", () => {
const { queryByAltText } = render(
<Image url="image.svg" alternativeText={altText} ext=".svg" />,
);
// since react-inlinesvg parses an actual svg to create the DOM,
// we basically just need to ensure that an <img> isn't present
expect(queryByAltText(altText)).not.toBeInTheDocument();
});
});
25 changes: 25 additions & 0 deletions data/opensource-licenses.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@
"licenseFile": "a2j-rechtsantragstelle/node_modules/mustache/LICENSE",
"direct": true
},
"node-forge": {
"licenses": "(BSD-3-Clause OR GPL-2.0)",
"repository": "https://github.com/digitalbazaar/forge",
"publisher": "Digital Bazaar, Inc.",
"email": "support@digitalbazaar.com",
"path": "a2j-rechtsantragstelle/node_modules/node-forge",
"licenseFile": "a2j-rechtsantragstelle/node_modules/node-forge/LICENSE"
},
"pako": {
"licenses": "(MIT AND Zlib)",
"repository": "https://github.com/nodeca/pako",
Expand Down Expand Up @@ -309,6 +317,15 @@
"licenseFile": "a2j-rechtsantragstelle/node_modules/react-imask/LICENSE",
"direct": true
},
"react-inlinesvg": {
"licenses": "MIT",
"repository": "https://github.com/gilbarbara/react-inlinesvg",
"publisher": "Gil Barbara",
"email": "gilbarbara@gmail.com",
"path": "a2j-rechtsantragstelle/node_modules/react-inlinesvg",
"licenseFile": "a2j-rechtsantragstelle/node_modules/react-inlinesvg/LICENSE",
"direct": true
},
"react-select": {
"licenses": "MIT",
"repository": "https://github.com/JedWatson/react-select.git#master",
Expand All @@ -333,6 +350,14 @@
"licenseFile": "a2j-rechtsantragstelle/node_modules/remix-validated-form/README.md",
"direct": true
},
"samlify": {
"licenses": "MIT",
"repository": "https://github.com/tngan/samlify",
"publisher": "tngan",
"path": "a2j-rechtsantragstelle/node_modules/samlify",
"licenseFile": "a2j-rechtsantragstelle/node_modules/samlify/LICENSE",
"direct": true
},
"tiny-invariant": {
"licenses": "MIT",
"repository": "https://github.com/alexreardon/tiny-invariant",
Expand Down

0 comments on commit 464e901

Please sign in to comment.