mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 23:00:20 +08:00
8f6f223f2d
* fix: image preview style * chore: code clean
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
import LeftOutlined from '@ant-design/icons/LeftOutlined';
|
|
import RightOutlined from '@ant-design/icons/RightOutlined';
|
|
import RotateLeftOutlined from '@ant-design/icons/RotateLeftOutlined';
|
|
import RotateRightOutlined from '@ant-design/icons/RotateRightOutlined';
|
|
import ZoomInOutlined from '@ant-design/icons/ZoomInOutlined';
|
|
import ZoomOutOutlined from '@ant-design/icons/ZoomOutOutlined';
|
|
import RcImage from 'rc-image';
|
|
import type { GroupConsumerProps } from 'rc-image/lib/PreviewGroup';
|
|
import * as React from 'react';
|
|
import { ConfigContext } from '../config-provider';
|
|
import { getTransitionName } from '../_util/motion';
|
|
|
|
// CSSINJS
|
|
import useStyle from './style';
|
|
|
|
export const icons = {
|
|
rotateLeft: <RotateLeftOutlined />,
|
|
rotateRight: <RotateRightOutlined />,
|
|
zoomIn: <ZoomInOutlined />,
|
|
zoomOut: <ZoomOutOutlined />,
|
|
close: <CloseOutlined />,
|
|
left: <LeftOutlined />,
|
|
right: <RightOutlined />,
|
|
};
|
|
|
|
const InternalPreviewGroup: React.FC<GroupConsumerProps> = ({
|
|
previewPrefixCls: customizePrefixCls,
|
|
preview,
|
|
...props
|
|
}) => {
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
const prefixCls = getPrefixCls('image', customizePrefixCls);
|
|
const previewPrefixCls = `${prefixCls}-preview`;
|
|
const rootPrefixCls = getPrefixCls();
|
|
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
|
|
|
const mergedPreview = React.useMemo(() => {
|
|
if (preview === false) {
|
|
return preview;
|
|
}
|
|
const _preview = typeof preview === 'object' ? preview : {};
|
|
|
|
return {
|
|
..._preview,
|
|
transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName),
|
|
maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName),
|
|
rootClassName: hashId,
|
|
};
|
|
}, [preview]);
|
|
|
|
return wrapSSR(
|
|
<RcImage.PreviewGroup
|
|
preview={mergedPreview}
|
|
previewPrefixCls={previewPrefixCls}
|
|
icons={icons}
|
|
{...props}
|
|
/>,
|
|
);
|
|
};
|
|
|
|
export default InternalPreviewGroup;
|