Skip to content

Commit f90594a

Browse files
billy-lekylemh
andauthored
replace refs to twMerge and classnames. remove classnames pkg (#1894)
Co-authored-by: Kyle Holmberg <kylemh.email@gmail.com>
1 parent 6572183 commit f90594a

35 files changed

Lines changed: 107 additions & 117 deletions

File tree

.eslintrc.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,18 @@ module.exports = {
151151
importNames: ['default'],
152152
message: 'React is globally availble for all page files.',
153153
},
154-
/* {
155-
* name: 'tailwind-merge',
156-
* importNames: ['twMerge'],
157-
* message:
158-
* 'Please import `cx` from `common/utils/cva.ts` instead of directly from tailwind-merge.',
159-
* },
160-
* {
161-
* name: 'class-variance-authority',
162-
* importNames: ['cx', 'cva'],
163-
* message:
164-
* 'Please import from `common/utils/cva.ts` instead of directly from class-variance-authority.',
165-
*},
166-
*/
154+
{
155+
name: 'tailwind-merge',
156+
importNames: ['twMerge'],
157+
message:
158+
'Please import `cx` from `common/utils/cva.ts` instead of directly from tailwind-merge.',
159+
},
160+
{
161+
name: 'class-variance-authority',
162+
importNames: ['cx', 'cva'],
163+
message:
164+
'Please import from `common/utils/cva.ts` instead of directly from class-variance-authority.',
165+
},
167166
],
168167
},
169168
],
@@ -255,6 +254,18 @@ module.exports = {
255254
importNames: ['default'],
256255
message: 'React is globally availble for all page files.',
257256
},
257+
{
258+
name: 'tailwind-merge',
259+
importNames: ['twMerge'],
260+
message:
261+
'Please import `cx` from `common/utils/cva.ts` instead of directly from tailwind-merge.',
262+
},
263+
{
264+
name: 'class-variance-authority',
265+
importNames: ['cx', 'cva'],
266+
message:
267+
'Please import from `common/utils/cva.ts` instead of directly from class-variance-authority.',
268+
},
258269
],
259270
},
260271
],

