The key icon: a 24 by 24 stroke glyph that takes its colour from the text around it.
registry/behivetech/icons/key · depends on @behivetech/icons.base
key.tsx
1import { createIcon } from "@behivetech/icons.base";23/** The key icon: a stroke glyph on a 24 by 24 grid that inherits the text colour. */4export const KeyIcon = /*#__PURE__*/ createIcon(5 "KeyIcon",6 <>7 <circle cx="7.5" cy="15.5" r="5.5" />8 <path d="m21 2-9.6 9.6" />9 <path d="m15.5 7.5 3 3L22 7l-3-3" />10 </>,11);1213export default KeyIcon;
index.ts
1export { KeyIcon, default } from "./key.js";
key.example.tsx
1import { KeyIcon } from "./key.js";23/** The icon at each size; it takes its colour from the surrounding text. */4export const KeyIconSizes = () => (5 <>6 <KeyIcon size="sm" />7 <KeyIcon />8 <KeyIcon size="lg" />9 <KeyIcon size="xl" />10 </>11);1213/** Named with `titleAccess`, so assistive technology announces it. */14export const NamedKeyIcon = () => <KeyIcon titleAccess="Key" />;
key.spec.tsx
1import { render } from "@testing-library/react";2import KeyIconDefault, { KeyIcon } from "./key.js";34describe("KeyIcon", () => {5 it("exports the same component by name and by default", () => {6 expect(KeyIconDefault).toBe(KeyIcon);7 expect(KeyIcon.displayName).toBe("KeyIcon");8 });910 it("draws its glyph and hides from assistive technology", () => {11 const { container } = render(<KeyIcon />);12 const svg = container.querySelector("svg");1314 expect(15 svg?.querySelector(16 "path, circle, rect, ellipse, line, polyline, polygon",17 ),18 ).not.toBeNull();19 expect(svg?.getAttribute("aria-hidden")).toBe("true");20 });2122 it("is an image named by titleAccess", () => {23 const { container } = render(<KeyIcon titleAccess="Key" />);24 const svg = container.querySelector("svg");2526 expect(svg?.getAttribute("role")).toBe("img");27 expect(svg?.querySelector("title")?.textContent).toBe("Key");28 });29});