From 94c26196d16a6d4bbf69a31f60bd02193513a2b8 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:42:01 +0300 Subject: [PATCH] R: Improve ValueIcon component --- .../src/components/view/value-icon.tsx | 17 ++-------- .../src/components/view/value-stats.tsx | 29 ++++++++++++---- .../components/editor-library-item.tsx | 6 ++-- .../oss-page/editor-oss-card/oss-stats.tsx | 10 +++--- .../editor-rsform-card/rsform-stats.tsx | 34 +++++++++---------- 5 files changed, 49 insertions(+), 47 deletions(-) diff --git a/rsconcept/frontend/src/components/view/value-icon.tsx b/rsconcept/frontend/src/components/view/value-icon.tsx index 0dace74f..021dddc4 100644 --- a/rsconcept/frontend/src/components/view/value-icon.tsx +++ b/rsconcept/frontend/src/components/view/value-icon.tsx @@ -15,15 +15,9 @@ interface ValueIconProps extends Styling, Titled { /** Icon to display. */ icon: React.ReactNode; - /** Classname for the text. */ - textClassName?: string; - /** Callback to be called when the component is clicked. */ onClick?: (event: React.MouseEvent) => void; - /** Number of symbols to display in a small size. */ - smallThreshold?: number; - /** Indicates that padding should be minimal. */ dense?: boolean; @@ -39,19 +33,15 @@ export function ValueIcon({ dense, icon, value, - textClassName, disabled = true, title, titleHtml, hideTitle, className, - smallThreshold, onClick, ...restProps }: ValueIconProps) { - // TODO: use CSS instead of threshold // TODO: do not add button if onClick is disabled - const isSmall = !smallThreshold || String(value).length < smallThreshold; return (
- - - {value} - + {onClick ? : icon} + {value}
); } diff --git a/rsconcept/frontend/src/components/view/value-stats.tsx b/rsconcept/frontend/src/components/view/value-stats.tsx index da92b417..021539ea 100644 --- a/rsconcept/frontend/src/components/view/value-stats.tsx +++ b/rsconcept/frontend/src/components/view/value-stats.tsx @@ -1,6 +1,7 @@ -import { type Styling, type Titled } from '@/components/props'; +import clsx from 'clsx'; -import { ValueIcon } from './value-icon'; +import { type Styling, type Titled } from '@/components/props'; +import { globalIDs } from '@/utils/constants'; // characters - threshold for small labels - small font const SMALL_THRESHOLD = 3; @@ -16,9 +17,23 @@ interface ValueStatsProps extends Styling, Titled { value: string | number; } -/** - * Displays statistics value with an icon. - */ -export function ValueStats(props: ValueStatsProps) { - return ; +/** Displays statistics value with an icon. */ +export function ValueStats({ id, icon, value, className, title, titleHtml, hideTitle, ...restProps }: ValueStatsProps) { + const isSmall = String(value).length < SMALL_THRESHOLD; + return ( +
+ {icon} + + {value} + +
+ ); } diff --git a/rsconcept/frontend/src/features/library/components/editor-library-item.tsx b/rsconcept/frontend/src/features/library/components/editor-library-item.tsx index a87e85ca..d83f49f1 100644 --- a/rsconcept/frontend/src/features/library/components/editor-library-item.tsx +++ b/rsconcept/frontend/src/features/library/components/editor-library-item.tsx @@ -133,23 +133,21 @@ export function EditorLibraryItem({ schema, isAttachedToOSS }: EditorLibraryItem } value={new Date(schema.time_update).toLocaleString(intl.locale)} - title='Дата обновления' /> } value={new Date(schema.time_create).toLocaleString(intl.locale, { year: '2-digit', month: '2-digit', day: '2-digit' })} - title='Дата создания' /> diff --git a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-card/oss-stats.tsx b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-card/oss-stats.tsx index d4ed2c51..56acc70f 100644 --- a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-card/oss-stats.tsx +++ b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-card/oss-stats.tsx @@ -19,34 +19,34 @@ export function OssStats({ className, stats }: OssStatsProps) { } value={stats.count_inputs} - title='Загрузка' /> } value={stats.count_synthesis} - title='Синтез' /> } value={stats.count_schemas} - title='Прикрепленные схемы' /> } value={stats.count_owned} - title='Собственные' /> } value={stats.count_schemas - stats.count_owned} - title='Внешние' /> ); diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-rsform-card/rsform-stats.tsx b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-rsform-card/rsform-stats.tsx index f8fe13b8..943544ce 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-rsform-card/rsform-stats.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-rsform-card/rsform-stats.tsx @@ -38,9 +38,9 @@ export function RSFormStats({ className, stats, isArchive }: RSFormStatsProps) { } value={stats.count_all - stats.count_inherited} - title='Собственные' /> } value={stats.count_all - stats.count_errors - stats.count_property - stats.count_incalculable} - title='Корректные' /> } value={stats.count_errors} - title='Неразмерные' /> } value={stats.count_incalculable} - title='Невычислимые' /> } value={stats.count_errors} - title='Некорректные' /> } value={stats.count_base} - title='Базисные множества' /> } value={stats.count_constant} - title='Константные множества' /> } value={stats.count_structured} - title='Родовые структуры' /> } value={stats.count_axiom} - title='Аксиомы' /> } value={stats.count_term} - title='Термы' /> } value={stats.count_function} - title='Терм-функции' /> } value={stats.count_predicate} - title='Предикат-функции' /> } value={stats.count_theorem} - title='Теоремы' /> } value={stats.count_text_term} - title='Термины' /> } value={stats.count_definition} - title='Определения' /> } value={stats.count_convention} - title='Конвенции' /> );