From 6533e451cbe55568b93552ae6908875263843e71 Mon Sep 17 00:00:00 2001 From: Victor Casas Date: Thu, 25 Mar 2021 19:48:11 -0300 Subject: [PATCH 1/3] docs: Migrate click away demo to emotion --- .../click-away-listener/ClickAway.js | 38 ++++++++--------- .../click-away-listener/ClickAway.tsx | 41 ++++++++----------- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/docs/src/pages/components/click-away-listener/ClickAway.js b/docs/src/pages/components/click-away-listener/ClickAway.js index a7187f53710170..718cff0677a111 100644 --- a/docs/src/pages/components/click-away-listener/ClickAway.js +++ b/docs/src/pages/components/click-away-listener/ClickAway.js @@ -1,25 +1,8 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; -const useStyles = makeStyles((theme) => ({ - root: { - position: 'relative', - }, - dropdown: { - position: 'absolute', - top: 28, - right: 0, - left: 0, - zIndex: 1, - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, -})); - export default function ClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -30,18 +13,29 @@ export default function ClickAway() { setOpen(false); }; + const styles = { + position: 'absolute', + top: 28, + right: 0, + left: 0, + zIndex: 1, + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return ( -
+ {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null} -
+
); } diff --git a/docs/src/pages/components/click-away-listener/ClickAway.tsx b/docs/src/pages/components/click-away-listener/ClickAway.tsx index ba9f78f6cbad76..1eb06c210c8bc8 100644 --- a/docs/src/pages/components/click-away-listener/ClickAway.tsx +++ b/docs/src/pages/components/click-away-listener/ClickAway.tsx @@ -1,27 +1,9 @@ import * as React from 'react'; -import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; - -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - position: 'relative', - }, - dropdown: { - position: 'absolute', - top: 28, - right: 0, - left: 0, - zIndex: 1, - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, - }), -); +import { SxProps } from '@material-ui/system'; export default function ClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -32,18 +14,29 @@ export default function ClickAway() { setOpen(false); }; + const styles: SxProps = { + position: 'absolute', + top: 28, + right: 0, + left: 0, + zIndex: 1, + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return ( -
+ {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null} -
+
); } From 1d7ec9ed7f407dbb59db873956e63657f4c8ed71 Mon Sep 17 00:00:00 2001 From: Victor Casas Date: Thu, 25 Mar 2021 19:48:24 -0300 Subject: [PATCH 2/3] docs: Migrate leading click away demo to emotion --- .../click-away-listener/LeadingClickAway.js | 38 ++++++++--------- .../click-away-listener/LeadingClickAway.tsx | 41 ++++++++----------- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/docs/src/pages/components/click-away-listener/LeadingClickAway.js b/docs/src/pages/components/click-away-listener/LeadingClickAway.js index 5f98d00c2a0927..183e0ee39d30f3 100644 --- a/docs/src/pages/components/click-away-listener/LeadingClickAway.js +++ b/docs/src/pages/components/click-away-listener/LeadingClickAway.js @@ -1,25 +1,8 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; -const useStyles = makeStyles((theme) => ({ - root: { - position: 'relative', - }, - dropdown: { - position: 'absolute', - top: 28, - right: 0, - left: 0, - zIndex: 1, - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, -})); - export default function LeadingClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -30,22 +13,33 @@ export default function LeadingClickAway() { setOpen(false); }; + const styles = { + position: 'absolute', + top: 28, + right: 0, + left: 0, + zIndex: 1, + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return ( -
+ {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null} -
+
); } diff --git a/docs/src/pages/components/click-away-listener/LeadingClickAway.tsx b/docs/src/pages/components/click-away-listener/LeadingClickAway.tsx index b2957eb82722c3..be8cd9e0e6ae65 100644 --- a/docs/src/pages/components/click-away-listener/LeadingClickAway.tsx +++ b/docs/src/pages/components/click-away-listener/LeadingClickAway.tsx @@ -1,27 +1,9 @@ import * as React from 'react'; -import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; - -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - position: 'relative', - }, - dropdown: { - position: 'absolute', - top: 28, - right: 0, - left: 0, - zIndex: 1, - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, - }), -); +import { SxProps } from '@material-ui/system'; export default function LeadingClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -32,22 +14,33 @@ export default function LeadingClickAway() { setOpen(false); }; + const styles: SxProps = { + position: 'absolute', + top: 28, + right: 0, + left: 0, + zIndex: 1, + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return ( -
+ {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null} -
+
); } From b0805e3967fcbf7e7dcba0ff130e434153c41c8a Mon Sep 17 00:00:00 2001 From: Victor Casas Date: Thu, 25 Mar 2021 19:48:35 -0300 Subject: [PATCH 3/3] docs: Migrate portal click away demo to emotion --- .../click-away-listener/PortalClickAway.js | 31 ++++++++--------- .../click-away-listener/PortalClickAway.tsx | 34 ++++++++----------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/docs/src/pages/components/click-away-listener/PortalClickAway.js b/docs/src/pages/components/click-away-listener/PortalClickAway.js index f59624314d3d7a..2f4a56c7738777 100644 --- a/docs/src/pages/components/click-away-listener/PortalClickAway.js +++ b/docs/src/pages/components/click-away-listener/PortalClickAway.js @@ -1,23 +1,9 @@ import * as React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import Portal from '@material-ui/core/Portal'; -const useStyles = makeStyles((theme) => ({ - dropdown: { - position: 'fixed', - width: 200, - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, -})); - export default function PortalClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -28,6 +14,17 @@ export default function PortalClickAway() { setOpen(false); }; + const styles = { + position: 'fixed', + width: 200, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return (
@@ -36,9 +33,9 @@ export default function PortalClickAway() { {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null}
diff --git a/docs/src/pages/components/click-away-listener/PortalClickAway.tsx b/docs/src/pages/components/click-away-listener/PortalClickAway.tsx index 35d4eddb44ef0a..cda151c25961e5 100644 --- a/docs/src/pages/components/click-away-listener/PortalClickAway.tsx +++ b/docs/src/pages/components/click-away-listener/PortalClickAway.tsx @@ -1,25 +1,10 @@ import * as React from 'react'; -import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; +import Box from '@material-ui/core/Box'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import Portal from '@material-ui/core/Portal'; - -const useStyles = makeStyles((theme: Theme) => - createStyles({ - dropdown: { - position: 'fixed', - width: 200, - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - border: '1px solid', - padding: theme.spacing(1), - backgroundColor: theme.palette.background.paper, - }, - }), -); +import { SxProps } from '@material-ui/system'; export default function PortalClickAway() { - const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleClick = () => { @@ -30,6 +15,17 @@ export default function PortalClickAway() { setOpen(false); }; + const styles: SxProps = { + position: 'fixed', + width: 200, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + border: '1px solid', + p: 1, + bgcolor: 'background.paper', + }; + return (
@@ -38,9 +34,9 @@ export default function PortalClickAway() { {open ? ( -
+ Click me, I will stay visible until you click outside. -
+
) : null}