refactor: replace classnames with clsx (#78)
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
"@types/sql.js": "^1.4.9",
|
"@types/sql.js": "^1.4.9",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"chrome-extension-toolkit": "^0.0.51",
|
"chrome-extension-toolkit": "^0.0.51",
|
||||||
"classnames": "^2.5.1",
|
"clsx": "^2.1.0",
|
||||||
"highcharts": "^11.3.0",
|
"highcharts": "^11.3.0",
|
||||||
"highcharts-react-official": "^3.2.1",
|
"highcharts-react-official": "^3.2.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|||||||
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
@@ -22,9 +22,9 @@ dependencies:
|
|||||||
chrome-extension-toolkit:
|
chrome-extension-toolkit:
|
||||||
specifier: ^0.0.51
|
specifier: ^0.0.51
|
||||||
version: 0.0.51
|
version: 0.0.51
|
||||||
classnames:
|
clsx:
|
||||||
specifier: ^2.5.1
|
specifier: ^2.1.0
|
||||||
version: 2.5.1
|
version: 2.1.0
|
||||||
highcharts:
|
highcharts:
|
||||||
specifier: ^11.3.0
|
specifier: ^11.3.0
|
||||||
version: 11.3.0
|
version: 11.3.0
|
||||||
@@ -6104,10 +6104,6 @@ packages:
|
|||||||
consola: 3.2.3
|
consola: 3.2.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/classnames@2.5.1:
|
|
||||||
resolution: {integrity: sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/clean-stack@2.2.0:
|
/clean-stack@2.2.0:
|
||||||
resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==}
|
resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
@@ -6159,6 +6155,11 @@ packages:
|
|||||||
engines: {node: '>=0.8'}
|
engines: {node: '>=0.8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/clsx@2.1.0:
|
||||||
|
resolution: {integrity: sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/color-convert@1.9.3:
|
/color-convert@1.9.3:
|
||||||
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
|
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styles from './Button.module.scss';
|
import styles from './Button.module.scss';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export function Button({
|
|||||||
<button
|
<button
|
||||||
style={style}
|
style={style}
|
||||||
data-testid={testId}
|
data-testid={testId}
|
||||||
className={classNames(styles.button, className, styles[type ?? 'primary'], {
|
className={clsx(styles.button, className, styles[type ?? 'primary'], {
|
||||||
[styles.disabled]: disabled,
|
[styles.disabled]: disabled,
|
||||||
})}
|
})}
|
||||||
title={title}
|
title={title}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import styles from './Card.module.scss';
|
import styles from './Card.module.scss';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
@@ -17,7 +17,7 @@ export default function Card(props: Props) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={props.style}
|
style={props.style}
|
||||||
className={classNames(styles.card, props.className)}
|
className={clsx(styles.card, props.className)}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
data-testid={props.testId}
|
data-testid={props.testId}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import classnames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Color } from '@views/styles/colors.module.scss';
|
import { Color } from '@views/styles/colors.module.scss';
|
||||||
import styles from './Divider.module.scss';
|
import styles from './Divider.module.scss';
|
||||||
@@ -21,5 +21,5 @@ export default function Divider(props: Props) {
|
|||||||
borderStyle: props.type,
|
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 React from 'react';
|
||||||
import colors, { Color } from '@views/styles/colors.module.scss';
|
import colors, { Color } from '@views/styles/colors.module.scss';
|
||||||
import fonts, { Size } from '@views/styles/fonts.module.scss';
|
import fonts, { Size } from '@views/styles/fonts.module.scss';
|
||||||
@@ -36,7 +36,7 @@ export default function Icon(props: Props) {
|
|||||||
<span
|
<span
|
||||||
data-testid={props.testId}
|
data-testid={props.testId}
|
||||||
style={style}
|
style={style}
|
||||||
className={classNames(styles.icon, props.className)}
|
className={clsx(styles.icon, props.className)}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
>
|
>
|
||||||
{props.name}
|
{props.name}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { background } from '@shared/messages';
|
import { background } from '@shared/messages';
|
||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React, { PropsWithChildren } from 'react';
|
import React, { PropsWithChildren } from 'react';
|
||||||
import Text, { TextProps } from '../Text/Text';
|
import Text, { TextProps } from '../Text/Text';
|
||||||
import styles from './Link.module.scss';
|
import styles from './Link.module.scss';
|
||||||
@@ -29,7 +29,7 @@ export default function Link(props: PropsWithChildren<Props>) {
|
|||||||
color='bluebonnet'
|
color='bluebonnet'
|
||||||
{...passedProps}
|
{...passedProps}
|
||||||
span
|
span
|
||||||
className={classNames(
|
className={clsx(
|
||||||
styles.link,
|
styles.link,
|
||||||
{
|
{
|
||||||
[styles.disabled]: isDisabled,
|
[styles.disabled]: isDisabled,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React, { PropsWithChildren, useCallback } from 'react';
|
import React, { PropsWithChildren, useCallback } from 'react';
|
||||||
import styles from './Popup.module.scss';
|
import styles from './Popup.module.scss';
|
||||||
|
|
||||||
@@ -46,12 +46,12 @@ export default function Popup({ onClose, children, className, style, testId, ove
|
|||||||
<div
|
<div
|
||||||
style={style}
|
style={style}
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
className={classNames(styles.container, {
|
className={clsx(styles.container, {
|
||||||
[styles.overlay]: overlay,
|
[styles.overlay]: overlay,
|
||||||
})}
|
})}
|
||||||
data-testid={testId}
|
data-testid={testId}
|
||||||
>
|
>
|
||||||
<div ref={bodyRef} className={classNames(styles.body, className)}>
|
<div ref={bodyRef} className={clsx(styles.body, className)}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styles from './Spinner.module.scss';
|
import styles from './Spinner.module.scss';
|
||||||
|
|
||||||
@@ -12,5 +12,5 @@ type Props = {
|
|||||||
* A simple spinner component that can be used to indicate loading.
|
* A simple spinner component that can be used to indicate loading.
|
||||||
*/
|
*/
|
||||||
export default function Spinner({ className, testId, style }: Props) {
|
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 React, { PropsWithChildren } from 'react';
|
||||||
import styles from './Text.module.scss';
|
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
|
* 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>) {
|
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} />;
|
if (as === 'div') return <div className={mergedClassName} {...props} />;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Course } from '@shared/types/Course';
|
import { Course } from '@shared/types/Course';
|
||||||
import classNames from 'classnames';
|
import clsx from 'clsx';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import Spinner from '@views/components/common/Spinner/Spinner';
|
import Spinner from '@views/components/common/Spinner/Spinner';
|
||||||
import Text from '@views/components/common/Text/Text';
|
import Text from '@views/components/common/Text/Text';
|
||||||
@@ -64,7 +64,7 @@ interface LineProps {
|
|||||||
function DescriptionLine({ line }: LineProps) {
|
function DescriptionLine({ line }: LineProps) {
|
||||||
const lowerCaseLine = line.toLowerCase();
|
const lowerCaseLine = line.toLowerCase();
|
||||||
|
|
||||||
const className = classNames({
|
const className = clsx({
|
||||||
[styles.prerequisite]: lowerCaseLine.includes('prerequisite'),
|
[styles.prerequisite]: lowerCaseLine.includes('prerequisite'),
|
||||||
[styles.onlyOne]:
|
[styles.onlyOne]:
|
||||||
lowerCaseLine.includes('may be') || lowerCaseLine.includes('only one') || lowerCaseLine.includes('may not'),
|
lowerCaseLine.includes('may be') || lowerCaseLine.includes('only one') || lowerCaseLine.includes('may not'),
|
||||||
|
|||||||
Reference in New Issue
Block a user