mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
F: Improve tooltips positioning and text truncation
This commit is contained in:
parent
40b799d815
commit
79c2050ed2
|
@ -67,6 +67,9 @@ function SelectMulti<Option, Group extends GroupBase<Option> = GroupBase<Option>
|
|||
}),
|
||||
option: (styles, { isSelected }) => ({
|
||||
...styles,
|
||||
padding: '0.25rem 0.75rem',
|
||||
fontSize: '0.875rem',
|
||||
lineHeight: '1.25rem',
|
||||
backgroundColor: isSelected ? colors.bgSelected : styles.backgroundColor,
|
||||
color: isSelected ? colors.fgSelected : styles.color,
|
||||
borderWidth: '1px',
|
||||
|
|
|
@ -78,6 +78,9 @@ function SelectSingle<Option, Group extends GroupBase<Option> = GroupBase<Option
|
|||
}),
|
||||
option: (defaultStyles, { isSelected }) => ({
|
||||
...defaultStyles,
|
||||
padding: '0.25rem 0.75rem',
|
||||
fontSize: '0.875rem',
|
||||
lineHeight: '1.25rem',
|
||||
backgroundColor: isSelected ? colors.bgSelected : defaultStyles.backgroundColor,
|
||||
color: isSelected ? colors.fgSelected : defaultStyles.color,
|
||||
borderWidth: '1px',
|
||||
|
|
|
@ -8,16 +8,17 @@ import { CProps } from '../props';
|
|||
export interface TextContentProps extends CProps.Styling {
|
||||
text: string;
|
||||
maxLength?: number;
|
||||
noTooltip?: boolean;
|
||||
}
|
||||
|
||||
function TextContent({ className, text, maxLength, ...restProps }: TextContentProps) {
|
||||
function TextContent({ className, text, maxLength, noTooltip, ...restProps }: TextContentProps) {
|
||||
const truncated = maxLength ? truncateToLastWord(text, maxLength) : text;
|
||||
const isTruncated = maxLength && text.length > maxLength;
|
||||
return (
|
||||
<div
|
||||
className={clsx('text-xs text-pretty', className)}
|
||||
data-tooltip-id={isTruncated ? globals.tooltip : undefined}
|
||||
data-tooltip-content={isTruncated ? text : undefined}
|
||||
data-tooltip-id={isTruncated && !noTooltip ? globals.value_tooltip : undefined}
|
||||
data-tooltip-html={isTruncated && !noTooltip ? text : undefined}
|
||||
{...restProps}
|
||||
>
|
||||
{truncated}
|
||||
|
|
|
@ -145,8 +145,15 @@ export const OptionsState = ({ children }: OptionsStateProps) => {
|
|||
id={`${globals.tooltip}`}
|
||||
layer='z-topmost'
|
||||
place='right-start'
|
||||
className={clsx('mt-1 translate-y-1/2', 'max-w-[20rem]')}
|
||||
className={clsx('mt-8', 'max-w-[20rem]')}
|
||||
/>
|
||||
<Tooltip
|
||||
float
|
||||
id={`${globals.value_tooltip}`}
|
||||
layer='z-topmost'
|
||||
className={clsx('max-w-[calc(min(40rem,100dvw-2rem))]')}
|
||||
/>
|
||||
|
||||
{children}
|
||||
</>
|
||||
</OptionsContext.Provider>
|
||||
|
|
|
@ -178,7 +178,7 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
|
|||
</div>
|
||||
<SelectMultiGrammeme
|
||||
placeholder='Выберите граммемы'
|
||||
className='w-[15rem]'
|
||||
className='min-w-[15rem] h-fit'
|
||||
value={inputGrams}
|
||||
setValue={setInputGrams}
|
||||
/>
|
||||
|
|
|
@ -356,20 +356,27 @@ function EditorTermGraph({ onOpenEdit }: EditorTermGraphProps) {
|
|||
hideZero
|
||||
totalCount={controller.schema?.stats?.count_all ?? 0}
|
||||
selectedCount={controller.selected.length}
|
||||
position='top-[4.3rem] sm:top-[0.3rem] left-0'
|
||||
position='top-[4.3rem] sm:top-[2rem] left-0'
|
||||
/>
|
||||
|
||||
{hoverCst && hoverCstDebounced && hoverCst === hoverCstDebounced ? (
|
||||
<Overlay
|
||||
layer='z-tooltip'
|
||||
position={clsx('top-[1.6rem]', { 'left-[2.6rem]': hoverLeft, 'right-[2.6rem]': !hoverLeft })}
|
||||
className={clsx('w-[25rem]', 'px-3', 'cc-scroll-y', 'border shadow-md', 'clr-app')}
|
||||
className={clsx(
|
||||
'w-[25rem] max-h-[calc(100dvh-15rem)]',
|
||||
'px-3',
|
||||
'cc-scroll-y',
|
||||
'border shadow-md',
|
||||
'clr-input',
|
||||
'text-sm'
|
||||
)}
|
||||
>
|
||||
<InfoConstituenta className='pt-1 pb-2' data={hoverCstDebounced} />
|
||||
</Overlay>
|
||||
) : null}
|
||||
|
||||
<Overlay position='top-[6.25rem] sm:top-9 left-0' className='flex gap-1'>
|
||||
<Overlay position='top-[6.25rem] sm:top-[4rem] left-0' className='flex gap-1'>
|
||||
<div className='flex flex-col ml-2 w-[13.5rem]'>
|
||||
{selectors}
|
||||
{viewHidden}
|
||||
|
|
|
@ -5,12 +5,15 @@ import { useCallback, useLayoutEffect, useMemo } from 'react';
|
|||
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
||||
import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable';
|
||||
import NoData from '@/components/ui/NoData';
|
||||
import TextContent from '@/components/ui/TextContent';
|
||||
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
||||
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
||||
import { isMockCst } from '@/models/rsformAPI';
|
||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||
import { describeConstituenta } from '@/utils/labels';
|
||||
|
||||
const DESCRIPTION_MAX_SYMBOLS = 280;
|
||||
|
||||
interface TableSideConstituentsProps {
|
||||
items: IConstituenta[];
|
||||
activeCst?: IConstituenta;
|
||||
|
@ -76,15 +79,16 @@ function TableSideConstituents({
|
|||
minSize: 250,
|
||||
maxSize: 1000,
|
||||
cell: props => (
|
||||
<div
|
||||
<TextContent
|
||||
noTooltip
|
||||
text={props.getValue()}
|
||||
maxLength={DESCRIPTION_MAX_SYMBOLS}
|
||||
style={{
|
||||
textWrap: 'pretty',
|
||||
fontSize: 12,
|
||||
color: isMockCst(props.row.original) ? colors.fgWarning : undefined
|
||||
}}
|
||||
>
|
||||
{props.getValue()}
|
||||
</div>
|
||||
/>
|
||||
)
|
||||
})
|
||||
],
|
||||
|
|
|
@ -138,6 +138,7 @@ export const storage = {
|
|||
*/
|
||||
export const globals = {
|
||||
tooltip: 'global_tooltip',
|
||||
value_tooltip: 'value_tooltip',
|
||||
password_tooltip: 'password_tooltip',
|
||||
email_tooltip: 'email_tooltip',
|
||||
main_scroll: 'main_scroll',
|
||||
|
|
Loading…
Reference in New Issue
Block a user