-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-instantsearch): add
Carousel
layout component (#6321)
- Loading branch information
Showing
25 changed files
with
1,570 additions
and
55 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
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
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
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
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,36 @@ | ||
import { | ||
createCarouselComponent, | ||
generateCarouselId, | ||
} from 'instantsearch-ui-components'; | ||
import React, { createElement, Fragment, useRef } from 'react'; | ||
|
||
import type { | ||
CarouselProps as CarouselUiProps, | ||
Pragma, | ||
} from 'instantsearch-ui-components'; | ||
|
||
const CarouselUiComponent = createCarouselComponent({ | ||
createElement: createElement as Pragma, | ||
Fragment, | ||
}); | ||
|
||
export type CarouselProps<TObject extends Record<string, unknown>> = Omit< | ||
CarouselUiProps<TObject>, | ||
'listRef' | 'nextButtonRef' | 'previousButtonRef' | 'carouselIdRef' | ||
>; | ||
|
||
export function Carousel<TObject extends Record<string, unknown>>( | ||
props: CarouselProps<TObject> | ||
) { | ||
const carouselRefs: Pick< | ||
CarouselUiProps<TObject>, | ||
'listRef' | 'nextButtonRef' | 'previousButtonRef' | 'carouselIdRef' | ||
> = { | ||
listRef: useRef(null), | ||
nextButtonRef: useRef(null), | ||
previousButtonRef: useRef(null), | ||
carouselIdRef: useRef(generateCarouselId()), | ||
}; | ||
|
||
return <CarouselUiComponent {...carouselRefs} {...props} />; | ||
} |
Oops, something went wrong.