@primer/react
Version:
An implementation of GitHub's Primer Design System using React
54 lines (53 loc) • 1.41 kB
JavaScript
import VisuallyHidden_module_css_default from "./VisuallyHidden.module.css.js";
import { c } from "react-compiler-runtime";
import { clsx } from "clsx";
import { jsx } from "react/jsx-runtime";
//#region src/VisuallyHidden/VisuallyHidden.tsx
/**
* Provides a component that implements the "visually hidden" technique. This is
* analogous to the common `sr-only` class. Children that are rendered inside
* this component will not be visible but will be available to screen readers.
*
* Note: if this component, or a descendant, has focus then this component will
* no longer be visually hidden.
*
* @see https://www.scottohara.me/blog/2023/03/21/visually-hidden-hack.html
*/
const VisuallyHidden = (t0) => {
const $ = c(10);
let children;
let className;
let rest;
if ($[0] !== t0) {
({className, children, ...rest} = t0);
$[0] = t0;
$[1] = children;
$[2] = className;
$[3] = rest;
} else {
children = $[1];
className = $[2];
rest = $[3];
}
let t1;
if ($[4] !== className) {
t1 = clsx(className, VisuallyHidden_module_css_default.VisuallyHidden);
$[4] = className;
$[5] = t1;
} else t1 = $[5];
let t2;
if ($[6] !== children || $[7] !== rest || $[8] !== t1) {
t2 = /*#__PURE__*/ jsx("span", {
className: t1,
...rest,
children
});
$[6] = children;
$[7] = rest;
$[8] = t1;
$[9] = t2;
} else t2 = $[9];
return t2;
};
//#endregion
export { VisuallyHidden };