Skip to content

Commit

Permalink
fix: added accordion button props so we can customize type
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagogomes772 committed May 24, 2024
1 parent 1c02bec commit f08119b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/yoga/src/Accordion/web/Accordion.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import styled, { css } from 'styled-components';
import { string, node, bool } from 'prop-types';
import { string, node, bool, shape } from 'prop-types';
import { ChevronDown } from '@gympass/yoga-icons';
import { Text, Divider } from '../..';
import Content from './Content';
Expand Down Expand Up @@ -206,6 +206,7 @@ const Accordion = ({
expanded,
small,
hasHorizontalPadding,
headerProps,
...props
}) => {
const [open, setOpen] = useState(expanded);
Expand All @@ -220,9 +221,13 @@ const Accordion = ({
disabled={disabled}
onClick={() => {
setOpen(o => !o);
if (headerProps.onClick) {
headerProps.onClick();
}
}}
small={small}
hasHorizontalPadding={hasHorizontalPadding}
{...headerProps}
>
{hasSummary ? (
summary
Expand Down Expand Up @@ -270,6 +275,9 @@ Accordion.propTypes = {
expanded: bool,
small: bool,
hasHorizontalPadding: bool,
/** if provided displays a button below the item text. It accepts all button
* element props */
headerProps: shape({}),
};

Accordion.defaultProps = {
Expand All @@ -279,6 +287,7 @@ Accordion.defaultProps = {
expanded: false,
small: false,
hasHorizontalPadding: true,
headerProps: {},
};

export default Accordion;

0 comments on commit f08119b

Please sign in to comment.