Portal/rsconcept/frontend/src/pages/ManualsPage/TopicsStatic.tsx

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
2025-02-07 10:53:49 +03:00
import { SelectTree } from '@/components/ui/Input';
2024-06-07 20:17:03 +03:00
import { HelpTopic, topicParent } from '@/models/miscellaneous';
import { useFitHeight } from '@/stores/appLayout';
2024-06-07 20:17:03 +03:00
import { prefixes } from '@/utils/constants';
import { describeHelpTopic, labelHelpTopic } from '@/utils/labels';
interface TopicsStaticProps {
activeTopic: HelpTopic;
onChangeTopic: (newTopic: HelpTopic) => void;
}
function TopicsStatic({ activeTopic, onChangeTopic }: TopicsStaticProps) {
const topicsHeight = useFitHeight('1rem + 2px');
2024-06-07 20:17:03 +03:00
return (
<SelectTree
items={Object.values(HelpTopic).map(item => item as HelpTopic)}
value={activeTopic}
onChange={onChangeTopic}
2024-06-07 20:17:03 +03:00
prefix={prefixes.topic_list}
getParent={item => topicParent.get(item) ?? item}
getLabel={labelHelpTopic}
getDescription={describeHelpTopic}
className={clsx(
'sticky top-0 left-0',
'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',
'self-start',
2024-12-11 23:37:23 +03:00
'border-x border-t rounded-none',
2024-12-17 10:52:36 +03:00
'text-xs sm:text-sm bg-prim-200',
2024-06-07 20:17:03 +03:00
'select-none'
)}
style={{ maxHeight: topicsHeight }}
2024-06-07 20:17:03 +03:00
/>
);
}
export default TopicsStatic;