-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds paddingSize prop to EuiAccordion #701
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,17 @@ import { | |
EuiFlexItem, | ||
} from '../flex'; | ||
|
||
const paddingSizeToClassNameMap = { | ||
none: null, | ||
xs: 'euiAccordion__padding--xs', | ||
s: 'euiAccordion__padding--s', | ||
m: 'euiAccordion__padding--m', | ||
l: 'euiAccordion__padding--l', | ||
xl: 'euiAccordion__padding--xl', | ||
}; | ||
|
||
export const PADDING_SIZES = Object.keys(paddingSizeToClassNameMap); | ||
|
||
export class EuiAccordion extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
@@ -45,16 +56,22 @@ export class EuiAccordion extends Component { | |
buttonClassName, | ||
buttonContentClassName, | ||
extraAction, | ||
paddingSize, | ||
initialIsOpen, // eslint-disable-line no-unused-vars | ||
...rest | ||
} = this.props; | ||
|
||
|
||
const classes = classNames( | ||
'euiAccordion', | ||
{ | ||
'euiAccordion-isOpen': this.state.isOpen, | ||
}, | ||
className | ||
className, | ||
); | ||
|
||
const paddingClass = classNames( | ||
paddingSizeToClassNameMap[paddingSize], | ||
); | ||
|
||
const buttonClasses = classNames( | ||
|
@@ -115,7 +132,9 @@ export class EuiAccordion extends Component { | |
id={id} | ||
> | ||
<div ref={node => { this.childContent = node; }}> | ||
{children} | ||
<div className={paddingClass}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to put the paddingClass directly on the ref'd div versus creating another dom node layer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that originally. It didn't work with the height calculations and messed up the calculation. |
||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -124,15 +143,38 @@ export class EuiAccordion extends Component { | |
} | ||
|
||
EuiAccordion.propTypes = { | ||
/** | ||
* The content of the exposed accordion. | ||
*/ | ||
children: PropTypes.node, | ||
id: PropTypes.string.isRequired, | ||
/** | ||
* Class that will apply to the entire accordion. | ||
*/ | ||
className: PropTypes.string, | ||
/** | ||
* Class that will apply to the trigger for the accordion. | ||
*/ | ||
buttonContentClassName: PropTypes.string, | ||
/** | ||
* The content of the clickable trigger | ||
*/ | ||
buttonContent: PropTypes.node, | ||
/** | ||
* Will appear right aligned against the button. Useful for separate actions like deletions. | ||
*/ | ||
extraAction: PropTypes.node, | ||
/** | ||
* The accordion will start in the open state. | ||
*/ | ||
initialIsOpen: PropTypes.bool, | ||
/** | ||
* The padding around the exposed accordion content. | ||
*/ | ||
paddingSize: PropTypes.oneOf(PADDING_SIZES), | ||
}; | ||
|
||
EuiAccordion.defaultProps = { | ||
initialIsOpen: false, | ||
paddingSize: 'none', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was never properly componentized. I was using it in the example docs as a singleton class, which is why the forms with flex groups weren't breaking. It is no longer needed now that there's a prop to manage padding.