R: Replace clsx with merging styles
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
Frontend CI / notify-failure (push) Blocked by required conditions

This commit is contained in:
Ivan 2025-06-24 22:23:27 +03:00
parent 2d2c0290e3
commit 91186b0e2e
8 changed files with 16 additions and 21 deletions

View File

@ -1,7 +1,7 @@
import { type FieldError, type GlobalError } from 'react-hook-form'; import { type FieldError, type GlobalError } from 'react-hook-form';
import clsx from 'clsx';
import { type Styling } from '../props'; import { type Styling } from '../props';
import { cn } from '../utils';
interface ErrorFieldProps extends Styling { interface ErrorFieldProps extends Styling {
error?: FieldError | GlobalError; error?: FieldError | GlobalError;
@ -15,7 +15,7 @@ export function ErrorField({ error, className, ...restProps }: ErrorFieldProps):
return null; return null;
} }
return ( return (
<div className={clsx('text-sm text-destructive select-none', className)} {...restProps}> <div className={cn('text-sm text-destructive select-none', className)} {...restProps}>
{error.message} {error.message}
</div> </div>
); );

View File

@ -1,6 +1,5 @@
import clsx from 'clsx';
import { IconChild } from '@/components/icons'; import { IconChild } from '@/components/icons';
import { cn } from '@/components/utils';
import { labelCstTypification } from '../labels'; import { labelCstTypification } from '../labels';
import { type IConstituenta } from '../models/rsform'; import { type IConstituenta } from '../models/rsform';
@ -12,7 +11,7 @@ interface InfoConstituentaProps extends React.ComponentProps<'div'> {
export function InfoConstituenta({ data, className, ...restProps }: InfoConstituentaProps) { export function InfoConstituenta({ data, className, ...restProps }: InfoConstituentaProps) {
return ( return (
<div className={clsx('dense min-w-60 break-words', className)} {...restProps}> <div className={cn('dense min-w-60 break-words', className)} {...restProps}>
<h2 className='cursor-default' title={data.is_inherited ? ' наследник' : undefined}> <h2 className='cursor-default' title={data.is_inherited ? ' наследник' : undefined}>
{data.alias} {data.alias}
{data.is_inherited ? <IconChild size='1rem' className='inline-icon align-middle ml-1 mt-1' /> : null} {data.is_inherited ? <IconChild size='1rem' className='inline-icon align-middle ml-1 mt-1' /> : null}

View File

@ -1,8 +1,7 @@
'use client'; 'use client';
import clsx from 'clsx';
import { type Styling } from '@/components/props'; import { type Styling } from '@/components/props';
import { cn } from '@/components/utils';
import { prefixes } from '@/utils/constants'; import { prefixes } from '@/utils/constants';
import { Grammeme, supportedGrammemes } from '../models/language'; import { Grammeme, supportedGrammemes } from '../models/language';
@ -39,7 +38,7 @@ export function SelectWordForm({ value, onChange, className, ...restProps }: Sel
} }
return ( return (
<div className={clsx('text-xs sm:text-sm grid grid-cols-6', className)} {...restProps}> <div className={cn('text-xs sm:text-sm grid grid-cols-6', className)} {...restProps}>
{DefaultWordForms.slice(0, 12).map((data, index) => ( {DefaultWordForms.slice(0, 12).map((data, index) => (
<WordformButton <WordformButton
key={`${prefixes.wordform_list}${index}`} key={`${prefixes.wordform_list}${index}`}

View File

@ -1,5 +1,3 @@
import clsx from 'clsx';
import { MiniButton } from '@/components/control'; import { MiniButton } from '@/components/control';
import { import {
IconGraphCollapse, IconGraphCollapse,
@ -13,6 +11,7 @@ import {
IconReset IconReset
} from '@/components/icons'; } from '@/components/icons';
import { type Styling } from '@/components/props'; import { type Styling } from '@/components/props';
import { cn } from '@/components/utils';
import { type Graph } from '@/models/graph'; import { type Graph } from '@/models/graph';
interface ToolbarGraphSelectionProps extends Styling { interface ToolbarGraphSelectionProps extends Styling {
@ -44,7 +43,7 @@ export function ToolbarGraphSelection({
} }
return ( return (
<div className={clsx('cc-icons', className)} {...restProps}> <div className={cn('cc-icons', className)} {...restProps}>
<MiniButton <MiniButton
title='Сбросить выделение' title='Сбросить выделение'
icon={<IconReset size='1.25rem' className='icon-primary' />} icon={<IconReset size='1.25rem' className='icon-primary' />}

View File

@ -6,6 +6,7 @@ import { HelpTopic } from '@/features/help';
import { BadgeHelp } from '@/features/help/components'; import { BadgeHelp } from '@/features/help/components';
import { Loader } from '@/components/loader'; import { Loader } from '@/components/loader';
import { cn } from '@/components/utils';
import { APP_COLORS } from '@/styling/colors'; import { APP_COLORS } from '@/styling/colors';
import { globalIDs } from '@/utils/constants'; import { globalIDs } from '@/utils/constants';
import { type RO } from '@/utils/meta'; import { type RO } from '@/utils/meta';
@ -40,7 +41,7 @@ export function StatusBar({ className, isModified, processing, activeCst, parseD
})(); })();
return ( return (
<div className={clsx('pl-34 xs:pl-8 flex gap-1', className)}> <div className={cn('pl-34 xs:pl-8 flex gap-1', className)}>
<div <div
tabIndex={0} tabIndex={0}
className={clsx( className={clsx(

View File

@ -1,9 +1,8 @@
import clsx from 'clsx';
import { IconShowKeyboard } from '@/features/rsform/components/icon-show-keyboard'; import { IconShowKeyboard } from '@/features/rsform/components/icon-show-keyboard';
import { MiniButton } from '@/components/control'; import { MiniButton } from '@/components/control';
import { IconTree, IconTypeGraph } from '@/components/icons'; import { IconTree, IconTypeGraph } from '@/components/icons';
import { cn } from '@/components/utils';
import { usePreferencesStore } from '@/stores/preferences'; import { usePreferencesStore } from '@/stores/preferences';
import { useMutatingRSForm } from '../../../backend/use-mutating-rsform'; import { useMutatingRSForm } from '../../../backend/use-mutating-rsform';
@ -21,7 +20,7 @@ export function ToolbarRSExpression({ className, disabled, showTypeGraph, showAS
const toggleControls = usePreferencesStore(state => state.toggleShowExpressionControls); const toggleControls = usePreferencesStore(state => state.toggleShowExpressionControls);
return ( return (
<div className={clsx('cc-icons', className)}> <div className={cn('cc-icons', className)}>
{!disabled || isProcessing ? ( {!disabled || isProcessing ? (
<MiniButton <MiniButton
title='Отображение специальной клавиатуры' title='Отображение специальной клавиатуры'

View File

@ -1,13 +1,12 @@
'use client'; 'use client';
import clsx from 'clsx';
import { HelpTopic } from '@/features/help'; import { HelpTopic } from '@/features/help';
import { BadgeHelp } from '@/features/help/components'; import { BadgeHelp } from '@/features/help/components';
import { useRestoreVersion } from '@/features/library/backend/use-restore-version'; import { useRestoreVersion } from '@/features/library/backend/use-restore-version';
import { MiniButton } from '@/components/control'; import { MiniButton } from '@/components/control';
import { IconNewVersion, IconUpload, IconVersions } from '@/components/icons'; import { IconNewVersion, IconUpload, IconVersions } from '@/components/icons';
import { cn } from '@/components/utils';
import { useDialogsStore } from '@/stores/dialogs'; import { useDialogsStore } from '@/stores/dialogs';
import { useModificationStore } from '@/stores/modification'; import { useModificationStore } from '@/stores/modification';
import { promptText } from '@/utils/labels'; import { promptText } from '@/utils/labels';
@ -58,7 +57,7 @@ export function ToolbarVersioning({ blockReload, className }: ToolbarVersioningP
} }
return ( return (
<div className={clsx('cc-icons', className)}> <div className={cn('cc-icons', className)}>
{isMutable ? ( {isMutable ? (
<> <>
<MiniButton <MiniButton

View File

@ -1,6 +1,5 @@
import clsx from 'clsx';
import { type Styling } from '@/components/props'; import { type Styling } from '@/components/props';
import { cn } from '@/components/utils';
import { useLabelUser } from '../backend/use-label-user'; import { useLabelUser } from '../backend/use-label-user';
@ -13,7 +12,7 @@ interface InfoUsersProps extends Styling {
export function InfoUsers({ items, className, prefix, header, ...restProps }: InfoUsersProps) { export function InfoUsers({ items, className, prefix, header, ...restProps }: InfoUsersProps) {
const getUserLabel = useLabelUser(); const getUserLabel = useLabelUser();
return ( return (
<div className={clsx('flex flex-col dense', className)} {...restProps}> <div className={cn('flex flex-col dense', className)} {...restProps}>
{header ? <h2>{header}</h2> : null} {header ? <h2>{header}</h2> : null}
{items.map((user, index) => ( {items.map((user, index) => (
<div key={`${prefix}${index}`}>{getUserLabel(user)}</div> <div key={`${prefix}${index}`}>{getUserLabel(user)}</div>