diff --git a/components/molecule/collapsible/demo/ArticleAlignment.js b/components/molecule/collapsible/demo/ArticleAlignment.js index 7d70e9b245..2ccafd5b03 100644 --- a/components/molecule/collapsible/demo/ArticleAlignment.js +++ b/components/molecule/collapsible/demo/ArticleAlignment.js @@ -10,13 +10,14 @@ const ArticleAlignment = ({className, icon, showText, hideText}) => {

Collapsible Alignment

- These are the options for the prop alignContainer + These are the options for the prop alignContainer and{' '} + alignButton (default left)

- Collapsible Left + Collapsible Left and Button Left
{
- Collapsible Center + Collapsible Center and Button Center
@@ -55,6 +57,7 @@ const ArticleAlignment = ({className, icon, showText, hideText}) => { showText={showText} hideText={hideText} alignContainer="right" + alignButton="right" > diff --git a/components/molecule/collapsible/demo/ArticleCustomToggleButton.js b/components/molecule/collapsible/demo/ArticleCustomToggleButton.js new file mode 100644 index 0000000000..fb7da1feb6 --- /dev/null +++ b/components/molecule/collapsible/demo/ArticleCustomToggleButton.js @@ -0,0 +1,73 @@ +import PropTypes from 'prop-types' + +import {Article, Code, H2, Paragraph} from '@s-ui/documentation-library' +import Button, { + atomButtonDesigns, + atomButtonShapes, + atomButtonSizes +} from '@s-ui/react-atom-button' + +import MoleculeCollapsible from '../src/index.js' +import {DemoWrapper, Text} from './config/index.js' + +const ArticleCustomToggleButton = ({className, icon, showText, hideText}) => { + const ToggleButton = props => { + return ( +
+ +
+ ) + } + + return ( +
+

Collapsible Gradient

+ + The prop toggleButton accepts a custom component to toggle + collapse + +
+
+ +
+ Custom toggle button +
+ + + +
+
+
+
+ ) +} + +ArticleCustomToggleButton.propTypes = { + className: PropTypes.string, + icon: PropTypes.node, + showText: PropTypes.string, + hideText: PropTypes.string +} + +export default ArticleCustomToggleButton diff --git a/components/molecule/collapsible/demo/ArticleGradient.js b/components/molecule/collapsible/demo/ArticleGradient.js index 80a1beeb99..10e290278a 100644 --- a/components/molecule/collapsible/demo/ArticleGradient.js +++ b/components/molecule/collapsible/demo/ArticleGradient.js @@ -37,7 +37,7 @@ const ArticleGradient = ({className, icon, showText, hideText}) => {
- Collapsible whithout Gradient + Collapsible without Gradient
{

+ +
+
{}, onOpen = () => {}, + alignButton, alignContainer, children, height = MIN_HEIGHT, + hideText, icon, showText, - hideText, + toggleButton: ToggleButton, withGradient = true, withOverflow = false, withTransition = true @@ -56,6 +59,7 @@ const MoleculeCollapsible = ({ }) const containerClassName = cx(`${CONTAINER_BUTTON_CLASS}`, { [`${CONTAINER_BUTTON_CLASS}--withGradient`]: withGradient, + [`${CONTAINER_BUTTON_CLASS}--alignButton-${alignButton}`]: alignButton, [COLLAPSED_CLASS]: collapsed }) const contentClassName = cx(`${CONTENT_CLASS}`, { @@ -75,16 +79,25 @@ const MoleculeCollapsible = ({
{showButton && (
- + + ) : ( + + )}
)}
@@ -94,6 +107,10 @@ const MoleculeCollapsible = ({ MoleculeCollapsible.displayName = 'MoleculeCollapsible' MoleculeCollapsible.propTypes = { + /** + * Container button center || left || right + */ + alignButton: PropTypes.oneOf(Object.values(BUTTON_ALIGN)), /** * Container align center || right */ @@ -106,6 +123,10 @@ MoleculeCollapsible.propTypes = { * Define the min height visible */ height: PropTypes.number, + /** + * Custom toggle button + */ + toggleButton: PropTypes.node, /** * Icon to be added on the right of the content */ diff --git a/components/molecule/collapsible/src/settings.js b/components/molecule/collapsible/src/settings.js index 4ad5049ce6..378a71b99d 100644 --- a/components/molecule/collapsible/src/settings.js +++ b/components/molecule/collapsible/src/settings.js @@ -12,3 +12,8 @@ export const CONTENT_ALIGN = { CENTER: 'center', RIGHT: 'right' } + +export const BUTTON_ALIGN = { + CENTER: 'center', + RIGHT: 'right' +} diff --git a/components/molecule/collapsible/src/styles/index.scss b/components/molecule/collapsible/src/styles/index.scss index 5fa094208e..1f58e295cf 100644 --- a/components/molecule/collapsible/src/styles/index.scss +++ b/components/molecule/collapsible/src/styles/index.scss @@ -58,9 +58,18 @@ $base-class: '.sui-MoleculeCollapsible'; &-container { background-color: $bgc-collapsible-container; position: relative; - text-align: $ta-collapsible-container; width: 100%; + &--alignButton { + &-center { + text-align: center; + } + + &-right { + text-align: right; + } + } + &#{&}--withGradient.is-collapsed { &::before { background: $bg-collapsible-container-gradient;