2024-05-14 19:16:04 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
import { SelectTree } from '@/components/Input';
|
2025-01-14 21:58:16 +03:00
|
|
|
import { useFitHeight } from '@/stores/appLayout';
|
2024-05-20 17:45:37 +03:00
|
|
|
import { prefixes } from '@/utils/constants';
|
2024-05-14 19:16:04 +03:00
|
|
|
|
2025-02-11 20:56:24 +03:00
|
|
|
import { describeHelpTopic, labelHelpTopic } from '../../labels';
|
|
|
|
import { HelpTopic, topicParent } from '../../models/helpTopic';
|
2025-02-10 01:32:55 +03:00
|
|
|
|
2024-05-14 19:16:04 +03:00
|
|
|
interface TopicsStaticProps {
|
|
|
|
activeTopic: HelpTopic;
|
|
|
|
onChangeTopic: (newTopic: HelpTopic) => void;
|
|
|
|
}
|
|
|
|
|
2025-02-19 23:30:35 +03:00
|
|
|
export function TopicsStatic({ activeTopic, onChangeTopic }: TopicsStaticProps) {
|
2025-01-14 21:58:16 +03:00
|
|
|
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}
|
2025-02-04 20:35:55 +03:00
|
|
|
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',
|
2024-12-12 13:19:12 +03:00
|
|
|
'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'
|
|
|
|
)}
|
2025-01-14 21:58:16 +03:00
|
|
|
style={{ maxHeight: topicsHeight }}
|
2024-05-20 17:45:37 +03:00
|
|
|
/>
|
2024-05-14 19:16:04 +03:00
|
|
|
);
|
|
|
|
}
|