Skip to content

Commit

Permalink
Merge pull request #3946 from DanudeSandstorm/makestyles-options
Browse files Browse the repository at this point in the history
Add name option to makeStyles
  • Loading branch information
fzaninotto authored Nov 26, 2019
2 parents 6f9fd6a + 4979a0b commit 5c38c08
Show file tree
Hide file tree
Showing 68 changed files with 1,103 additions and 894 deletions.
2 changes: 1 addition & 1 deletion packages/ra-input-rich-text/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { makeStyles } from '@material-ui/core/styles';

import styles from './styles';

const useStyles = makeStyles(styles);
const useStyles = makeStyles(styles, { name: 'RaRichTextInput' });

const RichTextInput = ({
options = {}, // Quill editor options
Expand Down
15 changes: 9 additions & 6 deletions packages/ra-ui-materialui/src/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import classNames from 'classnames';
import { Link as RRLink } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
link: {
textDecoration: 'none',
color: theme.palette.primary.main,
},
}));
const useStyles = makeStyles(
theme => ({
link: {
textDecoration: 'none',
color: theme.palette.primary.main,
},
}),
{ name: 'RaLink' }
);

const Link = ({
to,
Expand Down
51 changes: 27 additions & 24 deletions packages/ra-ui-materialui/src/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,33 @@ interface Props {
theme: object;
}

const useStyles = makeStyles((theme: Theme) => ({
main: {
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
height: '1px',
alignItems: 'center',
justifyContent: 'flex-start',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
},
card: {
minWidth: 300,
marginTop: '6em',
},
avatar: {
margin: '1em',
display: 'flex',
justifyContent: 'center',
},
icon: {
backgroundColor: theme.palette.secondary[500],
},
}));
const useStyles = makeStyles(
(theme: Theme) => ({
main: {
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
height: '1px',
alignItems: 'center',
justifyContent: 'flex-start',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
},
card: {
minWidth: 300,
marginTop: '6em',
},
avatar: {
margin: '1em',
display: 'flex',
justifyContent: 'center',
},
icon: {
backgroundColor: theme.palette.secondary[500],
},
}),
{ name: 'RaLogin' }
);

/**
* A standalone login page, to serve as authentication gate to the admin
Expand Down
31 changes: 17 additions & 14 deletions packages/ra-ui-materialui/src/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ interface FormData {
password: string;
}

const useStyles = makeStyles((theme: Theme) => ({
form: {
padding: '0 1em 1em 1em',
},
input: {
marginTop: '1em',
},
button: {
width: '100%',
},
icon: {
marginRight: theme.spacing(1),
},
}));
const useStyles = makeStyles(
(theme: Theme) => ({
form: {
padding: '0 1em 1em 1em',
},
input: {
marginTop: '1em',
},
button: {
width: '100%',
},
icon: {
marginRight: theme.spacing(1),
},
}),
{ name: 'RaLoginForm' }
);

const Input = ({
meta: { touched, error }, // eslint-disable-line react/prop-types
Expand Down
15 changes: 9 additions & 6 deletions packages/ra-ui-materialui/src/auth/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ interface Props {
redirectTo?: string;
}

const useStyles = makeStyles((theme: Theme) => ({
menuItem: {
color: theme.palette.text.secondary,
},
icon: { minWidth: theme.spacing(5) },
}));
const useStyles = makeStyles(
(theme: Theme) => ({
menuItem: {
color: theme.palette.text.secondary,
},
icon: { minWidth: theme.spacing(5) },
}),
{ name: 'RaLogout' }
);

/**
* Logout button component, to be passed to the Admin component
Expand Down
23 changes: 13 additions & 10 deletions packages/ra-ui-materialui/src/button/BulkDeleteWithConfirmButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ const sanitizeRestProps = ({
...rest
}) => rest;

const useStyles = makeStyles(theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
const useStyles = makeStyles(
theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
},
},
}));
}),
{ name: 'RaBulkDeleteWithConfirmButton' }
);

const BulkDeleteWithConfirmButton = ({
basePath,
Expand Down
23 changes: 13 additions & 10 deletions packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ const sanitizeRestProps = ({
...rest
}) => rest;

const useStyles = makeStyles(theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
const useStyles = makeStyles(
theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
},
},
}));
}),
{ name: 'RaBulkDeleteWithUndoButton' }
);

const BulkDeleteWithUndoButton = ({
basePath,
Expand Down
43 changes: 23 additions & 20 deletions packages/ra-ui-materialui/src/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ import {
import classnames from 'classnames';
import { useTranslate } from 'ra-core';

const useStyles = makeStyles({
button: {
display: 'inline-flex',
alignItems: 'center',
const useStyles = makeStyles(
{
button: {
display: 'inline-flex',
alignItems: 'center',
},
label: {
paddingLeft: '0.5em',
},
labelRightIcon: {
paddingRight: '0.5em',
},
smallIcon: {
fontSize: 20,
},
mediumIcon: {
fontSize: 22,
},
largeIcon: {
fontSize: 24,
},
},
label: {
paddingLeft: '0.5em',
},
labelRightIcon: {
paddingRight: '0.5em',
},
smallIcon: {
fontSize: 20,
},
mediumIcon: {
fontSize: 22,
},
largeIcon: {
fontSize: 24,
},
});
{ name: 'RaButton' }
);

const Button = ({
alignIcon = 'left',
Expand Down
33 changes: 18 additions & 15 deletions packages/ra-ui-materialui/src/button/CreateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ import { useTranslate } from 'ra-core';

import Button from './Button';

const useStyles = makeStyles(theme => ({
floating: {
color: theme.palette.getContrastText(theme.palette.primary.main),
margin: 0,
top: 'auto',
right: 20,
bottom: 60,
left: 'auto',
position: 'fixed',
zIndex: 1000,
},
floatingLink: {
color: 'inherit',
},
}));
const useStyles = makeStyles(
theme => ({
floating: {
color: theme.palette.getContrastText(theme.palette.primary.main),
margin: 0,
top: 'auto',
right: 20,
bottom: 60,
left: 'auto',
position: 'fixed',
zIndex: 1000,
},
floatingLink: {
color: 'inherit',
},
}),
{ name: 'RaCreateButton' }
);

const CreateButton = ({
basePath = '',
Expand Down
23 changes: 13 additions & 10 deletions packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ const sanitizeRestProps = ({
...rest
}) => rest;

const useStyles = makeStyles(theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
const useStyles = makeStyles(
theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
},
},
}));
}),
{ name: 'RaDeleteWithConfirmButton' }
);

const DeleteWithConfirmButton = ({
basePath,
Expand Down
23 changes: 13 additions & 10 deletions packages/ra-ui-materialui/src/button/DeleteWithUndoButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ export const sanitizeRestProps = ({
...rest
}) => rest;

const useStyles = makeStyles(theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
const useStyles = makeStyles(
theme => ({
deleteButton: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
},
},
}));
}),
{ name: 'RaDeleteWithUndoButton' }
);

const DeleteWithUndoButton = ({
label = 'ra.action.delete',
Expand Down
25 changes: 14 additions & 11 deletions packages/ra-ui-materialui/src/button/SaveButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import ContentSave from '@material-ui/icons/Save';
import classnames from 'classnames';
import { useTranslate, useNotify } from 'ra-core';

const useStyles = makeStyles(theme => ({
button: {
position: 'relative',
},
leftIcon: {
marginRight: theme.spacing(1),
},
icon: {
fontSize: 18,
},
}));
const useStyles = makeStyles(
theme => ({
button: {
position: 'relative',
},
leftIcon: {
marginRight: theme.spacing(1),
},
icon: {
fontSize: 18,
},
}),
{ name: 'RaSaveButton' }
);

const sanitizeRestProps = ({
basePath,
Expand Down
Loading

0 comments on commit 5c38c08

Please sign in to comment.