ConceptPortal-public/rsconcept/frontend/src/components/info/BadgeHelp.tsx

41 lines
1.3 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import TextURL from '@/components/ui/TextURL';
import Tooltip, { PlacesType } from '@/components/ui/Tooltip';
import { useConceptOptions } from '@/context/ConceptOptionsContext';
2023-12-26 14:23:51 +03:00
import { HelpTopic } from '@/models/miscellaneous';
import TopicPage from '../../pages/ManualsPage/TopicPage';
import { IconHelp } from '../Icons';
import { CProps } from '../props';
2024-04-01 19:07:20 +03:00
interface BadgeHelpProps extends CProps.Styling {
2023-12-28 14:04:44 +03:00
topic: HelpTopic;
offset?: number;
padding?: string;
place?: PlacesType;
}
function BadgeHelp({ topic, padding, ...restProps }: BadgeHelpProps) {
2024-04-01 19:07:20 +03:00
const { showHelp } = useConceptOptions();
if (!showHelp) {
return null;
}
return (
<div tabIndex={-1} id={`help-${topic}`} className={clsx('p-1', padding)}>
<IconHelp size='1.25rem' className='icon-primary' />
<Tooltip clickable anchorSelect={`#help-${topic}`} layer='z-modalTooltip' {...restProps}>
<div className='relative' onClick={event => event.stopPropagation()}>
2024-02-22 11:35:27 +03:00
<div className='absolute right-0 text-sm top-[0.4rem] clr-input'>
2023-12-28 14:04:44 +03:00
<TextURL text='Справка...' href={`/manuals?topic=${topic}`} />
</div>
</div>
2024-05-16 22:39:28 +03:00
<TopicPage topic={topic} />
</Tooltip>
2023-12-28 14:04:44 +03:00
</div>
);
}
2024-04-01 19:07:20 +03:00
export default BadgeHelp;