R: Simplify inline styles pt3

This commit is contained in:
Ivan 2025-03-13 14:40:56 +03:00
parent a60f63455c
commit ed89591af9
17 changed files with 60 additions and 80 deletions

View File

@ -27,7 +27,7 @@ export function ApplicationLayout() {
<NavigationState> <NavigationState>
<div className='min-w-80 antialiased h-full max-w-480 mx-auto'> <div className='min-w-80 antialiased h-full max-w-480 mx-auto'>
<ToasterThemed <ToasterThemed
className={clsx('text-[14px]', noNavigationAnimation ? 'mt-6' : 'mt-14')} className={clsx('text-[14px]/[20px]', noNavigationAnimation ? 'mt-6' : 'mt-14')}
autoClose={3000} autoClose={3000}
draggable={false} draggable={false}
pauseOnFocusLoss={false} pauseOnFocusLoss={false}

View File

@ -40,7 +40,7 @@ export function Dropdown({
<div <div
tabIndex={-1} tabIndex={-1}
className={clsx( className={clsx(
'cc-dropdown grid bg-prim-0 border rounded-md shadow-lg text-sm', 'cc-dropdown isolate z-topmost absolute grid bg-prim-0 border rounded-md shadow-lg text-sm',
stretchLeft ? 'right-0' : 'left-0', stretchLeft ? 'right-0' : 'left-0',
stretchTop ? 'bottom-0' : 'top-full', stretchTop ? 'bottom-0' : 'top-full',
isOpen && 'open', isOpen && 'open',

View File

@ -89,7 +89,7 @@ export function SelectTree<ItemType>({
<div <div
key={`${prefix}${index}`} key={`${prefix}${index}`}
className={clsx( className={clsx(
'cc-tree-item cc-scroll-row clr-hover', 'cc-tree-item relative cc-scroll-row clr-hover',
isActive ? 'max-h-7 py-1 border-b' : 'max-h-0 opacity-0 pointer-events-none', isActive ? 'max-h-7 py-1 border-b' : 'max-h-0 opacity-0 pointer-events-none',
value === item && 'clr-selected' value === item && 'clr-selected'
)} )}

View File

@ -18,7 +18,6 @@ import {
IconTree, IconTree,
IconTypeGraph IconTypeGraph
} from '@/components/icons'; } from '@/components/icons';
import { APP_COLORS } from '@/styling/colors';
import { LinkTopic } from '../../components/link-topic'; import { LinkTopic } from '../../components/link-topic';
import { HelpTopic } from '../../models/help-topic'; import { HelpTopic } from '../../models/help-topic';
@ -69,15 +68,15 @@ export function HelpRSEditor() {
<IconChild className='inline-icon' /> отображение наследованных <IconChild className='inline-icon' /> отображение наследованных
</li> </li>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgSelected }}>текущая конституента</span> <span className='bg-sec-200'>текущая конституента</span>
</li> </li>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgGreen50 }}> <span className='bg-(--acc-bg-green50)'>
<LinkTopic text='основа' topic={HelpTopic.CC_RELATIONS} /> текущей <LinkTopic text='основа' topic={HelpTopic.CC_RELATIONS} /> текущей
</span> </span>
</li> </li>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgOrange50 }}> <span className='bg-(--acc-bg-orange50)'>
<LinkTopic text='порожденные' topic={HelpTopic.CC_RELATIONS} /> текущей <LinkTopic text='порожденные' topic={HelpTopic.CC_RELATIONS} /> текущей
</span> </span>
</li> </li>

View File

@ -19,7 +19,6 @@ import {
IconText, IconText,
IconTypeGraph IconTypeGraph
} from '@/components/icons'; } from '@/components/icons';
import { APP_COLORS } from '@/styling/colors';
import { LinkTopic } from '../../components/link-topic'; import { LinkTopic } from '../../components/link-topic';
import { HelpTopic } from '../../models/help-topic'; import { HelpTopic } from '../../models/help-topic';
@ -49,7 +48,7 @@ export function HelpRSGraphTerm() {
<h1>Изменение узлов</h1> <h1>Изменение узлов</h1>
<li>Клик на узел выделение</li> <li>Клик на узел выделение</li>
<li> <li>
Левый клик выбор <span style={{ color: APP_COLORS.fgPurple }}>фокус-конституенты</span> Левый клик выбор <span className='text-(--acc-fg-purple)'>фокус-конституенты</span>
</li> </li>
<li> <li>
<IconReset className='inline-icon' /> Esc сбросить выделение <IconReset className='inline-icon' /> Esc сбросить выделение

View File

@ -1,5 +1,3 @@
import { APP_COLORS } from '@/styling/colors';
import { LinkTopic } from '../../components/link-topic'; import { LinkTopic } from '../../components/link-topic';
import { HelpTopic } from '../../models/help-topic'; import { HelpTopic } from '../../models/help-topic';
@ -21,13 +19,13 @@ export function HelpTypeGraph() {
<h2>Виды узлов</h2> <h2>Виды узлов</h2>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgControls }}>ступень-основание</span> <span className='bg-prim-200'>ступень-основание</span>
</li> </li>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgTeal }}>ступень-булеан</span> <span className='bg-(--acc-bg-teal)'>ступень-булеан</span>
</li> </li>
<li> <li>
<span style={{ backgroundColor: APP_COLORS.bgOrange }}>ступень декартова произведения</span> <span className='bg-(--acc-bg-orange)'>ступень декартова произведения</span>
</li> </li>
</div> </div>
); );

