88
99import React , {
1010 FunctionComponent ,
11+ HTMLAttributes ,
1112 ReactElement ,
1213 CSSProperties ,
1314 useMemo ,
1415} from 'react' ;
1516import classNames from 'classnames' ;
1617
18+ import { CommonProps } from '../common' ;
1719import { logicalStyles } from '../../global_styling' ;
1820
19- export type EuiAspectRatioProps = {
20- /**
21- * Aspect ratio height. For example 9 would be widescreen video.
22- */
23- height : number ;
24- /**
25- * Aspect ratio width. For example 16 would be widescreen video.
26- */
27- width : number ;
28- /**
29- * The maximum width you want the child to stretch to.
30- */
31- maxWidth ?: CSSProperties [ 'width' ] ;
32- children : ReactElement < any > ;
33- } ;
21+ export type EuiAspectRatioProps = HTMLAttributes < HTMLDivElement > &
22+ CommonProps & {
23+ /**
24+ * Aspect ratio height. For example 9 would be widescreen video.
25+ */
26+ height : number ;
27+ /**
28+ * Aspect ratio width. For example 16 would be widescreen video.
29+ */
30+ width : number ;
31+ /**
32+ * The maximum width you want the child to stretch to.
33+ */
34+ maxWidth ?: CSSProperties [ 'width' ] ;
35+ children : ReactElement < any > ;
36+ } ;
3437
3538export const EuiAspectRatio : FunctionComponent < EuiAspectRatioProps > = ( {
3639 children,
40+ className,
41+ style,
3742 height,
3843 width,
3944 maxWidth,
45+ ...rest
4046} ) => {
41- const classes = classNames ( 'euiAspectRatio' , children . props . className ) ;
47+ const classes = classNames (
48+ 'euiAspectRatio' ,
49+ className ,
50+ children . props . className
51+ ) ;
4252
4353 const euiAspectRatioStyle = useMemo (
4454 ( ) =>
@@ -52,7 +62,8 @@ export const EuiAspectRatio: FunctionComponent<EuiAspectRatioProps> = ({
5262 ) ;
5363
5464 return React . cloneElement ( children , {
65+ ...rest ,
5566 className : classes ,
56- style : { ...children . props . style , ...euiAspectRatioStyle } ,
67+ style : { ...children . props . style , ...euiAspectRatioStyle , ... style } ,
5768 } ) ;
5869} ;
0 commit comments