diff --git a/src/accordion/Accordion.tsx b/src/accordion/Accordion.tsx index c22affc..b930978 100644 --- a/src/accordion/Accordion.tsx +++ b/src/accordion/Accordion.tsx @@ -1,4 +1,4 @@ -import React, { useState, ReactNode } from 'react'; +import React, { useState, ReactNode, PropsWithChildren } from 'react'; import { css } from '@emotion/react'; import { Heading } from '../content'; import { Icon, ArrowIosDownwardOutline } from '../icon'; @@ -27,6 +27,7 @@ const accordionItemCSS = css` color: var(--ac-global-text-color-900); border-bottom: 1px solid var(--ac-global-border-color-dark); transition: background-color ease-in-out 0.2s; + box-sizing: border-box; &:hover { background-color: var(--ac-global-background-color-light); } @@ -102,13 +103,15 @@ export function AccordionItem(props: AccordionItemProps) { css={css` display: flex; flex-direction: row; + align-items: center; + justify-content: center; .ac-accordion-item__title { margin-right: var(--ac-global-dimension-static-size-50); } `} > {title} - {titleExtra} + {titleExtra && <>{titleExtra}} ) : ( {title} @@ -128,40 +131,40 @@ export function AccordionItem(props: AccordionItemProps) { } `} > - - - + aria-hidden={true} + /> + + +
); } + +/** + * A wrapper component that stops the event from propagating up the DOM tree + */ +function StopEventPropagation(props: PropsWithChildren) { + return ( +
{ + e.stopPropagation(); + }} + > + {props.children} +
+ ); +} diff --git a/stories/Accordion.stories.tsx b/stories/Accordion.stories.tsx index 048ab91..3bbd0d3 100644 --- a/stories/Accordion.stories.tsx +++ b/stories/Accordion.stories.tsx @@ -51,6 +51,11 @@ const Template: Story = args => { Description of predictions} + extra={ + + } id="predictions" >