-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(carousel): add carousel widget (#762)
Co-authored-by: Marc Güell Segarra <[email protected]>
- Loading branch information
1 parent
62e4f5d
commit 14fb225
Showing
3 changed files
with
47 additions
and
0 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,42 @@ | ||
import { WidgetProps } from "@/types"; | ||
import { Carousel as CarouselOoui, Group as GroupOoui } from "@gisce/ooui"; | ||
import { Carousel as AntCarousel, theme } from "antd"; | ||
import Container from "@/widgets/containers/Container"; | ||
import styled from "styled-components"; | ||
|
||
const { defaultAlgorithm, defaultSeed } = theme; | ||
|
||
const mapToken = defaultAlgorithm(defaultSeed); | ||
|
||
type CarouselProps = Omit<WidgetProps, "ooui"> & { | ||
ooui: CarouselOoui; | ||
responsiveBehaviour?: boolean; | ||
}; | ||
|
||
export const Carousel = (props: CarouselProps) => { | ||
const { ooui, responsiveBehaviour = false } = props; | ||
|
||
return ( | ||
<CustomCarousel autoplay={ooui.autoPlay} dots autoplaySpeed={5000}> | ||
{ooui.items.map((group: GroupOoui, index: number) => ( | ||
<Container | ||
key={index} | ||
container={group.container} | ||
responsiveBehaviour={responsiveBehaviour} | ||
/> | ||
))} | ||
</CustomCarousel> | ||
); | ||
}; | ||
|
||
const CustomCarousel = styled(AntCarousel)` | ||
.slick-dots li button { | ||
background-color: ${mapToken.colorPrimary}; | ||
} | ||
.slick-dots li.slick-active button { | ||
background-color: ${mapToken.colorPrimary}; | ||
} | ||
.slick-dots-bottom { | ||
bottom: -15px; | ||
} | ||
`; |