View File

@ -1,4 +1,5 @@
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import clsx from 'clsx';
import { useAuthSuspense } from '@/features/auth'; import { useAuthSuspense } from '@/features/auth';
import { HelpTopic } from '@/features/help'; import { HelpTopic } from '@/features/help';
@ -6,9 +7,8 @@ import { BadgeHelp } from '@/features/help/components';
import { MiniButton } from '@/components/control'; import { MiniButton } from '@/components/control';
import { IconFolderEdit, IconFolderTree } from '@/components/icons'; import { IconFolderEdit, IconFolderTree } from '@/components/icons';
import { useWindowSize } from '@/hooks/use-window-size';
import { useFitHeight } from '@/stores/app-layout'; import { useFitHeight } from '@/stores/app-layout';
import { PARAMETER, prefixes } from '@/utils/constants'; import { prefixes } from '@/utils/constants';
import { infoMsg } from '@/utils/labels'; import { infoMsg } from '@/utils/labels';
import { useLibrary } from '../../backend/use-library'; import { useLibrary } from '../../backend/use-library';
@ -25,7 +25,6 @@ interface ViewSideLocationProps {
export function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocationProps) { export function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocationProps) {
const { user, isAnonymous } = useAuthSuspense(); const { user, isAnonymous } = useAuthSuspense();
const { items } = useLibrary(); const { items } = useLibrary();
const { isSmall } = useWindowSize();
const location = useLibrarySearchStore(state => state.location); const location = useLibrarySearchStore(state => state.location);
const setLocation = useLibrarySearchStore(state => state.setLocation); const setLocation = useLibrarySearchStore(state => state.setLocation);
@ -62,15 +61,10 @@ export function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocati
return ( return (
<div <div
className='max-w-40 sm:max-w-60 flex flex-col text:xs sm:text-sm select-none' className={clsx(
style={{ 'max-w-40 sm:max-w-60 flex flex-col text:xs sm:text-sm select-none cc-side-location',
transitionProperty: 'width, min-width, opacity', isVisible && 'open min-w-[10rem] sm:min-w-[15rem]'
transitionDuration: `${PARAMETER.moveDuration}ms`, )}
transitionTimingFunction: 'ease-out',
minWidth: isVisible ? (isSmall ? '10rem' : '15rem') : '0',
width: isVisible ? '100%' : '0',
opacity: isVisible ? 1 : 0
}}
> >
<div className='h-8 flex justify-between items-center pr-1 pl-0.5'> <div className='h-8 flex justify-between items-center pr-1 pl-0.5'>
<BadgeHelp topic={HelpTopic.UI_LIBRARY} contentClass='text-sm' offset={5} place='right-start' /> <BadgeHelp topic={HelpTopic.UI_LIBRARY} contentClass='text-sm' offset={5} place='right-start' />

View File

@ -7,7 +7,6 @@ import { PickSubstitutions } from '@/features/rsform/components';
import { TextArea } from '@/components/input'; import { TextArea } from '@/components/input';
import { useDialogsStore } from '@/stores/dialogs'; import { useDialogsStore } from '@/stores/dialogs';
import { APP_COLORS } from '@/styling/colors';
import { type IOperationUpdateDTO } from '../../backend/types'; import { type IOperationUpdateDTO } from '../../backend/types';
import { SubstitutionValidator } from '../../models/oss-api'; import { SubstitutionValidator } from '../../models/oss-api';
@ -45,12 +44,7 @@ export function TabSynthesis() {
)} )}
/> />
<TextArea <TextArea disabled value={validator.msg} rows={4} className={isCorrect ? '' : 'border-(--acc-fg-red) border-2'} />
disabled
value={validator.msg}
rows={4}
style={{ borderColor: isCorrect ? undefined : APP_COLORS.fgRed, borderWidth: isCorrect ? undefined : '2px' }}
/>
</div> </div>
); );
} }

