Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
add type attribute to accordion button and allow passing cssOverrides…
Browse files Browse the repository at this point in the history
… prop
  • Loading branch information
i-hardy committed Feb 5, 2021
1 parent 3be8c40 commit 8a27ee2
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/core/components/accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ interface AccordionProps extends Props {
const Accordion = ({
hideToggleLabel = false,
children,
cssOverrides,
...props
}: AccordionProps) => {
return (
<div css={(theme) => accordion(theme.accordion && theme)} {...props}>
<div
css={(theme) => [accordion(theme.accordion && theme), cssOverrides]}
{...props}
>
{React.Children.map(children, (child) => {
return React.cloneElement(child, { hideToggleLabel });
})}
Expand All @@ -55,10 +59,18 @@ const NoJsRow = ({
label,
hideToggleLabel = false,
children,
onClick,
cssOverrides,
...props
}: AccordionRowProps) => {
return (
<div css={(theme) => accordionRow(theme.accordion && theme)} {...props}>
<div
css={(theme) => [
accordionRow(theme.accordion && theme),
cssOverrides,
]}
{...props}
>
<label>
<input type="checkbox" css={noJsInput} role="button" />
<div
Expand Down Expand Up @@ -117,7 +129,8 @@ const AccordionRow = ({
label,
hideToggleLabel = false,
children,
onClick = () => {},
cssOverrides,
onClick = () => undefined,
}: AccordionRowProps) => {
const [expanded, setExpanded] = useState(false);
const collapse = () => setExpanded(false);
Expand All @@ -135,8 +148,14 @@ const AccordionRow = ({

if (isBrowser) {
return (
<div css={(theme) => accordionRow(theme.accordion && theme)}>
<div
css={(theme) => [
accordionRow(theme.accordion && theme),
cssOverrides,
]}
>
<button
type="button"
aria-expanded={expanded}
onClick={handleClick}
css={(theme) => [
Expand Down

0 comments on commit 8a27ee2

Please sign in to comment.