* feat(BOOK-293): Adjusted padding of the buttons to match Figma design * feat(BOOK-293): Updated variants for IconButton * feat(BOOK-113): Updated focus indicators on buttons and added default focus ring color * feat(BOOK-293): Replaced buttons inside booking widget Approved-by: Christel Westerberg
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
"use client"
|
|
|
|
import { cx } from "class-variance-authority"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
|
|
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",
|
|
})}
|
|
>
|
|
<MaterialIcon color="Icon/Interactive/Default" icon="arrow_back" />
|
|
</IconButton>
|
|
</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",
|
|
})}
|
|
>
|
|
<MaterialIcon color="Icon/Interactive/Default" icon="arrow_forward" />
|
|
</IconButton>
|
|
</span>
|
|
)
|
|
}
|