mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
22 lines
578 B
TypeScript
22 lines
578 B
TypeScript
import * as React from 'react';
|
|
import { IconProps } from './index';
|
|
|
|
type TransformInformation = Pick<IconProps, 'rotate' | 'flip'>;
|
|
|
|
export function getComputedSvgStyle(
|
|
{ rotate, flip }: TransformInformation,
|
|
svgStyle: React.CSSProperties,
|
|
): React.CSSProperties {
|
|
|
|
if (!(rotate || flip)) {
|
|
return { ...svgStyle };
|
|
}
|
|
|
|
return {
|
|
transform: `${rotate ? `rotate(${rotate}deg)` : ''} `
|
|
+ `${(flip === 'horizontal' || flip === 'both') ? `scaleX(-1)` : ''} `
|
|
+ `${(flip === 'vertical' || flip === 'both') ? `scaleY(-1)` : ''}`,
|
|
...svgStyle,
|
|
};
|
|
}
|