From bd87079e121dbbaf9a0c545af8817bacf97d277e Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Thu, 14 Apr 2022 09:54:45 +0800 Subject: [PATCH] feat(image): add new features (#5479) * feat(image): add new features * fix: lint error * update test * update code * update docs * perf: reset currentIndex after close * update code * update code * update code * update code * update code * add rootClassName props * fix lint --- components/_util/EventInterface.ts | 1 + components/image/PreviewGroup.tsx | 19 +++ .../__tests__/__snapshots__/demo.test.js.snap | 56 ++++++-- components/image/demo/index.vue | 5 +- .../image/demo/preview-group-visible.vue | 2 +- components/image/demo/preview-src.vue | 31 ++++ components/image/index.en-US.md | 5 + components/image/index.tsx | 45 +++++- components/image/index.zh-CN.md | 5 + components/vc-dialog/Dialog.tsx | 3 +- components/vc-dialog/IDialogPropTypes.ts | 3 +- components/vc-image/src/Image.tsx | 96 +++++++++---- components/vc-image/src/Preview.tsx | 107 +++++++++----- components/vc-image/src/PreviewGroup.tsx | 135 +++++++++++++++--- 14 files changed, 413 insertions(+), 100 deletions(-) create mode 100644 components/image/demo/preview-src.vue diff --git a/components/_util/EventInterface.ts b/components/_util/EventInterface.ts index c8a4551c2..b72777cf5 100644 --- a/components/_util/EventInterface.ts +++ b/components/_util/EventInterface.ts @@ -4,6 +4,7 @@ export type KeyboardEventHandler = (e: KeyboardEvent) => void; export type CompositionEventHandler = (e: CompositionEvent) => void; export type ClipboardEventHandler = (e: ClipboardEvent) => void; export type ChangeEventHandler = (e: ChangeEvent) => void; +export type WheelEventHandler = (e: WheelEvent) => void; export type ChangeEvent = Event & { target: { value?: string | undefined; diff --git a/components/image/PreviewGroup.tsx b/components/image/PreviewGroup.tsx index 0666e2399..47cdc49e6 100644 --- a/components/image/PreviewGroup.tsx +++ b/components/image/PreviewGroup.tsx @@ -2,6 +2,24 @@ import PreviewGroup from '../vc-image/src/PreviewGroup'; import { computed, defineComponent } from 'vue'; import useConfigInject from '../_util/hooks/useConfigInject'; +import RotateLeftOutlined from '@ant-design/icons-vue/RotateLeftOutlined'; +import RotateRightOutlined from '@ant-design/icons-vue/RotateRightOutlined'; +import ZoomInOutlined from '@ant-design/icons-vue/ZoomInOutlined'; +import ZoomOutOutlined from '@ant-design/icons-vue/ZoomOutOutlined'; +import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; +import LeftOutlined from '@ant-design/icons-vue/LeftOutlined'; +import RightOutlined from '@ant-design/icons-vue/RightOutlined'; + +export const icons = { + rotateLeft: , + rotateRight: , + zoomIn: , + zoomOut: , + close: , + left: , + right: , +}; + const InternalPreviewGroup = defineComponent({ name: 'AImagePreviewGroup', inheritAttrs: false, @@ -13,6 +31,7 @@ const InternalPreviewGroup = defineComponent({ return ( diff --git a/components/image/__tests__/__snapshots__/demo.test.js.snap b/components/image/__tests__/__snapshots__/demo.test.js.snap index a357eefd0..9ec6faf07 100644 --- a/components/image/__tests__/__snapshots__/demo.test.js.snap +++ b/components/image/__tests__/__snapshots__/demo.test.js.snap @@ -3,8 +3,11 @@ exports[`renders ./components/image/demo/basic.vue correctly 1`] = `
- +
+
Preview
+
+ `; exports[`renders ./components/image/demo/controlled-preview.vue correctly 1`] = ` @@ -13,7 +16,9 @@ exports[`renders ./components/image/demo/controlled-preview.vue correctly 1`] =
- +
+
Preview
+
@@ -22,8 +27,11 @@ exports[`renders ./components/image/demo/controlled-preview.vue correctly 1`] = exports[`renders ./components/image/demo/fallback.vue correctly 1`] = `
- +
+
Preview
+
+ `; exports[`renders ./components/image/demo/placeholder.vue correctly 1`] = ` @@ -37,7 +45,9 @@ exports[`renders ./components/image/demo/placeholder.vue correctly 1`] = ` - +
+
Preview
+
@@ -52,35 +62,61 @@ exports[`renders ./components/image/demo/placeholder.vue correctly 1`] = ` exports[`renders ./components/image/demo/preview-group.vue correctly 1`] = `
- +
+
Preview
+
+
- +
+
Preview
+
+ + `; exports[`renders ./components/image/demo/preview-group-visible.vue correctly 1`] = `
- +
+
Preview
+
+
- +
+
Preview
+
- +
+
Preview
+
- +
+
Preview
+
`; + +exports[`renders ./components/image/demo/preview-src.vue correctly 1`] = ` +
+ +
+
Preview
+
+
+ +`; diff --git a/components/image/demo/index.vue b/components/image/demo/index.vue index f7989c94c..5fc0911b8 100644 --- a/components/image/demo/index.vue +++ b/components/image/demo/index.vue @@ -4,8 +4,9 @@ - + + @@ -13,6 +14,7 @@ import Basic from './basic.vue'; import Fallback from './fallback.vue'; import Placeholder from './placeholder.vue'; +import previewSrc from './preview-src.vue'; import PreviewGroup from './preview-group.vue'; import ControlledPreview from './controlled-preview.vue'; import previewGroupVisibleVue from './preview-group-visible.vue'; @@ -26,6 +28,7 @@ export default defineComponent({ components: { Basic, Fallback, + previewSrc, Placeholder, PreviewGroup, ControlledPreview, diff --git a/components/image/demo/preview-group-visible.vue b/components/image/demo/preview-group-visible.vue index 75e386293..1e3a2f283 100644 --- a/components/image/demo/preview-group-visible.vue +++ b/components/image/demo/preview-group-visible.vue @@ -18,7 +18,7 @@ Preview a collection from one image.