refactor: replace classnames with clsx (#78)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import styles from './Button.module.scss';
|
||||
|
||||
@@ -30,7 +30,7 @@ export function Button({
|
||||
<button
|
||||
style={style}
|
||||
data-testid={testId}
|
||||
className={classNames(styles.button, className, styles[type ?? 'primary'], {
|
||||
className={clsx(styles.button, className, styles[type ?? 'primary'], {
|
||||
[styles.disabled]: disabled,
|
||||
})}
|
||||
title={title}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import classNames from 'classnames';
|
||||
import React, { Component } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import styles from './Card.module.scss';
|
||||
|
||||
export type Props = {
|
||||
@@ -17,7 +17,7 @@ export default function Card(props: Props) {
|
||||
return (
|
||||
<div
|
||||
style={props.style}
|
||||
className={classNames(styles.card, props.className)}
|
||||
className={clsx(styles.card, props.className)}
|
||||
onClick={props.onClick}
|
||||
data-testid={props.testId}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import classnames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import { Color } from '@views/styles/colors.module.scss';
|
||||
import styles from './Divider.module.scss';
|
||||
@@ -21,5 +21,5 @@ export default function Divider(props: Props) {
|
||||
borderStyle: props.type,
|
||||
};
|
||||
|
||||
return <hr data-testid={props.testId} style={style} className={classnames(styles.divider, props.className)} />;
|
||||
return <hr data-testid={props.testId} style={style} className={clsx(styles.divider, props.className)} />;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import colors, { Color } from '@views/styles/colors.module.scss';
|
||||
import fonts, { Size } from '@views/styles/fonts.module.scss';
|
||||
@@ -36,7 +36,7 @@ export default function Icon(props: Props) {
|
||||
<span
|
||||
data-testid={props.testId}
|
||||
style={style}
|
||||
className={classNames(styles.icon, props.className)}
|
||||
className={clsx(styles.icon, props.className)}
|
||||
onClick={props.onClick}
|
||||
>
|
||||
{props.name}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { background } from '@shared/messages';
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import Text, { TextProps } from '../Text/Text';
|
||||
import styles from './Link.module.scss';
|
||||
@@ -29,7 +29,7 @@ export default function Link(props: PropsWithChildren<Props>) {
|
||||
color='bluebonnet'
|
||||
{...passedProps}
|
||||
span
|
||||
className={classNames(
|
||||
className={clsx(
|
||||
styles.link,
|
||||
{
|
||||
[styles.disabled]: isDisabled,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React, { PropsWithChildren, useCallback } from 'react';
|
||||
import styles from './Popup.module.scss';
|
||||
|
||||
@@ -46,12 +46,12 @@ export default function Popup({ onClose, children, className, style, testId, ove
|
||||
<div
|
||||
style={style}
|
||||
ref={containerRef}
|
||||
className={classNames(styles.container, {
|
||||
className={clsx(styles.container, {
|
||||
[styles.overlay]: overlay,
|
||||
})}
|
||||
data-testid={testId}
|
||||
>
|
||||
<div ref={bodyRef} className={classNames(styles.body, className)}>
|
||||
<div ref={bodyRef} className={clsx(styles.body, className)}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import styles from './Spinner.module.scss';
|
||||
|
||||
@@ -12,5 +12,5 @@ type Props = {
|
||||
* A simple spinner component that can be used to indicate loading.
|
||||
*/
|
||||
export default function Spinner({ className, testId, style }: Props) {
|
||||
return <div data-testid={testId} style={style} className={classNames(styles.spinner, className)} />;
|
||||
return <div data-testid={testId} style={style} className={clsx(styles.spinner, className)} />;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import styles from './Text.module.scss';
|
||||
|
||||
@@ -20,7 +20,7 @@ type Variant = (typeof variants)[number];
|
||||
* A reusable Text component with props that build on top of the design system for the extension
|
||||
*/
|
||||
export default function Text({ variant, as, className, ...props }: PropsWithChildren<TextProps>) {
|
||||
const mergedClassName = classNames(styles.text, styles[variant], className);
|
||||
const mergedClassName = clsx(styles.text, styles[variant], className);
|
||||
|
||||
if (as === 'div') return <div className={mergedClassName} {...props} />;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Course } from '@shared/types/Course';
|
||||
import classNames from 'classnames';
|
||||
import clsx from 'clsx';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Spinner from '@views/components/common/Spinner/Spinner';
|
||||
import Text from '@views/components/common/Text/Text';
|
||||
@@ -64,7 +64,7 @@ interface LineProps {
|
||||
function DescriptionLine({ line }: LineProps) {
|
||||
const lowerCaseLine = line.toLowerCase();
|
||||
|
||||
const className = classNames({
|
||||
const className = clsx({
|
||||
[styles.prerequisite]: lowerCaseLine.includes('prerequisite'),
|
||||
[styles.onlyOne]:
|
||||
lowerCaseLine.includes('may be') || lowerCaseLine.includes('only one') || lowerCaseLine.includes('may not'),
|
||||
|
||||
Reference in New Issue
Block a user