Skip to content

Commit e8b9aa6

Browse files
author
Rogerio Felix
committed
Refactor NextElasticCarousel component to use TypeScript and update import statements
1 parent fc46d4e commit e8b9aa6

File tree

1 file changed

+55
-61
lines changed

1 file changed

+55
-61
lines changed
Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,109 @@
11
/* eslint no-unused-vars: 0 */ // --> OFF
22
/* eslint no-undef: 0 */ // --> OFF
3-
import * as React from "react";
3+
import * as React from 'react'
44

55
export type RenderArrowProps = {
6-
type: "PREV" | "NEXT";
7-
onClick: () => void;
8-
isEdge: boolean;
9-
};
6+
type: 'PREV' | 'NEXT'
7+
onClick: () => void
8+
isEdge: boolean
9+
}
1010

1111
export type RenderPaginationProps = {
12-
pages: number[];
13-
activePage: number;
12+
pages: number[]
13+
activePage: number
1414
// The onClick event that sets the state of the carousel and sends
1515
// it to a specific page.
16-
onClick: (indicatorId: string) => void;
17-
};
16+
onClick: (indicatorId: string) => void
17+
}
1818

1919
export type ItemObject = {
2020
// Children's props
21-
object: any;
22-
index: number;
23-
};
21+
object: any
22+
index: number
23+
}
2424

2525
export type Breakpoint = {
26-
itemsToScroll: number;
27-
itemsToShow: number;
28-
};
26+
itemsToScroll: number
27+
itemsToShow: number
28+
}
2929

30-
export interface ReactElasticCarouselProps {
31-
children: React.ReactNode;
30+
export interface NextElasticCarouselProps {
31+
children: React.ReactNode
3232

33-
className?: string;
33+
className?: string
3434
// Defaults to 1
35-
itemsToShow?: number;
35+
itemsToShow?: number
3636
// Defaults to false
37-
verticalMode?: boolean;
37+
verticalMode?: boolean
3838
// Defaults to false
39-
isRTL: boolean;
39+
isRTL: boolean
4040
// Defaults to true
41-
pagination?: boolean;
41+
pagination?: boolean
4242
// Defaults to 500
43-
transitionMs?: number;
43+
transitionMs?: number
4444
// Defaults to "ease"
45-
easing?: string;
45+
easing?: string
4646
// Defaults to "ease"
47-
tiltEasing?: string;
47+
tiltEasing?: string
4848
// Defaults to true.
49-
enableTilt?: boolean;
49+
enableTilt?: boolean
5050
// Defaults to 1
51-
itemsToScroll?: number;
51+
itemsToScroll?: number
5252
// Collection of objects with a width, itemsToShow and itemsToScroll
5353
breakPoints?: {
54-
width: number;
55-
itemsToShow?: number;
56-
itemsToScroll?: number;
57-
}[];
54+
width: number
55+
itemsToShow?: number
56+
itemsToScroll?: number
57+
}[]
5858
// Defaults to 0
59-
initialActiveIndex?: number;
59+
initialActiveIndex?: number
6060
// Defaults to 0
61-
initialFirstItem?: number;
61+
initialFirstItem?: number
6262
// Defaults to true
63-
showArrows?: boolean;
63+
showArrows?: boolean
6464
// Defaults to false (not compatible with verticalMode yet !)
65-
showEmptySlots?: boolean;
65+
showEmptySlots?: boolean
6666
// Defaults to true
67-
disableArrowsOnEnd?: boolean;
67+
disableArrowsOnEnd?: boolean
6868
// Defaults to boolean
69-
focusOnSelect?: boolean;
69+
focusOnSelect?: boolean
7070
// Function to generate your own navigation arrows.
71-
renderArrow?: (props: RenderArrowProps) => void;
71+
renderArrow?: (props: RenderArrowProps) => void
7272
// Function to generate your own pagination component.
73-
renderPagination?: (props: RenderPaginationProps) => JSX.Element;
73+
renderPagination?: (props: RenderPaginationProps) => JSX.Element
7474
// Defaults to "CENTER"
75-
itemPosition?: "START" | "CENTER" | "END";
75+
itemPosition?: 'START' | 'CENTER' | 'END'
7676
// A padding for each element - Defaults to [0,0,0,0]
77-
itemPadding?: number[];
77+
itemPadding?: number[]
7878
// A margin at the beginning and at the end of the carousel - Defaults to 0 (not compatible with verticalMode yet !)
79-
outerSpacing?: number;
79+
outerSpacing?: number
8080
// Enable or disable swipe - Defaults to true
81-
enableSwipe?: boolean;
81+
enableSwipe?: boolean
8282
/** Enable or disable mouse swipe */
83-
enableMouseSwipe?: boolean;
83+
enableMouseSwipe?: boolean
8484
/** Prevent page scroll on touchmove.
8585
* Use this to stop the browser from scrolling while a user swipes.
8686
* More details: https://github.com/FormidableLabs/react-swipeable#preventdefaulttouchmoveevent-details
8787
*/
88-
preventDefaultTouchmoveEvent?: boolean;
88+
preventDefaultTouchmoveEvent?: boolean
8989
// Enable or disable auto play - Defaults to true
90-
enableAutoPlay?: boolean;
90+
enableAutoPlay?: boolean
9191
/** Set auto play speed (ms) - Defaults to 2000 */
92-
autoPlaySpeed?: number;
92+
autoPlaySpeed?: number
9393
// A callback for the change of an item
94-
onChange?: (currentItemObject: ItemObject, currentPageIndex: number) => void;
94+
onChange?: (currentItemObject: ItemObject, currentPageIndex: number) => void
9595
// A callback for the beginning of the next transition
96-
onNextStart?: (
97-
prevItemObject: ItemObject,
98-
nextItemObject: ItemObject
99-
) => void;
96+
onNextStart?: (prevItemObject: ItemObject, nextItemObject: ItemObject) => void
10097
// A callback for the beginning of the prev transition
101-
onPrevStart?: (
102-
prevItemObject: ItemObject,
103-
nextItemObject: ItemObject
104-
) => void;
98+
onPrevStart?: (prevItemObject: ItemObject, nextItemObject: ItemObject) => void
10599
// A callback for the end of the next transition
106-
onNextEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void;
100+
onNextEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void
107101
// A callback for the end of the prev transition
108-
onPrevEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void;
102+
onPrevEnd?: (nextItemObject: ItemObject, currentPageIndex: number) => void
109103
// A callback for the "slider-container" resize
110-
onResize?: (currentBreakpoint: Breakpoint) => void;
104+
onResize?: (currentBreakpoint: Breakpoint) => void
111105
}
112106

113-
declare class ReactElasticCarousel extends React.Component<ReactElasticCarouselProps> {}
107+
declare class NextElasticCarousel extends React.Component<NextElasticCarouselProps> {}
114108

115-
export default ReactElasticCarousel;
109+
export default NextElasticCarousel

0 commit comments

Comments
 (0)