View File

@ -1,5 +1,7 @@
'use client'; 'use client';
import clsx from 'clsx';
import { IconConsolidation, IconRSForm } from '@/components/icons'; import { IconConsolidation, IconRSForm } from '@/components/icons';
import { Indicator } from '@/components/view'; import { Indicator } from '@/components/view';
import { globalIDs } from '@/utils/constants'; import { globalIDs } from '@/utils/constants';
@ -52,13 +54,10 @@ export function NodeCore({ node }: NodeCoreProps) {
) : null} ) : null}
<div <div
className='text-center line-clamp-2' className={clsx(
style={{ 'text-center line-clamp-2 pl-[4px]',
fontSize: longLabel ? '12px' : '14px', longLabel ? 'text-[12px]/[16px] pr-[10px]' : 'text-[14px]/[20px] pr-[4px]'
lineHeight: longLabel ? '16px' : '20px', )}
paddingLeft: '4px',
paddingRight: longLabel ? '10px' : '4px'
}}
> >
{node.data.label} {node.data.label}
</div> </div>

View File

@ -1,5 +1,3 @@
import { APP_COLORS } from '@/styling/colors';
import { colorFgGrammeme } from '../colors'; import { colorFgGrammeme } from '../colors';
import { labelGrammeme } from '../labels'; import { labelGrammeme } from '../labels';
import { type GramData } from '../models/language'; import { type GramData } from '../models/language';
@ -15,11 +13,10 @@ interface BadgeGrammemeProps {
export function BadgeGrammeme({ grammeme }: BadgeGrammemeProps) { export function BadgeGrammeme({ grammeme }: BadgeGrammemeProps) {
return ( return (
<div <div
className='min-w-12 px-1 border rounded-md text-sm font-medium text-center whitespace-nowrap' className='min-w-12 px-1 border rounded-md text-sm font-medium text-center whitespace-nowrap bg-prim-0'
style={{ style={{
borderColor: colorFgGrammeme(grammeme), borderColor: colorFgGrammeme(grammeme),
color: colorFgGrammeme(grammeme), color: colorFgGrammeme(grammeme)
backgroundColor: APP_COLORS.bgInput
}} }}
> >
{labelGrammeme(grammeme)} {labelGrammeme(grammeme)}

View File

@ -1,16 +1,12 @@
'use client'; 'use client';
import { Handle, Position } from 'reactflow'; import { Handle, Position } from 'reactflow';
import clsx from 'clsx';
import { APP_COLORS } from '@/styling/colors';
import { colorBgSyntaxTree } from '../../../colors'; import { colorBgSyntaxTree } from '../../../colors';
import { labelSyntaxTree } from '../../../labels'; import { labelSyntaxTree } from '../../../labels';
import { type ISyntaxTreeNode } from '../../../models/rslang'; import { type ISyntaxTreeNode } from '../../../models/rslang';
const FONT_SIZE_MAX = 14;
const FONT_SIZE_MED = 12;
const LABEL_THRESHOLD = 3; const LABEL_THRESHOLD = 3;
/** /**
@ -30,24 +26,20 @@ export function ASTNode(node: ASTNodeInternal) {
return ( return (
<> <>
<Handle type='target' position={Position.Top} style={{ opacity: 0 }} /> <Handle type='target' position={Position.Top} className='opacity-0' />
<div <div
className='w-full h-full cursor-default flex items-center justify-center rounded-full' className='w-full h-full cursor-default flex items-center justify-center rounded-full'
style={{ backgroundColor: colorBgSyntaxTree(node.data) }} style={{ backgroundColor: colorBgSyntaxTree(node.data) }}
/> />
<Handle type='source' position={Position.Bottom} style={{ opacity: 0 }} /> <Handle type='source' position={Position.Bottom} className='opacity-0' />
<div <div
className='font-math mt-1 w-fit text-center translate-x-[calc(-50%+20px)]' className={clsx(
style={{ fontSize: label.length > LABEL_THRESHOLD ? FONT_SIZE_MED : FONT_SIZE_MAX }} 'font-math mt-1 w-fit text-center translate-x-[calc(-50%+20px)]',
label.length > LABEL_THRESHOLD ? 'text-[12px]/[16px]' : 'text-[14px]/[20px]'
)}
> >
<div className='absolute top-0 left-0 text-center w-full'>{label}</div> <div className='absolute top-0 left-0 text-center w-full'>{label}</div>
<div <div aria-hidden className='cc-ast-label-outline'>
aria-hidden='true'
style={{
WebkitTextStrokeWidth: 2,
WebkitTextStrokeColor: APP_COLORS.bgDefault
}}
>
{label} {label}
</div> </div>
</div> </div>

View File

@ -2,7 +2,6 @@
import { Handle, Position } from 'reactflow'; import { Handle, Position } from 'reactflow';
import { APP_COLORS } from '@/styling/colors';
import { globalIDs } from '@/utils/constants'; import { globalIDs } from '@/utils/constants';
import { colorBgTMGraphNode } from '../../../colors'; import { colorBgTMGraphNode } from '../../../colors';
@ -28,15 +27,10 @@ export function MGraphNode(node: MGraphNodeInternal) {
<> <>
<Handle type='source' position={Position.Top} className='opacity-0' /> <Handle type='source' position={Position.Top} className='opacity-0' />
<div <div
className='w-full h-full cursor-default flex items-center justify-center rounded-full' className='cc-node-label w-full h-full cursor-default flex items-center justify-center rounded-full'
data-tooltip-id={globalIDs.tooltip} data-tooltip-id={globalIDs.tooltip}
data-tooltip-html={tooltipText} data-tooltip-html={tooltipText}
style={{ style={{ backgroundColor: colorBgTMGraphNode(node.data) }}
backgroundColor: colorBgTMGraphNode(node.data),
fontWeight: 600,
WebkitTextStrokeWidth: '0.6px',
WebkitTextStrokeColor: APP_COLORS.bgDefault
}}
> >
{node.data.rank === 0 ? node.data.text : node.data.annotations.length > 0 ? node.data.annotations.length : ''} {node.data.rank === 0 ? node.data.text : node.data.annotations.length > 0 ? node.data.annotations.length : ''}
</div> </div>

View File

@ -98,6 +98,7 @@ export function RSEditorControls({ isOpen, disabled, onEdit }: RSEditorControlsP
'select-none', 'select-none',
isOpen && 'open' isOpen && 'open'
)} )}
aria-hidden={!isOpen}
> >
{MAIN_FIRST_ROW.map(token => ( {MAIN_FIRST_ROW.map(token => (
<RSTokenButton key={`${prefixes.rsedit_btn}${token}`} token={token} onInsert={onEdit} disabled={disabled} /> <RSTokenButton key={`${prefixes.rsedit_btn}${token}`} token={token} onInsert={onEdit} disabled={disabled} />

View File

@ -54,7 +54,7 @@ export function TGNode(node: TGNodeInternal) {
className={clsx( className={clsx(
'w-full h-full cursor-default flex items-center justify-center rounded-full', 'w-full h-full cursor-default flex items-center justify-center rounded-full',
isFocused && 'border-2 border-sec-200', isFocused && 'border-2 border-sec-200',
label.length > LABEL_THRESHOLD ? 'text-[12px]' : 'text-[14px]' label.length > LABEL_THRESHOLD ? 'text-[12px]/[16px]' : 'text-[14px]/[20px]'
)} )}
style={{ style={{
backgroundColor: node.selected backgroundColor: node.selected
@ -76,7 +76,7 @@ export function TGNode(node: TGNodeInternal) {
<div <div
className={clsx( className={clsx(
'mt-1 w-[150px] px-1 text-center translate-x-[calc(-50%+20px)]', 'mt-1 w-[150px] px-1 text-center translate-x-[calc(-50%+20px)]',
description.length > DESCRIPTION_THRESHOLD ? 'text-[10px]' : 'text-[12px]' description.length > DESCRIPTION_THRESHOLD ? 'text-[10px]/[12px]' : 'text-[12px]/[16px]'
)} )}
onContextMenu={handleContextMenu} onContextMenu={handleContextMenu}
onDoubleClick={handleDoubleClick} onDoubleClick={handleDoubleClick}
@ -84,7 +84,7 @@ export function TGNode(node: TGNodeInternal) {
<div className='absolute top-0 px-1 left-0 text-center w-full line-clamp-3 hover:line-clamp-none'> <div className='absolute top-0 px-1 left-0 text-center w-full line-clamp-3 hover:line-clamp-none'>
{description} {description}
</div> </div>
<div aria-hidden='true' className='line-clamp-3 hover:line-clamp-none cc-text-outline'> <div aria-hidden className='line-clamp-3 hover:line-clamp-none cc-text-outline'>
{description} {description}
</div> </div>
</div> </div>

View File

@ -70,6 +70,7 @@ export function ViewHidden({ items }: ViewHiddenProps) {
'cc-scroll-y', 'cc-scroll-y',
!isFolded && 'open' !isFolded && 'open'
)} )}
aria-hidden={isFolded}
style={{ maxHeight: hiddenHeight }} style={{ maxHeight: hiddenHeight }}
> >
{items.map(cstID => { {items.map(cstID => {

View File

@ -21,7 +21,6 @@
} }
@utility cc-tree-item { @utility cc-tree-item {
position: relative;
padding-left: 1.5rem; padding-left: 1.5rem;
padding-right: 0.75rem; padding-right: 0.75rem;
@ -80,10 +79,12 @@
-webkit-text-stroke-color: var(--clr-prim-100); -webkit-text-stroke-color: var(--clr-prim-100);
} }
@utility cc-dropdown { @utility cc-ast-label-outline {
position: absolute; -webkit-text-stroke-width: 2px;
z-index: var(--z-index-topmost); -webkit-text-stroke-color: var(--clr-prim-100);
}
@utility cc-dropdown {
transition-property: clip-path, transform; transition-property: clip-path, transform;
transition-duration: var(--duration-dropdown); transition-duration: var(--duration-dropdown);
transition-timing-function: var(--ease-in-out); transition-timing-function: var(--ease-in-out);
@ -97,6 +98,21 @@
} }
} }
@utility cc-side-location {
transition-property: width, min-width, opacity;
transition-duration: var(--duration-move);
transition-timing-function: var(--ease-bezier);
opacity: 0;
width: 0;
min-width: 0;
&.open {
opacity: 1;
width: 100%;
}
}
@utility cc-view-hidden-header { @utility cc-view-hidden-header {
transition-property: transform; transition-property: transform;
transition-duration: var(--duration-dropdown); transition-duration: var(--duration-dropdown);

View File

@ -169,7 +169,3 @@
@utility border { @utility border {
border-radius: 0.25rem; border-radius: 0.25rem;
} }
@utility sticky {
z-index: 20;
}