diff options
Diffstat (limited to 'apps/web/src/components/ui')
| -rw-r--r-- | apps/web/src/components/ui/command.tsx | 9 | ||||
| -rw-r--r-- | apps/web/src/components/ui/visually-hidden.tsx | 32 |
2 files changed, 39 insertions, 2 deletions
diff --git a/apps/web/src/components/ui/command.tsx b/apps/web/src/components/ui/command.tsx index 11b27041..b91cbd3d 100644 --- a/apps/web/src/components/ui/command.tsx +++ b/apps/web/src/components/ui/command.tsx @@ -1,12 +1,14 @@ "use client"; import * as React from "react"; -import { DialogProps } from "@radix-ui/react-dialog"; import { Command as CommandPrimitive } from "cmdk"; import { Search } from "lucide-react"; import { cn } from "../../lib/utils"; -import { Dialog, DialogContent } from "./dialog"; +import { Dialog, DialogContent, DialogTitle } from "./dialog"; +import { VisuallyHidden } from "./visually-hidden"; + +type DialogProps = React.ComponentProps<typeof Dialog>; const Command = React.forwardRef< React.ElementRef<typeof CommandPrimitive>, @@ -27,6 +29,9 @@ const CommandDialog = ({ children, ...props }: DialogProps) => { return ( <Dialog {...props}> <DialogContent className="overflow-hidden p-0"> + <DialogTitle> + <VisuallyHidden>Command Menu</VisuallyHidden> + </DialogTitle> <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"> {children} </Command> diff --git a/apps/web/src/components/ui/visually-hidden.tsx b/apps/web/src/components/ui/visually-hidden.tsx new file mode 100644 index 00000000..7d6fc435 --- /dev/null +++ b/apps/web/src/components/ui/visually-hidden.tsx @@ -0,0 +1,32 @@ +"use client"; + +import * as React from "react"; +import { cn } from "../../lib/utils"; + +/** + * VisuallyHidden component provides content that is accessible to screen readers + * but visually hidden from sighted users. This is useful for providing context + * or labels that are necessary for accessibility but would be redundant visually. + * + * Based on the Radix UI VisuallyHidden primitive pattern. + */ +const VisuallyHidden = React.forwardRef< + HTMLSpanElement, + React.ComponentPropsWithoutRef<"span"> +>(({ className, ...props }, ref) => ( + <span + ref={ref} + className={cn( + // Screen reader only styles - visually hidden but accessible + "absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0", + // Alternative approach using sr-only if preferred + // "sr-only", + className + )} + {...props} + /> +)); + +VisuallyHidden.displayName = "VisuallyHidden"; + +export { VisuallyHidden }; |
