fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): inherit color for icon Approved-by: Bianca Widstam Approved-by: Christel Westerberg
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { cx } from "class-variance-authority"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
|
|
|
import { useCarousel } from "./CarouselContext"
|
|
|
|
import styles from "./carousel.module.css"
|
|
|
|
import type { CarouselButtonProps } from "./types"
|
|
|
|
export function CarouselPrevious({ className }: CarouselButtonProps) {
|
|
const { scrollPrev, canScrollPrev } = useCarousel()
|
|
|
|
const intl = useIntl()
|
|
|
|
if (!canScrollPrev()) return null
|
|
|
|
return (
|
|
<span className={cx(styles.buttonWrapper, styles.previous, className)}>
|
|
<IconButton
|
|
variant="Elevated"
|
|
onPress={scrollPrev}
|
|
aria-label={intl.formatMessage({
|
|
id: "carousel.previousSlide",
|
|
defaultMessage: "Previous slide",
|
|
})}
|
|
iconName="arrow_back"
|
|
/>
|
|
</span>
|
|
)
|
|
}
|
|
|
|
export function CarouselNext({ className }: CarouselButtonProps) {
|
|
const { scrollNext, canScrollNext } = useCarousel()
|
|
|
|
const intl = useIntl()
|
|
|
|
if (!canScrollNext()) return null
|
|
|
|
return (
|
|
<span className={cx(styles.buttonWrapper, styles.next, className)}>
|
|
<IconButton
|
|
variant="Elevated"
|
|
onPress={scrollNext}
|
|
aria-label={intl.formatMessage({
|
|
id: "carousel.nextSlide",
|
|
defaultMessage: "Next slide",
|
|
})}
|
|
iconName="arrow_forward"
|
|
/>
|
|
</span>
|
|
)
|
|
}
|