-
Notifications
You must be signed in to change notification settings - Fork 118
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
bdc3d9c
commit 3655209
Showing
6 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
12 changes: 8 additions & 4 deletions
12
packages/react/src/components/carousel/carousel-control.tsx
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { mergeProps } from '@zag-js/react' | ||
import { forwardRef } from 'react' | ||
import { type HTMLProps, type PolymorphicProps, ark } from '../factory' | ||
import { carouselAnatomy } from './carousel.anatomy' | ||
import { useCarouselContext } from './use-carousel-context' | ||
|
||
export interface CarouselControlBaseProps extends PolymorphicProps {} | ||
export interface CarouselControlProps extends HTMLProps<'div'>, CarouselControlBaseProps {} | ||
|
||
export const CarouselControl = forwardRef<HTMLDivElement, CarouselControlProps>((props, ref) => ( | ||
<ark.div {...carouselAnatomy.build().control.attrs} {...props} ref={ref} /> | ||
)) | ||
export const CarouselControl = forwardRef<HTMLDivElement, CarouselControlProps>((props, ref) => { | ||
const carousel = useCarouselContext() | ||
const mergedProps = mergeProps(carousel.getControlProps(), props) | ||
|
||
return <ark.div {...mergedProps} {...props} ref={ref} /> | ||
}) | ||
|
||
CarouselControl.displayName = 'CarouselControl' |
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
import { anatomy } from '@zag-js/carousel' | ||
|
||
export const carouselAnatomy = anatomy.extendWith('control') | ||
export { anatomy as carouselAnatomy } from '@zag-js/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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { mergeProps } from '@zag-js/solid' | ||
import { type HTMLProps, type PolymorphicProps, ark } from '../factory' | ||
import { carouselAnatomy } from './carousel.anatomy' | ||
import { useCarouselContext } from './use-carousel-context' | ||
|
||
export interface CarouselControlBaseProps extends PolymorphicProps<'div'> {} | ||
export interface CarouselControlProps extends HTMLProps<'div'>, CarouselControlBaseProps {} | ||
|
||
export const CarouselControl = (props: CarouselControlProps) => { | ||
const mergedProps = mergeProps(() => carouselAnatomy.build().control.attrs, props) | ||
const api = useCarouselContext() | ||
const mergedProps = mergeProps(() => api().getControlProps(), props) | ||
|
||
return <ark.div {...mergedProps} /> | ||
} |
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
import { anatomy } from '@zag-js/carousel' | ||
|
||
export const carouselAnatomy = anatomy.extendWith('control') | ||
export { anatomy as carouselAnatomy } from '@zag-js/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
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
import { anatomy } from '@zag-js/carousel' | ||
|
||
export const carouselAnatomy = anatomy.extendWith('control') | ||
export { anatomy as carouselAnatomy } from '@zag-js/carousel' |