import React, { FC, ReactNode } from 'react'; import { classNames } from '../../lib/classNames'; import { getClassName } from '../../helpers/getClassName'; import { hasReactNode } from '../../lib/utils'; import Tappable, { TappableProps } from '../Tappable/Tappable'; import { Icon16Dropdown } from '@vkontakte/icons'; import { usePlatform } from '../../hooks/usePlatform'; import Caption from '../Typography/Caption/Caption'; import Subhead from '../Typography/Subhead/Subhead'; export interface SubnavigationButtonProps extends Omit { size?: 'm' | 'l'; selected?: boolean; /** * Размер шрифта. Этим свойством рекомендуется пользоваться, чтобы отрегулировать размер шрифта у кнопок в `` */ textLevel?: 1 | 2 | 3; /** * Рекомендуется использовать только иконки с размером 24 */ before?: ReactNode; /** * Рекомендуется использовать только `` или `` */ after?: ReactNode; expandable?: boolean; } function renderLabel(children: ReactNode, textLevel: SubnavigationButtonProps['textLevel']): ReactNode { const className = 'SubnavigationButton__label'; switch (textLevel) { case 1: return ( {children} ); case 2: return ( {children} ); case 3: return ( {children} ); } } export const SubnavigationButton: FC = (props: SubnavigationButtonProps) => { const platform = usePlatform(); const { size, selected, textLevel, before, after, expandable, children, className, ...restProps } = props; return (
{hasReactNode(before) &&
{before}
} {renderLabel(children, textLevel)} {hasReactNode(after) &&
{after}
} {expandable && }
); }; SubnavigationButton.defaultProps = { size: 'm', textLevel: 1, };