Skip to content

Commit 221d1b2

Browse files
committed
refactor: reorganize Slide component structure and improve type definitions for clarity and maintainability
1 parent 120127e commit 221d1b2

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

src/components/Slide/Slide.css

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
.carousel__slide {
2-
flex-shrink: 0;
3-
margin: 0;
4-
2+
align-items: center;
53
display: flex;
4+
flex-shrink: 0;
65
justify-content: center;
7-
align-items: center;
8-
9-
/* Fix iOS scrolling #22 */
6+
margin: 0;
107
transform: translateZ(0);
118
}

src/components/Slide/Slide.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
import {
2-
defineComponent,
3-
inject,
4-
h,
5-
SetupContext,
62
computed,
7-
ComputedRef,
3+
defineComponent,
84
getCurrentInstance,
9-
onUnmounted,
10-
provide,
11-
useId,
5+
h,
6+
inject,
127
onMounted,
8+
onUnmounted,
139
onUpdated,
14-
DeepReadonly,
10+
provide,
1511
ref,
12+
useId,
1613
} from 'vue'
1714

1815
import { injectCarousel } from '@/shared'
1916
import { disableChildrenTabbing } from '@/utils'
2017

2118
import { SlideProps } from './Slide.types'
2219

20+
import type { ComputedRef, DeepReadonly, SetupContext } from 'vue'
21+
2322
export const Slide = defineComponent({
2423
name: 'CarouselSlide',
2524
props: {
26-
isClone: {
27-
type: Boolean,
28-
default: false,
29-
},
30-
position: {
31-
type: String,
32-
default: undefined,
33-
},
3425
id: {
3526
type: String,
3627
default: (props: { isClone?: boolean }) => (props.isClone ? undefined : useId()),
@@ -39,6 +30,14 @@ export const Slide = defineComponent({
3930
type: Number,
4031
default: undefined,
4132
},
33+
isClone: {
34+
type: Boolean,
35+
default: false,
36+
},
37+
position: {
38+
type: String,
39+
default: undefined,
40+
},
4241
},
4342
setup(props: DeepReadonly<SlideProps>, { attrs, slots, expose }: SetupContext) {
4443
const carousel = inject(injectCarousel)

src/components/Slide/Slide.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export interface SlideProps {
1+
export type SlideProps = {
22
id?: string
3-
position?: 'before' | 'after'
43
index: number
54
isClone?: boolean
5+
position?: 'before' | 'after'
66
}

0 commit comments

Comments
 (0)