-
Notifications
You must be signed in to change notification settings - Fork 16
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
New DS core component: accordion #632
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8babd6d
fist approach to accordion story and components
vmilan 977e863
styles and props for accordion
vmilan 4d46565
stories for accordion
vmilan dbf72f9
types and export component
vmilan 0b90485
merge with master
vmilan 08bd1e7
merge with master
vmilan 03872ee
design review
vmilan 27727d4
cleanup
vmilan 1bc6694
design validation
vmilan 9e2e317
fix test
vmilan 8b96a55
merge with master
vmilan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/react-ui/src/components/molecules/AccordionGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
|
||
const AccordionContainer = styled('div', { | ||
shouldForwardProp: (prop) => prop !== 'variant' | ||
})(({ variant, theme }) => ({ | ||
width: '100%', | ||
borderRadius: theme.spacing(0.5), | ||
|
||
...(variant === 'outlined' && { | ||
backgroundColor: theme.palette.background.paper, | ||
boxShadow: `inset 0 0 0 1px ${theme.palette.divider}` | ||
}) | ||
})); | ||
|
||
const AccordionGroup = ({ variant, items, ...otherProps }) => { | ||
return ( | ||
<AccordionContainer {...otherProps} variant={variant}> | ||
{items.map((item, index) => ( | ||
<Accordion | ||
key={index} | ||
disabled={item.disabled} | ||
defaultExpanded={item.defaultExpanded} | ||
onChange={item.onChange} | ||
> | ||
<AccordionSummary aria-controls={`${index}-content`} id={`${index}-header`}> | ||
{item.summary} | ||
</AccordionSummary> | ||
<AccordionDetails>{item.content}</AccordionDetails> | ||
</Accordion> | ||
))} | ||
</AccordionContainer> | ||
); | ||
}; | ||
|
||
AccordionGroup.defaultProps = { | ||
variant: 'standard' | ||
}; | ||
AccordionGroup.propTypes = { | ||
variant: PropTypes.oneOf(['standard' | 'outlined']), | ||
items: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
summary: PropTypes.string.isRequired, | ||
content: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).isRequired, | ||
disabled: PropTypes.boolean, | ||
defaultExpanded: PropTypes.boolean, | ||
onChange: PropTypes.func | ||
}) | ||
).isRequired | ||
}; | ||
|
||
export default AccordionGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity.
We've got
theme.shadows
. Are they of no use here? If not, when they should be used (they are used in extensively in cloud-native)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 boxShadow use is custom, to simulate a border indeed... Designers wanted to have this line inside the element itself, and using an inset border didn't work properly.
But yes, we use
theme.shadows
for common use cases.