refactor(icons): migrate workspace to Icones
This commit is contained in:
@@ -5,7 +5,10 @@ import useEmblaCarousel, {
|
||||
|
||||
import { cn } from "@workspace/ui/lib/utils"
|
||||
import { Button } from "@workspace/ui/components/button"
|
||||
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
|
||||
import {
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from "@workspace/ui/components/icon"
|
||||
import { LocalizedText, uiMessages } from "./i18n"
|
||||
|
||||
type CarouselApi = UseEmblaCarouselType[1]
|
||||
@@ -60,10 +63,10 @@ function Carousel({
|
||||
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
||||
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
||||
|
||||
const onSelect = React.useCallback((api: CarouselApi) => {
|
||||
if (!api) return
|
||||
setCanScrollPrev(api.canScrollPrev())
|
||||
setCanScrollNext(api.canScrollNext())
|
||||
const onSelect = React.useCallback((carouselApi: CarouselApi) => {
|
||||
if (!carouselApi) return
|
||||
setCanScrollPrev(carouselApi.canScrollPrev())
|
||||
setCanScrollNext(carouselApi.canScrollNext())
|
||||
}, [])
|
||||
|
||||
const scrollPrev = React.useCallback(() => {
|
||||
@@ -103,20 +106,36 @@ function Carousel({
|
||||
}
|
||||
}, [api, onSelect])
|
||||
|
||||
const contextValue = React.useMemo<CarouselContextProps>(
|
||||
() => ({
|
||||
carouselRef,
|
||||
api,
|
||||
opts,
|
||||
orientation:
|
||||
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
||||
scrollPrev,
|
||||
scrollNext,
|
||||
canScrollPrev,
|
||||
canScrollNext,
|
||||
plugins,
|
||||
setApi,
|
||||
}),
|
||||
[
|
||||
api,
|
||||
canScrollNext,
|
||||
canScrollPrev,
|
||||
carouselRef,
|
||||
opts,
|
||||
orientation,
|
||||
plugins,
|
||||
scrollNext,
|
||||
scrollPrev,
|
||||
setApi,
|
||||
]
|
||||
)
|
||||
|
||||
return (
|
||||
<CarouselContext.Provider
|
||||
value={{
|
||||
carouselRef,
|
||||
api: api,
|
||||
opts,
|
||||
orientation:
|
||||
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
||||
scrollPrev,
|
||||
scrollNext,
|
||||
canScrollPrev,
|
||||
canScrollNext,
|
||||
}}
|
||||
>
|
||||
<CarouselContext.Provider value={contextValue}>
|
||||
<div
|
||||
onKeyDownCapture={handleKeyDown}
|
||||
className={cn("relative", className)}
|
||||
|
||||
Reference in New Issue
Block a user