-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
607144c
commit b4c7fca
Showing
5 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import onsCustomElement from "@Util/onsCustomElement"; | ||
import { SxProps } from "@mui/material"; | ||
import React from "react"; | ||
|
||
const deprecated = { | ||
index: "activeIndex", | ||
}; | ||
|
||
const Element = onsCustomElement<HTMLElement, HTMLCarousel>("ons-carousel", { deprecated })({}); | ||
|
||
const Carousel = React.forwardRef<HTMLElement, HTMLCarousel>((props, ref) => { | ||
const { itemWidth, itemHeight, ...rest } = props; | ||
|
||
// string values for itemWidth and itemHeight are deprecated but handle them | ||
// safely anyway to avoid breaking user code | ||
const stringify = (x) => (typeof x === "number" ? `${x}px` : x); | ||
const realItemWidth = stringify(itemWidth); | ||
const realItemHeight = stringify(itemHeight); | ||
|
||
return ( | ||
<Element itemWidth={realItemWidth} itemHeight={realItemHeight} ref={ref} {...rest}> | ||
{props.children} | ||
</Element> | ||
); | ||
}); | ||
|
||
interface HTMLCarousel extends React.PropsWithChildren { | ||
sx?: SxProps; | ||
direction?: "horizontal" | "vertical"; | ||
fullscreen?: boolean; | ||
overscrollable?: boolean; | ||
centered?: boolean; | ||
itemWidth?: string; | ||
itemHeight?: string; | ||
autoScroll?: boolean; | ||
autoScrollRatio?: number; | ||
swipeable?: boolean; | ||
disabled?: boolean; | ||
activeIndex?: number; | ||
index?: number; | ||
autoRefresh?: boolean; | ||
onPreChange?: Function; | ||
onPostChange?: Function; | ||
onRefresh?: Function; | ||
onOverscroll?: Function; | ||
animation?: string; | ||
animationOptions?: object; | ||
onSwipe?: Function; | ||
} | ||
|
||
export { Carousel }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import onsCustomElement from "@Util/onsCustomElement"; | ||
import { SxProps } from "@mui/material"; | ||
|
||
const CarouselItem = onsCustomElement<HTMLElement, HTMLCarouselItem>("ons-carousel-item")({}); | ||
|
||
interface HTMLCarouselItem extends React.PropsWithChildren { | ||
sx?: SxProps; | ||
modifier?: string; | ||
} | ||
|
||
export { HTMLCarouselItem, CarouselItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters