Portal/rsconcept/frontend/src/components/info/BadgeHelp.tsx

39 lines
1.2 KiB
TypeScript
Raw Normal View History

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