import React from 'react'; import { VerticalMenuIcon } from '@100mslive/react-icons'; import { Dropdown } from '../../../Dropdown'; import { Flex } from '../../../Layout'; import { styled } from '../../../Theme'; import { Tooltip } from '../../../Tooltip'; import IconButton from '../../IconButton'; const variants = { disabled: { true: { bg: '$surface_brighter', }, }, active: { false: { bg: '$secondary_dim', }, }, }; const IconSection = styled(IconButton, { w: 'unset', h: '$14', p: '$4', r: '$1', bg: 'transparent', borderTopRightRadius: '0 !important', borderColor: '$border_bright', borderBottomRightRadius: '0 !important', position: 'relative', '&:not([disabled]):focus-visible': { zIndex: 1, }, '@md': { mx: 0, borderTopRightRadius: '$1 !important', borderBottomRightRadius: '$1 !important', }, variants: { ...variants, hideOptions: { true: { borderTopRightRadius: '$1 !important', borderBottomRightRadius: '$1 !important', }, }, }, }); const OptionsSection = styled(IconButton, { w: 'unset', h: '$14', p: '$4 $2', r: '$1', borderTopLeftRadius: '0 !important', borderColor: '$border_bright', borderBottomLeftRadius: '0 !important', borderLeftWidth: '0 !important', position: 'relative', '&:not([disabled]):focus-visible': { zIndex: 1, }, '@md': { display: 'none', }, variants, }); const Icon = styled(Flex, { alignItems: 'center', justifyContent: 'center', color: '$on_primary_high', variants: { disabled: { true: { color: '$on_surface_low', }, }, active: { true: { color: '$on_surface_high', }, }, }, }); export const IconButtonWithOptions = ({ disabled = false, onDisabledClick = () => { return; }, testid = '', tooltipMessage = '', icon, children, active, hideOptions = false, onClick = () => { return; }, }: { onClick: () => void; onDisabledClick: () => void; icon: React.ReactNode; children: React.ReactNode; testid?: string; hideOptions?: boolean; active: boolean; disabled?: boolean; tooltipMessage?: string; }) => { const commonProps = { disabled, active }; return ( {icon} {!hideOptions && children ? ( { if (disabled) { e.preventDefault(); onDisabledClick(); } }} > {children} ) : null} ); };