Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[styles] Replace classnames with clsx #14152

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ module.exports = [
name: 'The initial cost paid for using one component',
webpack: true,
path: 'packages/material-ui/build/Paper/index.js',
limit: '18.8 KB',
limit: '18.7 KB',
},
{
name: 'The initial cost paid for using one component with ES modules',
webpack: true,
path: 'packages/material-ui/build/esm/Paper/index.js',
limit: '17.9 KB',
limit: '17.8 KB',
},
{
name: 'The size of the @material-ui/core modules',
webpack: true,
path: 'packages/material-ui/build/index.js',
limit: '92.2 KB',
limit: '92.3 KB',
},
{
name: 'The size of the @material-ui/styles modules',
Expand All @@ -53,14 +53,14 @@ module.exports = [
name: 'The size of the @material-ui/core/Button component',
webpack: true,
path: 'packages/material-ui/build/esm/Button/index.js',
limit: '24.6 KB',
limit: '24.5 KB',
},
{
// vs https://bundlephobia.com/result?p=react-modal
name: 'The size of the @material-ui/core/Modal component',
webpack: true,
path: 'packages/material-ui/build/esm/Modal/index.js',
limit: '24.1 KB',
limit: '24.0 KB',
},
{
// vs https://bundlephobia.com/result?p=react-popper
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppContent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';

const styles = theme => ({
Expand All @@ -27,7 +27,7 @@ const styles = theme => ({
function AppContent(props) {
const { className, classes, children } = props;

return <main className={classNames(classes.root, className)}>{children}</main>;
return <main className={clsx(classes.root, className)}>{children}</main>;
}

AppContent.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppDrawer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import classNames from 'classnames';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { _rewriteUrlForNextExport } from 'next/router';
import { withStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -130,7 +130,7 @@ function AppDrawer(props) {
<Hidden lgUp={!disablePermanent} implementation="js">
<SwipeableDrawer
classes={{
paper: classNames(classes.paper, 'algolia-drawer'),
paper: clsx(classes.paper, 'algolia-drawer'),
}}
disableBackdropTransition={!iOS}
variant="temporary"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppDrawerNavItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import ListItem from '@material-ui/core/ListItem';
import Button from '@material-ui/core/Button';
Expand Down Expand Up @@ -85,7 +85,7 @@ class AppDrawerNavItem extends React.Component {
component={props => (
<Link naked activeClassName={classes.active} href={href} {...props} />
)}
className={classNames(classes.buttonLeaf, `depth-${depth}`)}
className={clsx(classes.buttonLeaf, `depth-${depth}`)}
disableRipple
onClick={onClick}
style={style}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Link from 'docs/src/modules/components/Link';
Expand All @@ -26,7 +26,7 @@ function AppTheme(props) {
<Typography
color="textSecondary"
align="center"
className={classNames(classes.credit, {
className={clsx(classes.credit, {
[classes.hideCredit]: hideCredit,
})}
>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import LZString from 'lz-string';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import copy from 'clipboard-copy';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -321,7 +321,7 @@ class Demo extends React.Component {
</div>
)}
<div
className={classNames(classes.demo, {
className={clsx(classes.demo, {
[classes.demoHiddenHeader]: demoOptions.hideHeader,
})}
>
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/components/HomeSteps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import compose from 'recompose/compose';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -86,7 +86,7 @@ function HomeSteps(props) {

return (
<Grid container>
<Grid item xs={12} md={4} className={classNames(classes.step, classes.leftStep)}>
<Grid item xs={12} md={4} className={clsx(classes.step, classes.leftStep)}>
<div className={classes.stepTitle}>
<FileDownloadIcon className={classes.stepIcon} />
<Typography variant="h6">{t('installation')}</Typography>
Expand Down Expand Up @@ -169,7 +169,7 @@ function HomeSteps(props) {
{t('usageButton')}
</Button>
</Grid>
<Grid item xs={12} md={4} className={classNames(classes.step, classes.rightStep)}>
<Grid item xs={12} md={4} className={clsx(classes.step, classes.rightStep)}>
<div className={classes.stepTitle}>
<WhatshotIcon className={classes.stepIcon} />
<Typography variant="h6">{t('themes')}</Typography>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withRouter } from 'next/router';
import NextLink from 'next/link';
import MuiLink from '@material-ui/core/Link';
Expand All @@ -16,7 +16,7 @@ function NextWrapper(props) {
<NextLink href={href} prefetch={prefetch}>
<a
onClick={onClick}
className={classNames(className, {
className={clsx(className, {
[activeClassName]: router.pathname === href && activeClassName,
})}
{...other}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/Tidelift.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Link from 'docs/src/modules/components/Link';
Expand Down Expand Up @@ -43,7 +43,7 @@ function Tidelift(props) {
data-ga-event-category="sponsors"
data-ga-event-action="logo"
data-ga-event-label="tidelift"
className={classNames(classes.root, 'mui-fixed')}
className={clsx(classes.root, 'mui-fixed')}
href="https://tidelift.com/subscription/pkg/npm-material-ui?utm_source=material_ui&utm_medium=referral&utm_campaign=homepage"
target="_blank"
rel="noopener"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/css-in-js/CssInJs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';

Expand All @@ -23,7 +23,7 @@ function MyLink(props) {

return (
<a
className={classNames(
className={clsx(
classes.root,
{
[classes.primary]: variant === 'primary',
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/css-in-js/StyledComponents.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import classNames from 'classnames';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
Expand All @@ -10,7 +10,7 @@ function styled(Component) {
return (style, options) => {
function StyledComponent(props) {
const { classes, className, ...other } = props;
return <Component className={classNames(classes.root, className)} {...other} />;
return <Component className={clsx(classes.root, className)} {...other} />;
}
StyledComponent.propTypes = {
classes: PropTypes.object.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/overrides/ClassNames.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';

Expand All @@ -21,7 +21,7 @@ function ClassNames(props) {
const { classes, children, className, ...other } = props;

return (
<Button className={classNames(classes.root, className)} {...other}>
<Button className={clsx(classes.root, className)} {...other}>
{children || 'class names'}
</Button>
);
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/overrides/DynamicClassName.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import FormControlLabel from '@material-ui/core/FormControlLabel';
Expand Down Expand Up @@ -47,7 +47,7 @@ class DynamicClassName extends React.Component {
label="Blue"
/>
<Button
className={classNames(classes.button, {
className={clsx(classes.button, {
[classes.buttonBlue]: this.state.color === 'blue',
})}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types, react/jsx-handler-names */

import React from 'react';
import classNames from 'classnames';
import clsx from 'clsx';
import Select from 'react-select';
import { makeStyles, useTheme } from '@material-ui/styles';
import Typography from '@material-ui/core/Typography';
Expand Down Expand Up @@ -180,7 +180,7 @@ function MultiValue(props) {
<Chip
tabIndex={-1}
label={props.children}
className={classNames(props.selectProps.classes.chip, {
className={clsx(props.selectProps.classes.chip, {
[props.selectProps.classes.chipFocused]: props.isFocused,
})}
onDelete={props.removeProps.onClick}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/autocomplete/IntegrationReactSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import Select from 'react-select';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
Expand Down Expand Up @@ -181,7 +181,7 @@ function MultiValue(props) {
<Chip
tabIndex={-1}
label={props.children}
className={classNames(props.selectProps.classes.chip, {
className={clsx(props.selectProps.classes.chip, {
[props.selectProps.classes.chipFocused]: props.isFocused,
})}
onDelete={props.removeProps.onClick}
Expand Down
10 changes: 3 additions & 7 deletions docs/src/pages/demos/buttons/CustomizedButtons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import { withStyles, MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import purple from '@material-ui/core/colors/purple';
Expand Down Expand Up @@ -67,11 +67,7 @@ function CustomizedButtons(props) {

return (
<div>
<Button
variant="contained"
color="primary"
className={classNames(classes.margin, classes.cssRoot)}
>
<Button variant="contained" color="primary" className={clsx(classes.margin, classes.cssRoot)}>
Custom CSS
</Button>
<MuiThemeProvider theme={theme}>
Expand All @@ -83,7 +79,7 @@ function CustomizedButtons(props) {
variant="contained"
color="primary"
disableRipple
className={classNames(classes.margin, classes.bootstrapRoot)}
className={clsx(classes.margin, classes.bootstrapRoot)}
>
Bootstrap
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import SwipeableViews from 'react-swipeable-views';
import { makeStyles, useTheme } from '@material-ui/styles';
import AppBar from '@material-ui/core/AppBar';
Expand Down Expand Up @@ -81,7 +81,7 @@ function FloatingActionButtonZoom() {
},
{
color: 'inherit',
className: classNames(classes.fab, classes.fabGreen),
className: clsx(classes.fab, classes.fabGreen),
icon: <UpIcon />,
},
];
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/buttons/FloatingActionButtonZoom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import SwipeableViews from 'react-swipeable-views';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
Expand Down Expand Up @@ -83,7 +83,7 @@ class FloatingActionButtonZoom extends React.Component {
},
{
color: 'inherit',
className: classNames(classes.fab, classes.fabGreen),
className: clsx(classes.fab, classes.fabGreen),
icon: <UpIcon />,
},
];
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/buttons/IconLabelButtons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import clsx from 'clsx';
import Button from '@material-ui/core/Button';
import { withStyles } from '@material-ui/core/styles';
import DeleteIcon from '@material-ui/icons/Delete';
Expand Down Expand Up @@ -46,7 +46,7 @@ function IconLabelButtons(props) {
Talk
</Button>
<Button variant="contained" size="small" className={classes.button}>
<SaveIcon className={classNames(classes.leftIcon, classes.iconSmall)} />
<SaveIcon className={clsx(classes.leftIcon, classes.iconSmall)} />
Save
</Button>
</div>
Expand Down
Loading