import React, { ElementType, FC, HTMLAttributes } from 'react'; import { DropdownToggle as BSDropdownToggle } from 'reactstrap'; import classNames from 'classnames'; import { Icon } from '../Icon/Icon'; export interface DropdownToggleProps extends HTMLAttributes { caret?: boolean; tag?: ElementType; inNavbar?: boolean; testId?: string; /** Classi aggiuntive da usare per il componente Button */ color?: string; className?: string; outline?: boolean; } export const DropdownToggle: FC = ({ className, testId, children, caret, inNavbar, color = '', tag = 'button' }) => { const Tag = tag === 'a' || inNavbar ? 'a' : 'button'; const classes = classNames(className, { 'btn-dropdown': Tag === 'a' && !inNavbar, 'dropdown-toggle': true, btn: tag === 'button' && !inNavbar }); let colorClass = ''; if (tag === 'button' && color) { colorClass = `btn-${color}`; } const iconClasses = classNames({ 'icon-expand': true, 'icon-sm': !inNavbar, 'icon-xs': inNavbar, 'ms-1': inNavbar, 'icon-light': Tag.valueOf() !== 'a' ? true : false, color: color ? 'white' : 'primary' }); return ( {children as React.ReactNode} {caret === true ? : null} ); };