From cf3cb81cb3e22b90d1b0beba25a8a4906e8fd6e4 Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Wed, 10 Mar 2021 09:14:06 -0300 Subject: [PATCH 1/2] [docs] Migrate AppBar demos to emotion --- .../src/pages/components/app-bar/BackToTop.js | 18 +-- .../pages/components/app-bar/BackToTop.tsx | 20 +-- .../pages/components/app-bar/BottomAppBar.js | 67 +++----- .../pages/components/app-bar/BottomAppBar.tsx | 69 +++------ .../pages/components/app-bar/ButtonAppBar.js | 29 +--- .../pages/components/app-bar/ButtonAppBar.tsx | 31 +--- .../pages/components/app-bar/DenseAppBar.js | 24 +-- .../pages/components/app-bar/DenseAppBar.tsx | 26 +--- .../pages/components/app-bar/MenuAppBar.js | 28 +--- .../pages/components/app-bar/MenuAppBar.tsx | 30 +--- .../components/app-bar/PrimarySearchAppBar.js | 119 ++++++--------- .../app-bar/PrimarySearchAppBar.tsx | 143 ++++++++---------- .../components/app-bar/ProminentAppBar.js | 43 +++--- .../components/app-bar/ProminentAppBar.tsx | 43 +++--- .../pages/components/app-bar/SearchAppBar.js | 97 +++++------- .../pages/components/app-bar/SearchAppBar.tsx | 125 +++++++-------- docs/src/pages/components/app-bar/app-bar.md | 7 +- 17 files changed, 326 insertions(+), 593 deletions(-) diff --git a/docs/src/pages/components/app-bar/BackToTop.js b/docs/src/pages/components/app-bar/BackToTop.js index f9b8a86fb7ed13..dba57aa2e93390 100644 --- a/docs/src/pages/components/app-bar/BackToTop.js +++ b/docs/src/pages/components/app-bar/BackToTop.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; -import { makeStyles } from '@material-ui/core/styles'; import CssBaseline from '@material-ui/core/CssBaseline'; import useScrollTrigger from '@material-ui/core/useScrollTrigger'; import Box from '@material-ui/core/Box'; @@ -12,17 +11,8 @@ import Fab from '@material-ui/core/Fab'; import KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp'; import Zoom from '@material-ui/core/Zoom'; -const useStyles = makeStyles((theme) => ({ - root: { - position: 'fixed', - bottom: theme.spacing(2), - right: theme.spacing(2), - }, -})); - function ScrollTop(props) { const { children, window } = props; - const classes = useStyles(); // Note that you normally won't need to set the window ref as useScrollTrigger // will default to window. // This is only being set here because the demo is in an iframe. @@ -47,9 +37,13 @@ function ScrollTop(props) { return ( -
+ {children} -
+
); } diff --git a/docs/src/pages/components/app-bar/BackToTop.tsx b/docs/src/pages/components/app-bar/BackToTop.tsx index e591a68395321c..91d4ef78bb1b54 100644 --- a/docs/src/pages/components/app-bar/BackToTop.tsx +++ b/docs/src/pages/components/app-bar/BackToTop.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; -import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; import CssBaseline from '@material-ui/core/CssBaseline'; import useScrollTrigger from '@material-ui/core/useScrollTrigger'; import Box from '@material-ui/core/Box'; @@ -20,19 +19,8 @@ interface Props { children: React.ReactElement; } -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - position: 'fixed', - bottom: theme.spacing(2), - right: theme.spacing(2), - }, - }), -); - function ScrollTop(props: Props) { const { children, window } = props; - const classes = useStyles(); // Note that you normally won't need to set the window ref as useScrollTrigger // will default to window. // This is only being set here because the demo is in an iframe. @@ -57,9 +45,13 @@ function ScrollTop(props: Props) { return ( -
+ {children} -
+
); } diff --git a/docs/src/pages/components/app-bar/BottomAppBar.js b/docs/src/pages/components/app-bar/BottomAppBar.js index 6b6679371ae920..7a08d60f1cbdfb 100644 --- a/docs/src/pages/components/app-bar/BottomAppBar.js +++ b/docs/src/pages/components/app-bar/BottomAppBar.js @@ -1,6 +1,7 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import CssBaseline from '@material-ui/core/CssBaseline'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; @@ -67,60 +68,34 @@ const messages = [ }, ]; -const useStyles = makeStyles((theme) => ({ - text: { - padding: theme.spacing(2, 2, 0), - }, - paper: { - paddingBottom: 50, - }, - list: { - marginBottom: theme.spacing(2), - }, - subheader: { - backgroundColor: theme.palette.background.paper, - }, - appBar: { - top: 'auto', - bottom: 0, - }, - grow: { - flexGrow: 1, - }, - fabButton: { - position: 'absolute', - zIndex: 1, - top: -30, - left: 0, - right: 0, - margin: '0 auto', - }, -})); +const StyledFab = styled(Fab)({ + position: 'absolute', + zIndex: 1, + top: -30, + left: 0, + right: 0, + margin: '0 auto', +}); export default function BottomAppBar() { - const classes = useStyles(); - return ( - - + + Inbox - + {messages.map(({ id, primary, secondary, person }) => ( {id === 1 && ( - Today + + Today + )} {id === 3 && ( - + Yesterday )} @@ -135,15 +110,15 @@ export default function BottomAppBar() { ))} - + - + - -
+ + diff --git a/docs/src/pages/components/app-bar/BottomAppBar.tsx b/docs/src/pages/components/app-bar/BottomAppBar.tsx index 5b5f6888174cc1..3515dc18b0294d 100644 --- a/docs/src/pages/components/app-bar/BottomAppBar.tsx +++ b/docs/src/pages/components/app-bar/BottomAppBar.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; -import { createStyles, Theme, makeStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import CssBaseline from '@material-ui/core/CssBaseline'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; @@ -67,61 +68,33 @@ const messages = [ }, ]; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - text: { - padding: theme.spacing(2, 2, 0), - }, - paper: { - paddingBottom: 50, - }, - list: { - marginBottom: theme.spacing(2), - }, - subheader: { - backgroundColor: theme.palette.background.paper, - }, - appBar: { - top: 'auto', - bottom: 0, - }, - grow: { - flexGrow: 1, - }, - fabButton: { - position: 'absolute', - zIndex: 1, - top: -30, - left: 0, - right: 0, - margin: '0 auto', - }, - }), -); +const StyledFab = styled(Fab)({ + position: 'absolute', + zIndex: 1, + top: -30, + left: 0, + right: 0, + margin: '0 auto', +}); export default function BottomAppBar() { - const classes = useStyles(); - return ( - - + + Inbox - + {messages.map(({ id, primary, secondary, person }) => ( {id === 1 && ( - Today + + Today + )} {id === 3 && ( - + Yesterday )} @@ -135,15 +108,15 @@ export default function BottomAppBar() { ))} - + - + - -
+ + diff --git a/docs/src/pages/components/app-bar/ButtonAppBar.js b/docs/src/pages/components/app-bar/ButtonAppBar.js index 46dc7c4721da84..3d48def9855894 100644 --- a/docs/src/pages/components/app-bar/ButtonAppBar.js +++ b/docs/src/pages/components/app-bar/ButtonAppBar.js @@ -1,45 +1,26 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; import IconButton from '@material-ui/core/IconButton'; import MenuIcon from '@material-ui/icons/Menu'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - flexGrow: 1, - }, -})); - export default function ButtonAppBar() { - const classes = useStyles(); - return ( -
+ - + - + News -
+
); } diff --git a/docs/src/pages/components/app-bar/ButtonAppBar.tsx b/docs/src/pages/components/app-bar/ButtonAppBar.tsx index f1ff39bd80bab1..3d48def9855894 100644 --- a/docs/src/pages/components/app-bar/ButtonAppBar.tsx +++ b/docs/src/pages/components/app-bar/ButtonAppBar.tsx @@ -1,47 +1,26 @@ import * as React from 'react'; -import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; import IconButton from '@material-ui/core/IconButton'; import MenuIcon from '@material-ui/icons/Menu'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - flexGrow: 1, - }, - }), -); - export default function ButtonAppBar() { - const classes = useStyles(); - return ( -
+ - + - + News -
+ ); } diff --git a/docs/src/pages/components/app-bar/DenseAppBar.js b/docs/src/pages/components/app-bar/DenseAppBar.js index 2569203fca198f..15e661f959fa98 100644 --- a/docs/src/pages/components/app-bar/DenseAppBar.js +++ b/docs/src/pages/components/app-bar/DenseAppBar.js @@ -1,33 +1,17 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import IconButton from '@material-ui/core/IconButton'; import MenuIcon from '@material-ui/icons/Menu'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, -})); - export default function DenseAppBar() { - const classes = useStyles(); - return ( -
+ - + @@ -35,6 +19,6 @@ export default function DenseAppBar() { -
+ ); } diff --git a/docs/src/pages/components/app-bar/DenseAppBar.tsx b/docs/src/pages/components/app-bar/DenseAppBar.tsx index d87c28f03c329d..15e661f959fa98 100644 --- a/docs/src/pages/components/app-bar/DenseAppBar.tsx +++ b/docs/src/pages/components/app-bar/DenseAppBar.tsx @@ -1,35 +1,17 @@ import * as React from 'react'; -import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import IconButton from '@material-ui/core/IconButton'; import MenuIcon from '@material-ui/icons/Menu'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - }), -); - export default function DenseAppBar() { - const classes = useStyles(); - return ( -
+ - + @@ -37,6 +19,6 @@ export default function DenseAppBar() { -
+ ); } diff --git a/docs/src/pages/components/app-bar/MenuAppBar.js b/docs/src/pages/components/app-bar/MenuAppBar.js index 4e2776a91fb7f6..efc4e9a105cd6a 100644 --- a/docs/src/pages/components/app-bar/MenuAppBar.js +++ b/docs/src/pages/components/app-bar/MenuAppBar.js @@ -1,6 +1,6 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import IconButton from '@material-ui/core/IconButton'; @@ -12,20 +12,7 @@ import FormGroup from '@material-ui/core/FormGroup'; import MenuItem from '@material-ui/core/MenuItem'; import Menu from '@material-ui/core/Menu'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - flexGrow: 1, - }, -})); - export default function MenuAppBar() { - const classes = useStyles(); const [auth, setAuth] = React.useState(true); const [anchorEl, setAnchorEl] = React.useState(null); @@ -42,7 +29,7 @@ export default function MenuAppBar() { }; return ( -
+ - + - + Photos {auth && ( @@ -101,6 +83,6 @@ export default function MenuAppBar() { )} -
+ ); } diff --git a/docs/src/pages/components/app-bar/MenuAppBar.tsx b/docs/src/pages/components/app-bar/MenuAppBar.tsx index 256f1922347c1f..ab462d59cea13d 100644 --- a/docs/src/pages/components/app-bar/MenuAppBar.tsx +++ b/docs/src/pages/components/app-bar/MenuAppBar.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import IconButton from '@material-ui/core/IconButton'; @@ -12,22 +12,7 @@ import FormGroup from '@material-ui/core/FormGroup'; import MenuItem from '@material-ui/core/MenuItem'; import Menu from '@material-ui/core/Menu'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - flexGrow: 1, - }, - }), -); - export default function MenuAppBar() { - const classes = useStyles(); const [auth, setAuth] = React.useState(true); const [anchorEl, setAnchorEl] = React.useState(null); @@ -44,7 +29,7 @@ export default function MenuAppBar() { }; return ( -
+ - + - + Photos {auth && ( @@ -103,6 +83,6 @@ export default function MenuAppBar() { )} -
+ ); } diff --git a/docs/src/pages/components/app-bar/PrimarySearchAppBar.js b/docs/src/pages/components/app-bar/PrimarySearchAppBar.js index a4b9a7e3e5c195..ff89210ce367e7 100644 --- a/docs/src/pages/components/app-bar/PrimarySearchAppBar.js +++ b/docs/src/pages/components/app-bar/PrimarySearchAppBar.js @@ -1,6 +1,7 @@ import * as React from 'react'; -import { alpha, makeStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled, alpha } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; @@ -15,47 +16,35 @@ import MailIcon from '@material-ui/icons/Mail'; import NotificationsIcon from '@material-ui/icons/Notifications'; import MoreIcon from '@material-ui/icons/MoreVert'; -const useStyles = makeStyles((theme) => ({ - grow: { - flexGrow: 1, +const Search = styled('div')(({ theme }) => ({ + position: 'relative', + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.white, 0.15), + '&:hover': { + backgroundColor: alpha(theme.palette.common.white, 0.25), }, - menuButton: { - marginRight: theme.spacing(2), + marginRight: theme.spacing(2), + marginLeft: 0, + width: '100%', + [theme.breakpoints.up('sm')]: { + marginLeft: theme.spacing(3), + width: 'auto', }, - title: { - display: 'none', - [theme.breakpoints.up('sm')]: { - display: 'block', - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - backgroundColor: alpha(theme.palette.common.white, 0.15), - '&:hover': { - backgroundColor: alpha(theme.palette.common.white, 0.25), - }, - marginRight: theme.spacing(2), - marginLeft: 0, - width: '100%', - [theme.breakpoints.up('sm')]: { - marginLeft: theme.spacing(3), - width: 'auto', - }, - }, - searchIcon: { - padding: theme.spacing(0, 2), - height: '100%', - position: 'absolute', - pointerEvents: 'none', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - }, - inputRoot: { - color: 'inherit', - }, - inputInput: { +})); + +const SearchIconWrapper = styled('div')(({ theme }) => ({ + padding: theme.spacing(0, 2), + height: '100%', + position: 'absolute', + pointerEvents: 'none', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', +})); + +const StyledInputBase = styled(InputBase)(({ theme }) => ({ + color: 'inherit', + '& .MuiInputBase-input': { padding: theme.spacing(1, 1, 1, 0), // vertical padding + font size from searchIcon paddingLeft: `calc(1em + ${theme.spacing(4)})`, @@ -65,22 +54,9 @@ const useStyles = makeStyles((theme) => ({ width: '20ch', }, }, - sectionDesktop: { - display: 'none', - [theme.breakpoints.up('md')]: { - display: 'flex', - }, - }, - sectionMobile: { - display: 'flex', - [theme.breakpoints.up('md')]: { - display: 'none', - }, - }, })); export default function PrimarySearchAppBar() { - const classes = useStyles(); const [anchorEl, setAnchorEl] = React.useState(null); const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = React.useState(null); @@ -174,35 +150,36 @@ export default function PrimarySearchAppBar() { ); return ( -
+ - + Material-UI -
-
+ + -
- + -
-
-
+ + + @@ -223,8 +200,8 @@ export default function PrimarySearchAppBar() { > -
-
+ + -
+ {renderMobileMenu} {renderMenu} -
+
); } diff --git a/docs/src/pages/components/app-bar/PrimarySearchAppBar.tsx b/docs/src/pages/components/app-bar/PrimarySearchAppBar.tsx index 7f362d76db91a4..4417a9f0a10c9b 100644 --- a/docs/src/pages/components/app-bar/PrimarySearchAppBar.tsx +++ b/docs/src/pages/components/app-bar/PrimarySearchAppBar.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; -import { alpha, makeStyles, Theme, createStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled, alpha } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; @@ -15,74 +16,47 @@ import MailIcon from '@material-ui/icons/Mail'; import NotificationsIcon from '@material-ui/icons/Notifications'; import MoreIcon from '@material-ui/icons/MoreVert'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - grow: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - display: 'none', - [theme.breakpoints.up('sm')]: { - display: 'block', - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - backgroundColor: alpha(theme.palette.common.white, 0.15), - '&:hover': { - backgroundColor: alpha(theme.palette.common.white, 0.25), - }, - marginRight: theme.spacing(2), - marginLeft: 0, - width: '100%', - [theme.breakpoints.up('sm')]: { - marginLeft: theme.spacing(3), - width: 'auto', - }, - }, - searchIcon: { - padding: theme.spacing(0, 2), - height: '100%', - position: 'absolute', - pointerEvents: 'none', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - }, - inputRoot: { - color: 'inherit', - }, - inputInput: { - padding: theme.spacing(1, 1, 1, 0), - // vertical padding + font size from searchIcon - paddingLeft: `calc(1em + ${theme.spacing(4)})`, - transition: theme.transitions.create('width'), - width: '100%', - [theme.breakpoints.up('md')]: { - width: '20ch', - }, - }, - sectionDesktop: { - display: 'none', - [theme.breakpoints.up('md')]: { - display: 'flex', - }, - }, - sectionMobile: { - display: 'flex', - [theme.breakpoints.up('md')]: { - display: 'none', - }, +const Search = styled('div')(({ theme }) => ({ + position: 'relative', + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.white, 0.15), + '&:hover': { + backgroundColor: alpha(theme.palette.common.white, 0.25), + }, + marginRight: theme.spacing(2), + marginLeft: 0, + width: '100%', + [theme.breakpoints.up('sm')]: { + marginLeft: theme.spacing(3), + width: 'auto', + }, +})); + +const SearchIconWrapper = styled('div')(({ theme }) => ({ + padding: theme.spacing(0, 2), + height: '100%', + position: 'absolute', + pointerEvents: 'none', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', +})); + +const StyledInputBase = styled(InputBase)(({ theme }) => ({ + color: 'inherit', + '& .MuiInputBase-input': { + padding: theme.spacing(1, 1, 1, 0), + // vertical padding + font size from searchIcon + paddingLeft: `calc(1em + ${theme.spacing(4)})`, + transition: theme.transitions.create('width'), + width: '100%', + [theme.breakpoints.up('md')]: { + width: '20ch', }, - }), -); + }, +})); export default function PrimarySearchAppBar() { - const classes = useStyles(); const [anchorEl, setAnchorEl] = React.useState(null); const [ mobileMoreAnchorEl, @@ -179,35 +153,36 @@ export default function PrimarySearchAppBar() { ); return ( -
+ - + Material-UI -
-
+ + -
- + -
-
-
+ + + @@ -228,8 +203,8 @@ export default function PrimarySearchAppBar() { > -
-
+ + -
+ {renderMobileMenu} {renderMenu} -
+
); } diff --git a/docs/src/pages/components/app-bar/ProminentAppBar.js b/docs/src/pages/components/app-bar/ProminentAppBar.js index 6d5fcaec24d48c..489af37c76b5c1 100644 --- a/docs/src/pages/components/app-bar/ProminentAppBar.js +++ b/docs/src/pages/components/app-bar/ProminentAppBar.js @@ -1,48 +1,43 @@ import * as React from 'react'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; -import { makeStyles } from '@material-ui/core/styles'; import MenuIcon from '@material-ui/icons/Menu'; import SearchIcon from '@material-ui/icons/Search'; import MoreIcon from '@material-ui/icons/MoreVert'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - toolbar: { +const StyledToolbar = styled(Toolbar)(({ theme }) => ({ + alignItems: 'flex-start', + paddingTop: theme.spacing(1), + paddingBottom: theme.spacing(2), + // Override media queries injected by theme.mixins.toolbar + '@media all': { minHeight: 128, - alignItems: 'flex-start', - paddingTop: theme.spacing(1), - paddingBottom: theme.spacing(2), - }, - title: { - flexGrow: 1, - alignSelf: 'flex-end', }, })); export default function ProminentAppBar() { - const classes = useStyles(); - return ( -
+ - + - + Material-UI @@ -51,8 +46,8 @@ export default function ProminentAppBar() { - + -
+ ); } diff --git a/docs/src/pages/components/app-bar/ProminentAppBar.tsx b/docs/src/pages/components/app-bar/ProminentAppBar.tsx index 6d5fcaec24d48c..489af37c76b5c1 100644 --- a/docs/src/pages/components/app-bar/ProminentAppBar.tsx +++ b/docs/src/pages/components/app-bar/ProminentAppBar.tsx @@ -1,48 +1,43 @@ import * as React from 'react'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; -import { makeStyles } from '@material-ui/core/styles'; import MenuIcon from '@material-ui/icons/Menu'; import SearchIcon from '@material-ui/icons/Search'; import MoreIcon from '@material-ui/icons/MoreVert'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - toolbar: { +const StyledToolbar = styled(Toolbar)(({ theme }) => ({ + alignItems: 'flex-start', + paddingTop: theme.spacing(1), + paddingBottom: theme.spacing(2), + // Override media queries injected by theme.mixins.toolbar + '@media all': { minHeight: 128, - alignItems: 'flex-start', - paddingTop: theme.spacing(1), - paddingBottom: theme.spacing(2), - }, - title: { - flexGrow: 1, - alignSelf: 'flex-end', }, })); export default function ProminentAppBar() { - const classes = useStyles(); - return ( -
+ - + - + Material-UI @@ -51,8 +46,8 @@ export default function ProminentAppBar() { - + -
+ ); } diff --git a/docs/src/pages/components/app-bar/SearchAppBar.js b/docs/src/pages/components/app-bar/SearchAppBar.js index e9fd18424a82f2..f4c304e76a0005 100644 --- a/docs/src/pages/components/app-bar/SearchAppBar.js +++ b/docs/src/pages/components/app-bar/SearchAppBar.js @@ -1,54 +1,42 @@ import * as React from 'react'; +import { experimentalStyled as styled, alpha } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; import InputBase from '@material-ui/core/InputBase'; -import { alpha, makeStyles } from '@material-ui/core/styles'; import MenuIcon from '@material-ui/icons/Menu'; import SearchIcon from '@material-ui/icons/Search'; -const useStyles = makeStyles((theme) => ({ - root: { - flexGrow: 1, +const Search = styled('div')(({ theme }) => ({ + position: 'relative', + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.white, 0.15), + '&:hover': { + backgroundColor: alpha(theme.palette.common.white, 0.25), }, - menuButton: { - marginRight: theme.spacing(2), + marginLeft: 0, + width: '100%', + [theme.breakpoints.up('sm')]: { + marginLeft: theme.spacing(1), + width: 'auto', }, - title: { - flexGrow: 1, - display: 'none', - [theme.breakpoints.up('sm')]: { - display: 'block', - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - backgroundColor: alpha(theme.palette.common.white, 0.15), - '&:hover': { - backgroundColor: alpha(theme.palette.common.white, 0.25), - }, - marginLeft: 0, - width: '100%', - [theme.breakpoints.up('sm')]: { - marginLeft: theme.spacing(1), - width: 'auto', - }, - }, - searchIcon: { - padding: theme.spacing(0, 2), - height: '100%', - position: 'absolute', - pointerEvents: 'none', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - }, - inputRoot: { - color: 'inherit', - }, - inputInput: { +})); + +const SearchIconWrapper = styled('div')(({ theme }) => ({ + padding: theme.spacing(0, 2), + height: '100%', + position: 'absolute', + pointerEvents: 'none', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', +})); + +const StyledInputBase = styled(InputBase)(({ theme }) => ({ + color: 'inherit', + '& .MuiInputBase-input': { padding: theme.spacing(1, 1, 1, 0), // vertical padding + font size from searchIcon paddingLeft: `calc(1em + ${theme.spacing(4)})`, @@ -64,38 +52,37 @@ const useStyles = makeStyles((theme) => ({ })); export default function SearchAppBar() { - const classes = useStyles(); - return ( -
+ - + Material-UI -
-
+ + -
- + -
+
-
+ ); } diff --git a/docs/src/pages/components/app-bar/SearchAppBar.tsx b/docs/src/pages/components/app-bar/SearchAppBar.tsx index e428456e66c63d..f4c304e76a0005 100644 --- a/docs/src/pages/components/app-bar/SearchAppBar.tsx +++ b/docs/src/pages/components/app-bar/SearchAppBar.tsx @@ -1,103 +1,88 @@ import * as React from 'react'; +import { experimentalStyled as styled, alpha } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; +import Box from '@material-ui/core/Box'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; import InputBase from '@material-ui/core/InputBase'; -import { createStyles, alpha, Theme, makeStyles } from '@material-ui/core/styles'; import MenuIcon from '@material-ui/icons/Menu'; import SearchIcon from '@material-ui/icons/Search'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - flexGrow: 1, - }, - menuButton: { - marginRight: theme.spacing(2), - }, - title: { - flexGrow: 1, - display: 'none', - [theme.breakpoints.up('sm')]: { - display: 'block', - }, - }, - search: { - position: 'relative', - borderRadius: theme.shape.borderRadius, - backgroundColor: alpha(theme.palette.common.white, 0.15), - '&:hover': { - backgroundColor: alpha(theme.palette.common.white, 0.25), - }, - marginLeft: 0, - width: '100%', - [theme.breakpoints.up('sm')]: { - marginLeft: theme.spacing(1), - width: 'auto', - }, - }, - searchIcon: { - padding: theme.spacing(0, 2), - height: '100%', - position: 'absolute', - pointerEvents: 'none', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - }, - inputRoot: { - color: 'inherit', - }, - inputInput: { - padding: theme.spacing(1, 1, 1, 0), - // vertical padding + font size from searchIcon - paddingLeft: `calc(1em + ${theme.spacing(4)})`, - transition: theme.transitions.create('width'), - width: '100%', - [theme.breakpoints.up('sm')]: { - width: '12ch', - '&:focus': { - width: '20ch', - }, +const Search = styled('div')(({ theme }) => ({ + position: 'relative', + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.white, 0.15), + '&:hover': { + backgroundColor: alpha(theme.palette.common.white, 0.25), + }, + marginLeft: 0, + width: '100%', + [theme.breakpoints.up('sm')]: { + marginLeft: theme.spacing(1), + width: 'auto', + }, +})); + +const SearchIconWrapper = styled('div')(({ theme }) => ({ + padding: theme.spacing(0, 2), + height: '100%', + position: 'absolute', + pointerEvents: 'none', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', +})); + +const StyledInputBase = styled(InputBase)(({ theme }) => ({ + color: 'inherit', + '& .MuiInputBase-input': { + padding: theme.spacing(1, 1, 1, 0), + // vertical padding + font size from searchIcon + paddingLeft: `calc(1em + ${theme.spacing(4)})`, + transition: theme.transitions.create('width'), + width: '100%', + [theme.breakpoints.up('sm')]: { + width: '12ch', + '&:focus': { + width: '20ch', }, }, - }), -); + }, +})); export default function SearchAppBar() { - const classes = useStyles(); - return ( -
+ - + Material-UI -
-
+ + -
- + -
+
-
+ ); } diff --git a/docs/src/pages/components/app-bar/app-bar.md b/docs/src/pages/components/app-bar/app-bar.md index d2eaf621aeffa3..aeea6ef0bbb4d3 100644 --- a/docs/src/pages/components/app-bar/app-bar.md +++ b/docs/src/pages/components/app-bar/app-bar.md @@ -72,18 +72,15 @@ function App() { 3. You can use `theme.mixins.toolbar` CSS: ```jsx -const useStyles = makeStyles((theme) => ({ - offset: theme.mixins.toolbar, -})); +const Offset = styled('div')(({ theme }) => theme.mixins.toolbar); function App() { - const classes = useStyles(); return ( {/* content */} -
+ ); } From 4f944863888c22ebaed5519a94f1f1a7e8ca3cfa Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Sat, 13 Mar 2021 20:26:51 -0300 Subject: [PATCH 2/2] Fix FAB position --- docs/src/pages/components/app-bar/BackToTop.js | 2 +- docs/src/pages/components/app-bar/BackToTop.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/pages/components/app-bar/BackToTop.js b/docs/src/pages/components/app-bar/BackToTop.js index dba57aa2e93390..36ecc51b3b2a3f 100644 --- a/docs/src/pages/components/app-bar/BackToTop.js +++ b/docs/src/pages/components/app-bar/BackToTop.js @@ -40,7 +40,7 @@ function ScrollTop(props) { {children} diff --git a/docs/src/pages/components/app-bar/BackToTop.tsx b/docs/src/pages/components/app-bar/BackToTop.tsx index 91d4ef78bb1b54..409f89fb9ef8e0 100644 --- a/docs/src/pages/components/app-bar/BackToTop.tsx +++ b/docs/src/pages/components/app-bar/BackToTop.tsx @@ -48,7 +48,7 @@ function ScrollTop(props: Props) { {children}