ConceptPortal-public/rsconcept/frontend/src/features/help/pages/ManualsPage/TopicsStatic.tsx

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-05-14 19:16:04 +03:00
import clsx from 'clsx';
import { SelectTree } from '@/components/Input';
import { useFitHeight } from '@/stores/appLayout';
2024-05-20 17:45:37 +03:00
import { prefixes } from '@/utils/constants';
import { describeHelpTopic, labelHelpTopic } from '@/utils/labels';
2024-05-14 19:16:04 +03:00
import { topicParent } from '../../models/helpTopic';
import { HelpTopic } from '../../models/helpTopic';
2024-05-14 19:16:04 +03:00
interface TopicsStaticProps {
activeTopic: HelpTopic;
onChangeTopic: (newTopic: HelpTopic) => void;
}
2024-05-16 16:05:39 +03:00
function TopicsStatic({ activeTopic, onChangeTopic }: TopicsStaticProps) {
const topicsHeight = useFitHeight('1rem + 2px');
2024-05-14 19:16:04 +03:00
return (
2024-05-20 17:45:37 +03:00
<SelectTree
items={Object.values(HelpTopic).map(item => item as HelpTopic)}
value={activeTopic}
onChange={onChangeTopic}
2024-05-20 17:45:37 +03:00
prefix={prefixes.topic_list}
getParent={item => topicParent.get(item) ?? item}
getLabel={labelHelpTopic}
getDescription={describeHelpTopic}
2024-05-14 19:16:04 +03:00
className={clsx(
'sticky top-0 left-0',
2024-05-29 22:40:23 +03:00
'min-w-[14.5rem] max-w-[14.5rem] sm:min-w-[12.5rem] sm:max-w-[12.5rem] md:min-w-[14.5rem] md:max-w-[14.5rem]',
'cc-scroll-y',
2024-05-14 19:16:04 +03:00
'self-start',
'border-x border-t rounded-none',
2024-12-17 10:53:01 +03:00
'text-xs sm:text-sm bg-prim-200',
2024-05-14 19:16:04 +03:00
'select-none'
)}
style={{ maxHeight: topicsHeight }}
2024-05-20 17:45:37 +03:00
/>
2024-05-14 19:16:04 +03:00
);
}
export default TopicsStatic;