Dynamic and Accessible Multi-Expand Accordion
At OYO, providing detailed and well-structured information about properties is crucial for guest satisfaction and booking conversion. We often need to display various sections of information (e.g., amenities, house rules, location details) in a compact and user-friendly manner. This problem challenges you to build a flexible and accessible Accordion component that can handle multiple expandable sections, enhancing the user experience on our property detail pages.
Your primary task is to develop a reusable and controlled Accordion component in React/TypeScript.
Accordion component: This component should accept an array of AccordionItemData (defined below) and manage the rendering of individual accordion items.AccordionItem component: A sub-component responsible for rendering a single accordion section, including its header and expandable content.Accordion component should be a controlled component, meaning its parent (App in this case) dictates which items are open via props and receives callbacks when an item is toggled. It should support having multiple items open simultaneously.AccordionItemData provided.Space or Enter key to toggle an item when its header is focused) and appropriate ARIA attributes (aria-expanded, aria-controls, role="heading", role="region").Accordion component renders all provided items.App component successfully controls the open/closed state of the accordion items.Tab and toggle items using Space or Enter.aria-expanded, aria-controls, role="heading", role="region") are correctly applied to the accordion elements.Constraints
AccordionItemData structure will be provided in /App.tsx.Accordion and AccordionItem components are structured, how reusable they are, and how effectively state and props are managed for controlled behavior.Loading editor...