forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breadcrumbs] Migrate to emotion (mui#24522)
- Loading branch information
1 parent
68f86c2
commit 27bbb5b
Showing
13 changed files
with
235 additions
and
86 deletions.
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
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
89 changes: 63 additions & 26 deletions
89
packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.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 |
---|---|---|
@@ -1,52 +1,89 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import withStyles from '../styles/withStyles'; | ||
import { unstable_composeClasses as composeClasses } from '@material-ui/unstyled'; | ||
import experimentalStyled from '../styles/experimentalStyled'; | ||
import { emphasize } from '../styles/colorManipulator'; | ||
import MoreHorizIcon from '../internal/svg-icons/MoreHoriz'; | ||
import ButtonBase from '../ButtonBase'; | ||
import { getBreadcrumbCollapsedUtilityClass } from './breadcrumbCollapsedClasses'; | ||
|
||
const styles = (theme) => ({ | ||
button: { | ||
display: 'flex', | ||
marginLeft: theme.spacing(0.5), | ||
marginRight: theme.spacing(0.5), | ||
backgroundColor: theme.palette.grey[100], | ||
color: theme.palette.grey[700], | ||
borderRadius: 2, | ||
'&:hover, &:focus': { | ||
backgroundColor: theme.palette.grey[200], | ||
}, | ||
'&:active': { | ||
boxShadow: theme.shadows[0], | ||
backgroundColor: emphasize(theme.palette.grey[200], 0.12), | ||
}, | ||
const useUtilityClasses = (styleProps) => { | ||
const { classes } = styleProps; | ||
|
||
const slots = { | ||
button: ['button'], | ||
icon: ['icon'], | ||
}; | ||
|
||
return composeClasses(slots, getBreadcrumbCollapsedUtilityClass, classes); | ||
}; | ||
|
||
const BreadcrumbCollapsedButton = experimentalStyled( | ||
ButtonBase, | ||
{}, | ||
{ | ||
name: 'PrivateBreadcrumbCollapsed', | ||
slot: 'Button', | ||
}, | ||
icon: { | ||
width: 24, | ||
height: 16, | ||
)(({ theme }) => ({ | ||
display: 'flex', | ||
marginLeft: theme.spacing(0.5), | ||
marginRight: theme.spacing(0.5), | ||
...(theme.palette.mode === 'light' | ||
? { backgroundColor: theme.palette.grey[100], color: theme.palette.grey[700] } | ||
: { backgroundColor: theme.palette.grey[700], color: theme.palette.grey[100] }), | ||
borderRadius: 2, | ||
'&:hover, &:focus': { | ||
...(theme.palette.mode === 'light' | ||
? { backgroundColor: theme.palette.grey[200] } | ||
: { backgroundColor: theme.palette.grey[600] }), | ||
}, | ||
'&:active': { | ||
boxShadow: theme.shadows[0], | ||
...(theme.palette.mode === 'light' | ||
? { backgroundColor: emphasize(theme.palette.grey[200], 0.12) } | ||
: { backgroundColor: emphasize(theme.palette.grey[600], 0.12) }), | ||
}, | ||
})); | ||
|
||
const BreadcrumbCollapsedIcon = experimentalStyled( | ||
MoreHorizIcon, | ||
{}, | ||
{ | ||
name: 'PrivateBreadcrumbCollapsed', | ||
slot: 'Icon', | ||
}, | ||
)({ | ||
width: 24, | ||
height: 16, | ||
}); | ||
|
||
/** | ||
* @ignore - internal component. | ||
*/ | ||
function BreadcrumbCollapsed(props) { | ||
const { classes, ...other } = props; | ||
const styleProps = props; | ||
const classes = useUtilityClasses(styleProps); | ||
|
||
return ( | ||
<li> | ||
<ButtonBase className={classes.button} focusRipple {...other}> | ||
<MoreHorizIcon className={classes.icon} /> | ||
</ButtonBase> | ||
<BreadcrumbCollapsedButton | ||
className={classes.button} | ||
focusRipple | ||
{...props} | ||
styleProps={styleProps} | ||
> | ||
<BreadcrumbCollapsedIcon className={classes.icon} styleProps={styleProps} /> | ||
</BreadcrumbCollapsedButton> | ||
</li> | ||
); | ||
} | ||
|
||
BreadcrumbCollapsed.propTypes = { | ||
/** | ||
* @ignore | ||
* The system prop that allows defining system overrides as well as additional CSS styles. | ||
*/ | ||
classes: PropTypes.object.isRequired, | ||
sx: PropTypes.object, | ||
}; | ||
|
||
export default withStyles(styles, { name: 'PrivateBreadcrumbCollapsed' })(BreadcrumbCollapsed); | ||
export default BreadcrumbCollapsed; |
8 changes: 2 additions & 6 deletions
8
packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.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
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.