components/Alert/Alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { cx } from 'common/utils/cva';
22
import { ALERT, ALERT_CLOSE_BUTTON } from 'common/constants/testIDs';
33
import ScreenReaderOnly from 'components/ScreenReaderOnly/ScreenReaderOnly';
44
import styles from './Alert.module.css';
@@ -20,7 +20,7 @@ function Alert({
2020
}: AlertPropsType) {
2121
return (
2222
<div
23-
className={classNames(styles.Alert, className, {
23+
className={cx(styles.Alert, className, {
2424
[styles.error]: type === 'error',
2525
[styles.success]: type === 'success',
2626
[styles.warning]: type === 'warning',

components/Badge/Badge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { cx } from 'common/utils/cva';
22

33
export interface BadgePropsType {
44
/**
@@ -23,7 +23,7 @@ export interface BadgePropsType {
2323
function Badge({ className = undefined, icon, isImageFirst = true, label }: BadgePropsType) {
2424
return (
2525
<figure
26-
className={classNames(
26+
className={cx(
2727
'flex',
2828
'flex-col',
2929
'justify-items-center',

components/Branding/LogoSection/LogoSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { cx } from 'common/utils/cva';
22
import Badge from 'components/Badge/Badge';
33
import Content from 'components/Content/Content';
44
import { s3 } from 'common/constants/urls';
@@ -14,7 +14,7 @@ function LogoSection() {
1414
columns={[
1515
<ul className={styles.logoSizeList}>
1616
{/* - SMALL LOGOS - */}
17-
<li className={classNames(styles.logoSizeListItem, styles.smallLogos)}>
17+
<li className={cx(styles.logoSizeListItem, styles.smallLogos)}>
1818
<h5 className="text-center">Small Logos</h5>
1919
<p className="mx-auto">
2020
For use when Operation Code&apos;s logo name is between 0-1 inch in height. In most
@@ -255,7 +255,7 @@ function LogoSection() {
255255
</li>
256256

257257
{/* - LARGE LOGOS - */}
258-
<li className={classNames(styles.logoSizeListItem, styles.largeLogos)}>
258+
<li className={cx(styles.logoSizeListItem, styles.largeLogos)}>
259259
<h5 className="text-center">Large Logos</h5>
260260
<p className="mx-auto">
261261
Use the Original Large Logo in almost all cases above 1 inch in height. The Red Large

components/Buttons/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ButtonHTMLAttributes } from 'react';
22
import noop from 'lodash/noop';
3-
import classNames from 'classnames';
3+
import { cx } from 'common/utils/cva';
44
import { BUTTON } from 'common/constants/testIDs';
55
import { gtag } from 'common/utils/thirdParty/gtag';
66
import { getDataAttributes, getAriaAttributes } from 'common/utils/prop-utils';
@@ -76,7 +76,7 @@ export default function Button({
7676

7777
return (
7878
<button
79-
className={classNames(styles.Button, className, styles[theme], {
79+
className={cx(styles.Button, className, styles[theme], {
8080
[styles.disabled]: disabled,
8181
[styles.fullWidth]: fullWidth,
8282
})}

components/Buttons/CloseButton/CloseButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { cx } from 'common/utils/cva';
22
import { CLOSE_BUTTON } from 'common/constants/testIDs';
33
import ScreenReaderOnly from 'components/ScreenReaderOnly/ScreenReaderOnly';
44
import PlusIcon from 'static/images/icons/plus.svg';
@@ -26,7 +26,7 @@ export default function CloseButton({
2626
>
2727
<ScreenReaderOnly>Close</ScreenReaderOnly>
2828

29-
<PlusIcon className={classNames(styles.icon, styles[theme])} />
29+
<PlusIcon className={cx(styles.icon, styles[theme])} />
3030
</button>
3131
);
3232
}

components/Buttons/LinkButton/LinkButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { cx } from 'common/utils/cva';
22
import Link from 'next/link';
33
import OutboundLink from 'components/OutboundLink/OutboundLink';
44
import styles from '../Button/Button.module.css';
@@ -43,7 +43,7 @@ export default function LinkButton({
4343
href,
4444
theme = 'primary',
4545
}: LinkButtonProps) {
46-
const linkButtonClassNames = classNames(styles.Button, className, styles[theme], {
46+
const linkButtonClassNames = cx(styles.Button, className, styles[theme], {
4747
[styles.fullWidth]: fullWidth,
4848
});
4949

components/Cards/Card/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { twMerge } from 'tailwind-merge';
1+
import { cx } from 'common/utils/cva';
22
import { getDataAttributes } from 'common/utils/prop-utils';
33

44
export interface CardPropsType {
@@ -12,7 +12,7 @@ function Card({ children, className, hasAnimationOnHover, ...props }: CardPropsT
1212

1313
return (
1414
<article
15-
className={twMerge(
15+
className={cx(
1616
'items-center bg-white [&_svg]:fill-themeSecondary text-themeSecondary flex flex-col flex-nowrap justify-around m-4 min-h-[100px] min-w-[100px] p-6 shadow-md focus-visible:outline-none',
1717
hasAnimationOnHover &&
1818
'shadow-sm transition-shadow duration-200 ease-linear hover:shadow-lg focus-visible:shadow-lg',

components/Cards/FlatCard/FlatCard.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { element, node, shape, string } from 'prop-types';
2-
import classNames from 'classnames';
3-
import { twMerge } from 'tailwind-merge';
2+
import { cx } from 'common/utils/cva';
43
import Image from 'next/image';
54
import { FLAT_CARD_IMAGE } from 'common/constants/testIDs';
65
import { getPlaceholder } from 'common/utils/next-utils';
@@ -28,12 +27,12 @@ function FlatCard({ button: Button, children, className, header, image }) {
2827

2928
return (
3029
<article
31-
className={classNames('box-border my-6 mx-4 relative max-w-[400px]', className, {
30+
className={cx('box-border my-6 mx-4 relative max-w-[400px]', className, {
3231
'pt-20 sm:pt-14': hasImage,
3332
})}
3433
>
3534
<div
36-
className={twMerge(
35+
className={cx(
3736
'p-8 flex flex-col gap-5 border-4 border-solid border-themePrimary',
3837
hasImage && `pt-32`,
3938
)}

components/Cards/ImageCard/ImageCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { twMerge } from 'tailwind-merge';
1+
import { cx } from 'common/utils/cva';
22
import Image from 'next/image';
33
import type { CardPropsType } from 'components/Cards/Card/Card';
44
import Card from 'components/Cards/Card/Card';
@@ -34,7 +34,7 @@ function ImageCard({
3434

3535
return (
3636
<Card
37-
className={twMerge(
37+
className={cx(
3838
'md:flex-row flex-col md:h-56 md:w-[650px] md:max-w-none p-0 h-auto max-w-xs w-auto [&>*]:flex-[1_1_50%]',
3939
className,
4040
)}

0 commit comments

Comments
 (0)