2024-06-02 23:41:46 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2024-01-04 19:38:12 +03:00
|
|
|
import TextURL from '@/components/ui/TextURL';
|
2024-01-06 03:15:02 +03:00
|
|
|
import Tooltip, { PlacesType } from '@/components/ui/Tooltip';
|
2024-06-26 19:47:31 +03:00
|
|
|
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
2023-12-26 14:23:51 +03:00
|
|
|
import { HelpTopic } from '@/models/miscellaneous';
|
2024-09-14 17:10:07 +03:00
|
|
|
import TopicPage from '@/pages/ManualsPage/TopicPage';
|
2023-12-13 14:32:57 +03:00
|
|
|
|
2024-04-03 21:05:53 +03:00
|
|
|
import { IconHelp } from '../Icons';
|
2023-12-18 19:42:27 +03:00
|
|
|
import { CProps } from '../props';
|
2023-12-05 01:22:44 +03:00
|
|
|
|
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;
|
2024-06-02 23:41:46 +03:00
|
|
|
padding?: string;
|
2024-01-06 03:15:02 +03:00
|
|
|
place?: PlacesType;
|
2023-12-05 01:22:44 +03:00
|
|
|
}
|
|
|
|
|
2024-06-02 23:41:46 +03:00
|
|
|
function BadgeHelp({ topic, padding, ...restProps }: BadgeHelpProps) {
|
2024-04-01 19:07:20 +03:00
|
|
|
const { showHelp } = useConceptOptions();
|
|
|
|
|
|
|
|
if (!showHelp) {
|
|
|
|
return null;
|
|
|
|
}
|
2023-12-05 01:22:44 +03:00
|
|
|
return (
|
2024-06-02 23:41:46 +03:00
|
|
|
<div tabIndex={-1} id={`help-${topic}`} className={clsx('p-1', padding)}>
|
2024-04-03 21:05:53 +03:00
|
|
|
<IconHelp size='1.25rem' className='icon-primary' />
|
2024-06-02 23:41:46 +03:00
|
|
|
<Tooltip clickable anchorSelect={`#help-${topic}`} layer='z-modalTooltip' {...restProps}>
|
2024-01-16 01:28:20 +03:00
|
|
|
<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} />
|
2024-01-04 19:30:10 +03:00
|
|
|
</Tooltip>
|
2023-12-28 14:04:44 +03:00
|
|
|
</div>
|
|
|
|
);
|
2023-12-05 01:22:44 +03:00
|
|
|
}
|
|
|
|
|
2024-04-01 19:07:20 +03:00
|
|
|
export default BadgeHelp;
|