66 */
77
88import styled , { css , ThemeProps , DefaultTheme } from 'styled-components' ;
9- import React , { Children } from 'react' ;
10- import { DEFAULT_THEME , retrieveComponentStyles } from '@zendeskgarden/react-theming' ;
9+ import {
10+ DEFAULT_THEME ,
11+ StyledBaseIcon ,
12+ retrieveComponentStyles
13+ } from '@zendeskgarden/react-theming' ;
1114
1215const COMPONENT_ID = 'buttons.icon' ;
1316
1417interface IStyledIconProps {
15- isRotated : boolean ;
16- position ?: 'start' | 'end' ;
18+ $ isRotated : boolean ;
19+ $ position ?: 'start' | 'end' ;
1720}
1821
1922const sizeStyles = ( props : IStyledIconProps & ThemeProps < DefaultTheme > ) => {
2023 let marginProperty ;
2124
22- if ( props . position === 'start' ) {
25+ if ( props . $ position === 'start' ) {
2326 marginProperty = `margin-${ props . theme . rtl ? 'left' : 'right' } ` ;
24- } else if ( props . position === 'end' ) {
27+ } else if ( props . $ position === 'end' ) {
2528 marginProperty = `margin-${ props . theme . rtl ? 'right' : 'left' } ` ;
2629 }
2730
@@ -33,14 +36,11 @@ const sizeStyles = (props: IStyledIconProps & ThemeProps<DefaultTheme>) => {
3336 ) ;
3437} ;
3538
36- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
37- export const StyledIcon = styled ( ( { children, isRotated, theme, ...props } ) =>
38- React . cloneElement ( Children . only ( children ) , props )
39- ) . attrs ( {
39+ export const StyledIcon = styled ( StyledBaseIcon ) . attrs ( {
4040 'data-garden-id' : COMPONENT_ID ,
4141 'data-garden-version' : PACKAGE_VERSION
4242} ) < IStyledIconProps > `
43- transform: ${ props => props . isRotated && `rotate(${ props . theme . rtl ? '-' : '+' } 180deg)` } ;
43+ transform: ${ props => props . $ isRotated && `rotate(${ props . theme . rtl ? '-' : '+' } 180deg)` } ;
4444 transition:
4545 transform 0.25s ease-in-out,
4646 color 0.25s ease-in-out;
0 commit comments