Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions packages/widgets/src/components/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import Slider, { ResponsiveObject, Settings } from 'react-slick';

type BuilderBlockType = BuilderElement;

const CarouselArrow = ({
currentSlide,
slideCount,
children,
...rest
}: React.HTMLAttributes<HTMLDivElement> & {
currentSlide?: number;
slideCount?: number;
}) => <div {...rest}>{children}</div>;

interface CarouselProps {
slides: Array<
React.ReactNode | { content: BuilderBlockType[] } /* BuilderBlock <- export this type */
Expand Down Expand Up @@ -106,26 +116,31 @@ export class CarouselComponent extends React.Component<CarouselProps> {
focusOnSelect={this.props.focusOnSelect}
// TODO: on change emit event on element?
// renderBottomCenterControls={this.props.hideDots ? () => null : undefined}

arrows={
!!(
(this.props.prevButton && this.props.prevButton.length) ||
(this.props.nextButton && this.props.nextButton.length)
)
}
// OOF!!
nextArrow={
<div>
<CarouselArrow>
<BuilderBlocks
parentElementId={this.props.builderBlock.id}
dataPath="component.options.prevButton"
blocks={this.props.prevButton}
/>
</div>
</CarouselArrow>
}
// OOF!!
prevArrow={
<div>
<CarouselArrow>
<BuilderBlocks
parentElementId={this.props.builderBlock.id}
dataPath="component.options.nextButton"
blocks={this.props.nextButton}
/>
</div>
</CarouselArrow>
}
{...this.props.slickProps}
>
Expand Down
Loading