From 8d464157b943d806c24c9e04de86eda7374d288c Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 5 Mar 2019 10:48:45 +0100 Subject: [PATCH] [docs] Add button demos in ts (#14739) * [docs] Add button demos in ts * [docs] Enable button ts demos --- docs/src/pages/demos/buttons/ButtonBases.js | 1 + docs/src/pages/demos/buttons/ButtonBases.tsx | 142 +++++++++++++++++ docs/src/pages/demos/buttons/ButtonSizes.tsx | 118 ++++++++++++++ .../pages/demos/buttons/ContainedButtons.js | 1 + .../pages/demos/buttons/ContainedButtons.tsx | 55 +++++++ .../pages/demos/buttons/CustomizedButtons.js | 2 +- .../pages/demos/buttons/CustomizedButtons.tsx | 99 ++++++++++++ .../buttons/FloatingActionButtonZoom.tsx | 148 ++++++++++++++++++ .../demos/buttons/FloatingActionButtons.tsx | 45 ++++++ docs/src/pages/demos/buttons/IconButtons.tsx | 50 ++++++ .../pages/demos/buttons/IconLabelButtons.tsx | 61 ++++++++ .../pages/demos/buttons/OutlinedButtons.js | 1 + .../pages/demos/buttons/OutlinedButtons.tsx | 58 +++++++ docs/src/pages/demos/buttons/TextButtons.js | 1 + docs/src/pages/demos/buttons/TextButtons.tsx | 52 ++++++ package.json | 1 + .../src/IconButton/IconButton.d.ts | 21 ++- pages/demos/buttons.js | 6 +- tsconfig.json | 5 +- yarn.lock | 7 + 20 files changed, 861 insertions(+), 13 deletions(-) create mode 100644 docs/src/pages/demos/buttons/ButtonBases.tsx create mode 100644 docs/src/pages/demos/buttons/ButtonSizes.tsx create mode 100644 docs/src/pages/demos/buttons/ContainedButtons.tsx create mode 100644 docs/src/pages/demos/buttons/CustomizedButtons.tsx create mode 100644 docs/src/pages/demos/buttons/FloatingActionButtonZoom.tsx create mode 100644 docs/src/pages/demos/buttons/FloatingActionButtons.tsx create mode 100644 docs/src/pages/demos/buttons/IconButtons.tsx create mode 100644 docs/src/pages/demos/buttons/IconLabelButtons.tsx create mode 100644 docs/src/pages/demos/buttons/OutlinedButtons.tsx create mode 100644 docs/src/pages/demos/buttons/TextButtons.tsx diff --git a/docs/src/pages/demos/buttons/ButtonBases.js b/docs/src/pages/demos/buttons/ButtonBases.js index e832dd6f46c75f..04ace325a7b05f 100644 --- a/docs/src/pages/demos/buttons/ButtonBases.js +++ b/docs/src/pages/demos/buttons/ButtonBases.js @@ -116,6 +116,7 @@ function ButtonBases(props) { backgroundImage: `url(${image.url})`, }} /> + + createStyles({ + root: { + display: 'flex', + flexWrap: 'wrap', + minWidth: 300, + width: '100%', + }, + image: { + position: 'relative', + height: 200, + [theme.breakpoints.down('xs')]: { + width: '100% !important', // Overrides inline-style + height: 100, + }, + '&:hover, &$focusVisible': { + zIndex: 1, + '& $imageBackdrop': { + opacity: 0.15, + }, + '& $imageMarked': { + opacity: 0, + }, + '& $imageTitle': { + border: '4px solid currentColor', + }, + }, + }, + focusVisible: {}, + 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, + backgroundColor: theme.palette.common.black, + opacity: 0.4, + transition: theme.transitions.create('opacity'), + }, + imageTitle: { + position: 'relative', + padding: `${theme.spacing(2)}px ${theme.spacing(4)}px ${theme.spacing(1) + 6}px`, + }, + imageMarked: { + height: 3, + width: 18, + backgroundColor: theme.palette.common.white, + position: 'absolute', + bottom: -2, + left: 'calc(50% - 9px)', + transition: theme.transitions.create('opacity'), + }, + }); + +const images = [ + { + url: '/static/images/grid-list/breakfast.jpg', + title: 'Breakfast', + width: '40%', + }, + { + url: '/static/images/grid-list/burgers.jpg', + title: 'Burgers', + width: '30%', + }, + { + url: '/static/images/grid-list/camera.jpg', + title: 'Camera', + width: '30%', + }, +]; + +function ButtonBases(props: WithStyles) { + const { classes } = props; + + return ( +
+ {images.map(image => ( + + + + + + {image.title} + + + + + ))} +
+ ); +} + +ButtonBases.propTypes = { + classes: PropTypes.object.isRequired, +} as any; + +export default withStyles(styles)(ButtonBases); diff --git a/docs/src/pages/demos/buttons/ButtonSizes.tsx b/docs/src/pages/demos/buttons/ButtonSizes.tsx new file mode 100644 index 00000000000000..4de722e7008343 --- /dev/null +++ b/docs/src/pages/demos/buttons/ButtonSizes.tsx @@ -0,0 +1,118 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles'; +import Button from '@material-ui/core/Button'; +import Fab from '@material-ui/core/Fab'; +import IconButton from '@material-ui/core/IconButton'; +import AddIcon from '@material-ui/icons/Add'; +import DeleteIcon from '@material-ui/icons/Delete'; +import NavigationIcon from '@material-ui/icons/Navigation'; +import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward'; + +const styles = (theme: Theme) => + createStyles({ + margin: { + margin: theme.spacing(1), + }, + extendedIcon: { + marginRight: theme.spacing(1), + }, + }); + +function ButtonSizes(props: WithStyles) { + const { classes } = props; + return ( +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + + + + + + + +
+
+ + + Extended + + + + Extended + + + + Extended + +
+
+ + + + + + + + + + + + +
+
+ ); +} + +ButtonSizes.propTypes = { + classes: PropTypes.object.isRequired, +} as any; + +export default withStyles(styles)(ButtonSizes); diff --git a/docs/src/pages/demos/buttons/ContainedButtons.js b/docs/src/pages/demos/buttons/ContainedButtons.js index 7f659c026ec4bf..c7c52184e73f32 100644 --- a/docs/src/pages/demos/buttons/ContainedButtons.js +++ b/docs/src/pages/demos/buttons/ContainedButtons.js @@ -38,6 +38,7 @@ function ContainedButtons(props) { multiple type="file" /> +