import * as React from 'react'; import { useState } from 'react'; import { styled, SvgIcon, type SvgIconProps, ToggleButton, type ToggleButtonProps } from '@elementor/ui'; import { __ } from '@wordpress/i18n'; interface StyledElementorLogoProps extends SvgIconProps { showMenuIcon?: boolean; } type ToolbarLogoProps = Omit< ToggleButtonProps, 'value' >; const ElementorLogo = ( props: SvgIconProps ) => { return ( ); }; const StyledToggleButton = styled( ToggleButton )( ( { theme } ) => ( { padding: 0, border: 0, color: theme.palette.text.primary, '&.MuiToggleButton-root:hover': { backgroundColor: 'initial', }, '&.MuiToggleButton-root.Mui-selected': { backgroundColor: 'initial', }, } ) ); const StyledElementorLogo = styled( ElementorLogo, { shouldForwardProp: ( prop ) => prop !== 'showMenuIcon', } )< StyledElementorLogoProps >( ( { theme, showMenuIcon } ) => ( { '& path': { fill: theme.palette.background.default, transition: 'all 0.2s linear', transformOrigin: 'bottom left', '&:first-of-type': { transitionDelay: ! showMenuIcon && '0.2s', transform: showMenuIcon && 'translateY(-9px) scaleY(0)', }, '&:not(:first-of-type)': { // Emotion automatically change 4 to -4 in RTL mode. transform: ! showMenuIcon && `translateX(${ theme.direction === 'rtl' ? '4' : '9' }px) scaleX(0.6)`, }, '&:nth-of-type(2)': { transitionDelay: showMenuIcon ? '0' : '0.2s', }, '&:nth-of-type(3)': { transitionDelay: '0.1s', }, '&:nth-of-type(4)': { transitionDelay: showMenuIcon ? '0.2s' : '0', }, }, } ) ); export default function ToolbarLogo( props: ToolbarLogoProps ) { const [ isHoverState, setIsHoverState ] = useState( false ); const showMenuIcon = props.selected || isHoverState; return ( setIsHoverState( true ) } onMouseLeave={ () => setIsHoverState( false ) } > ); }