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

Dependencies: Replace classnames with clsx - v2 #91408

Merged
merged 1 commit into from
Jun 3, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion apps/blaze-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@tanstack/react-query": "^5.15.5",
"@wordpress/data": "^10.0.0",
"calypso": "workspace:^",
"classnames": "^2.3.2",
"clsx": "^2.1.1",
"debug": "^4.3.4",
"moment": "^2.26.0",
"prop-types": "^15.8.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import classNames from 'classnames';
import clsx from 'clsx';

import './style.scss';

const JetpackBlazeHeader = ( { className = '' } ) => (
<header className={ classNames( 'jetpack-blaze-header', className ) }>
<header className={ clsx( 'jetpack-blaze-header', className ) }>
<svg width="175" height="32" viewBox="0 0 175 32" fill="none">
<g clipPath="url(#clip0_8399_69928)">
<path
Expand Down
4 changes: 2 additions & 2 deletions apps/blaze-dashboard/src/components/layout.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classnames from 'classnames';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';
Expand All @@ -22,7 +22,7 @@ class Layout extends Component {
};

render() {
const sectionClass = classnames( 'layout', `focus-${ this.props.currentLayoutFocus }`, {
const sectionClass = clsx( 'layout', `focus-${ this.props.currentLayoutFocus }`, {
[ 'is-group-' + this.props.sectionGroup ]: this.props.sectionGroup,
[ 'is-section-' + this.props.sectionName ]: this.props.sectionName,
'is-support-session': this.props.isSupportSession,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames';
import clsx from 'clsx';
import { useTranslate } from 'i18n-calypso';

import './style.scss';
Expand All @@ -7,7 +7,7 @@ const WooBlazeHeader = ( { className = '', children } ) => {
const translate = useTranslate();

return (
<header className={ classNames( 'woo-blaze-header', className ) }>
<header className={ clsx( 'woo-blaze-header', className ) }>
<h2>{ translate( 'Blaze for WooCommerce' ) }</h2>
{ children }
</header>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { ENTER } from '@wordpress/keycodes';
import classnames from 'classnames';
import clsx from 'clsx';
import NoSupport from './no-support';

export default ( { fontPairings, fontBase, fontHeadings, update } ) => {
Expand All @@ -15,7 +15,7 @@ export default ( { fontPairings, fontBase, fontHeadings, update } ) => {
const isSelected = headings === fontHeadings && base === fontBase;
return (
<Button
className={ classnames( 'style-preview__font-option', {
className={ clsx( 'style-preview__font-option', {
'is-selected': isSelected,
} ) }
onClick={ () => update( { headings, base } ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useMediaQuery } from '@wordpress/compose';
import { useDispatch, useSelect } from '@wordpress/data';
import { useCallback, useEffect, useState } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import cx from 'classnames';
import cx from 'clsx';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename to clsx for consistency?

import { useSelector } from 'react-redux';
import { getSectionName } from 'calypso/state/ui/selectors';
import { whatsNewQueryClient } from '../../common/what-new-query-client';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { positionLeft, positionRight } from '@wordpress/icons';
import classnames from 'classnames';
import clsx from 'clsx';
import { TimelineIcon } from './icon';

const DEFAULT_BACKGROUND = '#eeeeee';
Expand Down Expand Up @@ -66,7 +66,7 @@ export function registerTimelineItemBlock() {
setAttributes( { alignment: newAlignment } );
};

const classes = classnames( 'wp-block-jetpack-timeline-item', {
const classes = clsx( 'wp-block-jetpack-timeline-item', {
'is-left': attributes.alignment === 'left',
'is-right': attributes.alignment === 'right',
} );
Expand Down Expand Up @@ -103,7 +103,7 @@ export function registerTimelineItemBlock() {
);
},
save: ( { attributes } ) => {
const classes = classnames( {
const classes = clsx( {
'is-left': attributes.alignment === 'left',
'is-right': attributes.alignment === 'right',
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { registerBlockType, createBlock } from '@wordpress/blocks';
import { ToggleControl, PanelBody } from '@wordpress/components';
import { dispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import clsx from 'clsx';
import { BlockAppender } from './block-appender';
import { TimelineIcon } from './icon';

Expand Down Expand Up @@ -83,7 +83,7 @@ export function registerTimelineBlock() {

const toggleAlternate = () => setAttributes( { isAlternating: ! isAlternating } );

const classes = classnames( 'wp-block-jetpack-timeline', {
const classes = clsx( 'wp-block-jetpack-timeline', {
'is-alternating': isAlternating,
} );

Expand Down Expand Up @@ -112,7 +112,7 @@ export function registerTimelineBlock() {
save: ( props ) => {
const { attributes } = props;
const { isAlternating } = attributes;
const classes = classnames( 'wp-block-jetpack-timeline', {
const classes = clsx( 'wp-block-jetpack-timeline', {
'is-alternating': isAlternating,
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { forwardRef } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';
import { _x } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import classNames from 'classnames';
import clsx from 'clsx';
import { Post } from '../../types';

import './style.scss';
Expand All @@ -18,11 +18,11 @@ interface NavItemProps {

const NavItem = forwardRef< HTMLLIElement, NavItemProps >(
( { item, postType, selected, statusLabel }, ref ) => {
const buttonClasses = classNames( 'wpcom-block-editor-nav-item', {
const buttonClasses = clsx( 'wpcom-block-editor-nav-item', {
'is-selected': selected,
} );

const titleClasses = classNames( 'wpcom-block-editor-nav-item__title', {
const titleClasses = clsx( 'wpcom-block-editor-nav-item__title', {
'is-untitled': ! item.title?.raw,
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { __, isRTL } from '@wordpress/i18n';
import { chevronLeft, chevronRight } from '@wordpress/icons';
import { ESCAPE } from '@wordpress/keycodes';
import { addQueryArgs, getQueryArg } from '@wordpress/url';
import classNames from 'classnames';
import clsx from 'clsx';
import { get, isEmpty, partition } from 'lodash';
import * as React from 'react';
import { POST_IDS_TO_EXCLUDE } from '../../constants';
Expand Down Expand Up @@ -185,7 +185,7 @@ function WpcomBlockEditorNavSidebar() {

return (
<IsolatedEventContainer
className={ classNames( 'wpcom-block-editor-nav-sidebar-nav-sidebar__click-guard', {
className={ clsx( 'wpcom-block-editor-nav-sidebar-nav-sidebar__click-guard', {
'is-fading-out': isClosing,
} ) }
onAnimationEnd={ ( ev: React.AnimationEvent ) => {
Expand Down Expand Up @@ -213,7 +213,7 @@ function WpcomBlockEditorNavSidebar() {
// 'full-site-editing'
// )
// }
className={ classNames( 'wpcom-block-editor-nav-sidebar-nav-sidebar__container', {
className={ clsx( 'wpcom-block-editor-nav-sidebar-nav-sidebar__container', {
'is-sliding-left': isClosing,
} ) }
role="dialog"
Expand All @@ -224,7 +224,7 @@ function WpcomBlockEditorNavSidebar() {
label={ __( 'Close block editor sidebar', 'full-site-editing' ) }
showTooltip
ref={ dismissButtonMount }
className={ classNames(
className={ clsx(
'edit-post-fullscreen-mode-close',
'wpcom-block-editor-nav-sidebar-nav-sidebar__dismiss-sidebar-button',
'has-icon'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { recordTracksEvent } from '@automattic/calypso-analytics';
import { Button } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import clsx from 'clsx';
import { store } from '../../store';
import SiteIcon from '../site-icon';
import './style.scss';
Expand All @@ -20,7 +20,7 @@ export default function ToggleSidebarButton() {
<Button
label={ __( 'Block editor sidebar', 'full-site-editing' ) }
showTooltip
className={ classnames(
className={ clsx(
'edit-post-fullscreen-mode-close',
'wpcom-block-editor-nav-sidebar-toggle-sidebar-button__button',
'has-icon',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Modal } from '@wordpress/components';
import { useEffect, useRef } from '@wordpress/element';
import classnames from 'classnames';
import clsx from 'clsx';
import React from 'react';
import './style.scss';

Expand Down Expand Up @@ -41,7 +41,7 @@ const NuxModal: React.FC< Props > = ( {

return (
<Modal
className={ classnames( 'wpcom-block-editor-nux-modal', className ) }
className={ clsx( 'wpcom-block-editor-nux-modal', className ) }
title=""
onRequestClose={ onRequestClose }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect, useRef, useState } from '@wordpress/element';
import { Icon, globe, link as linkIcon } from '@wordpress/icons';
import { store as noticesStore } from '@wordpress/notices';
import { useI18n } from '@wordpress/react-i18n';
import classnames from 'classnames';
import clsx from 'clsx';
import React from 'react';
import ClipboardButton from 'calypso/components/forms/clipboard-button';
import FormInputCheckbox from 'calypso/components/forms/form-checkbox';
Expand Down Expand Up @@ -204,7 +204,7 @@ const SharingModalInner: React.FC = () => {
<hr />
<h2>{ __( 'Get more traffic to your post by sharing:', 'full-site-editing' ) }</h2>
<Button
className={ classnames(
className={ clsx(
'wpcom-block-editor-post-published-sharing-modal__sharing-button',
'share-facebook'
) }
Expand All @@ -213,7 +213,7 @@ const SharingModalInner: React.FC = () => {
<InlineSocialLogo icon="facebook" size={ 18 } />
</Button>
<Button
className={ classnames(
className={ clsx(
'wpcom-block-editor-post-published-sharing-modal__sharing-button',
'share-twitter'
) }
Expand All @@ -222,7 +222,7 @@ const SharingModalInner: React.FC = () => {
<InlineSocialLogo icon="twitter-alt" size={ 18 } />
</Button>
<Button
className={ classnames(
className={ clsx(
'wpcom-block-editor-post-published-sharing-modal__sharing-button',
'share-linkedin'
) }
Expand All @@ -231,7 +231,7 @@ const SharingModalInner: React.FC = () => {
<InlineSocialLogo icon="linkedin" size={ 18 } />
</Button>
<Button
className={ classnames(
className={ clsx(
'wpcom-block-editor-post-published-sharing-modal__sharing-button',
'share-tumblr'
) }
Expand All @@ -240,7 +240,7 @@ const SharingModalInner: React.FC = () => {
<InlineSocialLogo icon="tumblr-alt" size={ 18 } />
</Button>
<Button
className={ classnames(
className={ clsx(
'wpcom-block-editor-post-published-sharing-modal__sharing-button',
'share-pinterest'
) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classnames from 'classnames';
import clsx from 'clsx';
import * as React from 'react';
import { Assign } from 'utility-types';

Expand Down Expand Up @@ -28,7 +28,7 @@ function InlineSocialLogo( props: Assign< React.SVGProps< SVGSVGElement >, Props
// The current CSS expects individual icon classes in the form of e.g. `.twitter`, but the social-logos build
// appears to generate them in the form of `.social-logo-twitter` instead.
// We add both here, to ensure compatibility.
const iconClass = classnames( 'social-logo', iconName, icon, className );
const iconClass = clsx( 'social-logo', iconName, icon, className );

return (
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useState,
} from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import classnames from 'classnames';
import clsx from 'clsx';
import { useCanvas } from './use-canvas';
import { useGlobalStylesConfig } from './use-global-styles-config';
import { usePreview } from './use-preview';
Expand Down Expand Up @@ -148,7 +148,7 @@ function GlobalStylesEditNotice() {
onClick: upgradePlan,
variant: 'primary',
noDefaultClasses: true,
className: classnames(
className: clsx(
'wpcom-global-styles-action-is-upgrade',
'wpcom-global-styles-action-has-icon',
'wpcom-global-styles-action-is-external'
Expand Down
2 changes: 1 addition & 1 deletion apps/editing-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@wordpress/server-side-render": "^5.0.0",
"@wordpress/url": "^4.0.0",
"calypso": "workspace:^",
"classnames": "^2.3.2",
"clsx": "^2.1.1",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import classNames from 'classnames';
import clsx from 'clsx';
import { FunctionComponent } from 'react';
import usePlanOptions from '../hooks/plan-options';
import { BlockPlan } from '../hooks/pricing-plans';
Expand Down Expand Up @@ -98,7 +98,7 @@ const BlockSettings: FunctionComponent<
<PanelRow>
{ planOptions.map( ( option ) => (
<CheckboxControl
className={ classNames( {
className={ clsx( {
'hb-pricing-plans-embed__settings-checkbox--disabled': isDisabled( option.value ),
} ) }
key={ option.value }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classnames from 'classnames';
import clsx from 'clsx';
import { FunctionComponent } from 'react';
import usePlanOptions from '../hooks/plan-options';
import { BlockPlan } from '../hooks/pricing-plans';
Expand Down Expand Up @@ -35,7 +35,7 @@ const PricingPlansTabs: FunctionComponent< Props > = ( {
{ availablePlanOptions.map( ( planOption ) => (
<button
onClick={ () => onTabButtonClick( planOption.value ) }
className={ classnames( 'hb-pricing-plans-embed__tabs-label', {
className={ clsx( 'hb-pricing-plans-embed__tabs-label', {
'hb-pricing-plans-embed__tabs-label--active': planOption.value === currentPlan.type,
} ) }
key={ planOption.value }
Expand Down
2 changes: 1 addition & 1 deletion apps/happy-blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@wordpress/data": "^10.0.0",
"@wordpress/element": "^6.0.0",
"@wordpress/i18n": "^5.0.0",
"classnames": "^2.3.2",
"clsx": "^2.1.1",
"glob": "^7.1.6",
"i18n-calypso": "workspace:^",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@automattic/webpack-extensive-lodash-replacement-plugin": "workspace:^",
"autoprefixer": "^10.2.5",
"calypso": "workspace:^",
"classnames": "^2.3.2",
"clsx": "^2.1.1",
"debug": "^4.3.3",
"i18n-calypso": "workspace:^",
"prop-types": "^15.7.2",
Expand Down
4 changes: 2 additions & 2 deletions apps/notifications/src/panel/templates/action-button.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import classNames from 'classnames';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import HotkeyContainer from './container-hotkey';
import Gridicon from './gridicons';

const ActionButton = ( { isActive, hotkey, icon, onToggle, text, title } ) => (
<HotkeyContainer shortcuts={ hotkey ? [ { hotkey, action: onToggle } ] : null }>
<button
className={ classNames( 'wpnc__action-link', {
className={ clsx( 'wpnc__action-link', {
'active-action': isActive,
'inactive-action': ! isActive,
} ) }
Expand Down
Loading
Loading