import UI from "../ui"; import React, { ReactNode } from "react"; type ComponentProps = React.ComponentProps; /** * Renders children elements without any wrapping component. * Can be used as a placeholder when no semantic landmark is needed. */ export const Landmarks = (children?: React.FC) => <>{children}; type HeaderProps = { headerBackground?: ReactNode; } & ComponentProps; /** * Header component. * * Renders a header landmark with a section child. * * @param children - The content to render inside the header. * @param styles - Optional styles object. * @param props - Other props. */ export const Header = ({ id, children, headerBackground, styles, classes, ...props }: HeaderProps) => { return ( {headerBackground} {children} ); }; /** * Main component. * * Renders a main landmark. * * @param children - The content to render inside the main element. * @param styles - Optional styles object. * @param props - Other props. */ export const Main = ({ id, children, styles, classes, ...props }: ComponentProps) => { return ( {children} ); }; /** * Footer component that renders a footer element with a section element inside. * @param {ReactNode} children - Child elements to render inside the section element. * @param styles - CSS styles to apply to the footer element. * @param props - Additional props to pass to the footer element. * @returns A React component that renders a footer element with a section element inside. */ export const Footer = ({ id, classes, children, styles = {}, ...props }: ComponentProps) => { return ( {children || "Copyright © 2022"} ); }; export const Aside = ({ id, children, styles = {}, classes, ...props }: ComponentProps) => { return ( {children} ); }; /** * Section component that renders a section element. * * @param children - Child elements to render inside the section. * @param styles - CSS styles to apply to the section. * @param props - Other props. */ export const Section = ({ id, children, styles, classes, ...props }: ComponentProps) => { return ( {children} ); }; /** * Article component renders an HTML
element. * * @param children - Child elements to render inside the article. * @param styles - CSS styles to apply to the article. * @param props - Additional props to pass to the article element. */ export const Article = ({ id, children, styles, classes, ...props }: ComponentProps) => { return ( {children} ); }; type FieldsetProps = { /** * Optional legend content displayed as the fieldset's accessible name */ legend?: ReactNode; /** * Additional description text for complex fieldsets * Enhances accessibility via aria-describedby */ description?: string; /** * Custom ID for the description element * Auto-generated if description is provided without custom ID */ descriptionId?: string; } & ComponentProps; /** * Fieldset landmark for semantic content grouping. * Provides WCAG 2.1 Level AA compliant form grouping with optional descriptions. * * @param legend - Optional legend content (accessible name) * @param description - Optional description for additional context * @param descriptionId - Custom ID for description element * @param children - Content inside fieldset section * * @example * ```tsx *
* {/* form controls *\/} *
* ``` */ export const Fieldset = ({ id, children, legend, description, descriptionId, styles, classes, ...props }: FieldsetProps) => { const descId = descriptionId || (description ? `${id}-desc` : undefined); return ( {legend && {legend}} {description && (

{description}

)} {children}
); }; export default Landmarks; Landmarks.displayName = "Landmarks"; Landmarks.Header = Header; Landmarks.Main = Main; Landmarks.Footer = Footer; Landmarks.Aside = Aside; Landmarks.Section = Section; Landmarks.Article = Article; Landmarks.Fieldset = Fieldset;