-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ButtonBase] Expose internal component (#7727)
- Loading branch information
1 parent
640e56e
commit 7933dfd
Showing
21 changed files
with
256 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!--- This documentation is automatically generated, do not try to edit it. --> | ||
|
||
# ButtonBase | ||
|
||
|
||
|
||
## Props | ||
| Name | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| centerRipple | boolean | false | If `true`, the ripples will be centered. They won't start at the cursor interaction position. | | ||
| children | Element | | The content of the component. | | ||
| classes | Object | {} | Useful to extend the style applied to components. | | ||
| component | union: string<br> Function<br> | | The component used for the root node. Either a string to use a DOM element or a component. The default value is a `button`. | | ||
| disableRipple | boolean | false | If `true`, the ripple effect will be disabled. | | ||
| disabled | boolean | | If `true`, the base button will be disabled. | | ||
| focusRipple | boolean | false | If `true`, the base button will have a keyboard focus ripple. `disableRipple` must also be `false`. | | ||
| keyboardFocusedClassName | string | | The CSS class applied while the component is keyboard focused. | | ||
| onKeyboardFocus | Function | | Callback fired when the component is focused with a keyboard. We trigger a `onFocus` callback too.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback | | ||
|
||
Any other properties supplied will be spread to the root element. | ||
|
||
## CSS API | ||
|
||
You can overrides all the class names injected by Material-UI thanks to the `classes` property. | ||
This property accepts the following keys: | ||
- `root` | ||
- `disabled` | ||
|
||
Have a look at [overriding with classes](/customization/overrides#overriding-with-classes) | ||
section for more detail. | ||
|
||
If using the `overrides` key of the theme as documented | ||
[here](/customization/themes#customizing-all-instances-of-a-component-type), | ||
you need to use the following style sheet name: `MuiButtonBase`. |
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,145 @@ | ||
// @flow weak | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles, createStyleSheet } from 'material-ui/styles'; | ||
import ButtonBase from 'material-ui/ButtonBase'; | ||
import Typography from 'material-ui/Typography'; | ||
import breakfastImage from 'docs/src/assets/images/grid-list/breakfast.jpg'; | ||
import burgersImage from 'docs/src/assets/images/grid-list/burgers.jpg'; | ||
import cameraImage from 'docs/src/assets/images/grid-list/camera.jpg'; | ||
|
||
const styleSheet = createStyleSheet(theme => ({ | ||
root: { | ||
marginTop: theme.spacing.unit * 4, | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
minWidth: 300, | ||
width: '100%', | ||
}, | ||
image: { | ||
position: 'relative', | ||
height: 200, | ||
[theme.breakpoints.down('sm')]: { | ||
width: '100% !important', // Overrides inline-style | ||
height: 100, | ||
}, | ||
'&:hover': { | ||
zIndex: 1, | ||
}, | ||
'&:hover $imageBackdrop': { | ||
opacity: 0.15, | ||
}, | ||
'&:hover $imageMarked': { | ||
opacity: 0, | ||
}, | ||
'&:hover $imageTitle': { | ||
border: '4px solid currentColor', | ||
}, | ||
}, | ||
imageButton: { | ||
position: 'absolute', | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
color: theme.palette.common.white, | ||
}, | ||
imageSrc: { | ||
position: 'absolute', | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
backgroundSize: 'cover', | ||
backgroundPosition: 'center 40%', | ||
}, | ||
imageBackdrop: { | ||
position: 'absolute', | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
background: theme.palette.common.black, | ||
opacity: 0.4, | ||
transition: theme.transitions.create('opacity'), | ||
}, | ||
imageTitle: { | ||
position: 'relative', | ||
padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 4}px ${theme.spacing.unit + 6}px`, | ||
}, | ||
imageMarked: { | ||
height: 3, | ||
width: 18, | ||
background: theme.palette.common.white, | ||
position: 'absolute', | ||
bottom: -2, | ||
left: 'calc(50% - 9px)', | ||
transition: theme.transitions.create('opacity'), | ||
}, | ||
})); | ||
|
||
const images = [ | ||
{ | ||
url: breakfastImage, | ||
title: 'Breakfast', | ||
width: '40%', | ||
}, | ||
{ | ||
url: burgersImage, | ||
title: 'Burgers', | ||
width: '30%', | ||
}, | ||
{ | ||
url: cameraImage, | ||
title: 'Camera', | ||
width: '30%', | ||
}, | ||
]; | ||
|
||
function ButtonBases(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
{images.map(image => | ||
<ButtonBase | ||
focusRipple | ||
key={image.title} | ||
className={classes.image} | ||
style={{ | ||
width: image.width, | ||
}} | ||
> | ||
<div | ||
className={classes.imageSrc} | ||
style={{ | ||
backgroundImage: `url(${image.url})`, | ||
}} | ||
/> | ||
<div className={classes.imageBackdrop} /> | ||
<div className={classes.imageButton}> | ||
<Typography | ||
component="h3" | ||
type="subheading" | ||
color="inherit" | ||
className={classes.imageTitle} | ||
> | ||
{image.title} | ||
<div className={classes.imageMarked} /> | ||
</Typography> | ||
</div> | ||
</ButtonBase>, | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
ButtonBases.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styleSheet)(ButtonBases); |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
// @flow | ||
|
||
export { default } from './ButtonBase'; |
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
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.