This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
forked from HHS/simpler-grants-gov
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import SpriteSVG from "public/img/uswds-sprite.svg"; | ||
|
||
interface IconProps { | ||
name: string; | ||
className: string; | ||
height?: string; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const sprite_uri = SpriteSVG.src as string; | ||
|
||
export function USWDSIcon(props: IconProps) { | ||
return ( | ||
<svg | ||
className={props.className} | ||
aria-hidden="true" | ||
height={props.height} | ||
role="img" | ||
> | ||
<use href={`${sprite_uri}#${props.name}`}></use> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { render, screen } from "tests/react-utils"; | ||
|
||
import { USWDSIcon } from "src/components/USWDSIcon"; | ||
|
||
describe("USWDSIcon", () => { | ||
it("Renders without errors", () => { | ||
render(<USWDSIcon className="usa-icon" name="search" />); | ||
const icon = screen.getByRole("img", { hidden: true }); | ||
expect(icon).toBeInTheDocument(); | ||
expect(icon).toHaveClass("usa-icon"); | ||
}); | ||
}); |