From cd306117aea122240c5d494768dd5adf2944747a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E7=88=B1vue=E7=9A=84=E5=B0=8F=E8=8F=9C=E9=B8=9F?= <282126990@qq.com> Date: Sun, 14 May 2023 17:47:43 +0800 Subject: [PATCH] feat(components): [carousel] If the carousel height is auto apply item height (#12388) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(components): [carousel] :height is auto and card direction vertical * fix(components): [carousel] :height is auto and card direction vertical * fix(components): [carousel] :height is auto and card direction 垂直 * feat(components): [carousel] height is adaptive when height is auto * feat(components): [carousel] height is adaptive when height is auto * fix(components): [carousel] :height is auto and card direction 垂直 * fix(components): [carousel] :height is auto and card direction 垂直 * fix(components): [carousel] :height is auto test.tsx * fix(components): [carousel] :height is auto and card direction * fix: delete zIndex * fix: delete ts type * fix: add test * fix: css modification * fix: delete doc inside * fix: Revise card width not adaptive * fix: Modify calcCardTranslate * fix: test * fix: calcCardTranslate * fix: remove redundant code --- docs/en-US/component/carousel.md | 10 ++ docs/examples/carousel/auto-height.vue | 43 ++++++++ docs/examples/carousel/vertical.vue | 12 +++ .../carousel/__tests__/carousel.test.tsx | 100 +++++++++++++++++- .../components/carousel/src/carousel-item.vue | 7 +- packages/components/carousel/src/carousel.vue | 9 +- packages/components/carousel/src/constants.ts | 1 + .../carousel/src/use-carousel-item.ts | 17 +-- .../components/carousel/src/use-carousel.ts | 21 ++++ packages/theme-chalk/src/carousel-item.scss | 8 ++ packages/theme-chalk/src/carousel.scss | 11 +- 11 files changed, 226 insertions(+), 13 deletions(-) create mode 100644 docs/examples/carousel/auto-height.vue diff --git a/docs/en-US/component/carousel.md b/docs/en-US/component/carousel.md index f6c4afa367..1789ec5b33 100644 --- a/docs/en-US/component/carousel.md +++ b/docs/en-US/component/carousel.md @@ -35,6 +35,16 @@ carousel/arrows ::: +## Auto height + +When the `height` of `carousel` is set to `auto`, the `carousel` height will be automatically set according to the height of the `carousel item` + +:::demo + +carousel/auto-height + +::: + ## Card mode When a page is wide enough but has limited height, you can activate card mode for carousels diff --git a/docs/examples/carousel/auto-height.vue b/docs/examples/carousel/auto-height.vue new file mode 100644 index 0000000000..16c4c142df --- /dev/null +++ b/docs/examples/carousel/auto-height.vue @@ -0,0 +1,43 @@ + + + diff --git a/docs/examples/carousel/vertical.vue b/docs/examples/carousel/vertical.vue index fca9beb58a..c50e0f1ab7 100644 --- a/docs/examples/carousel/vertical.vue +++ b/docs/examples/carousel/vertical.vue @@ -1,9 +1,21 @@