Skip to content

Commit

Permalink
feat(Carousel): expose sub-components & more thumbnail customization
Browse files Browse the repository at this point in the history
  • Loading branch information
zettca committed Jul 21, 2023
1 parent df3cde3 commit 6d413f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
30 changes: 0 additions & 30 deletions packages/core/src/components/Carousel/CarouselThumbnail.tsx

This file was deleted.

16 changes: 11 additions & 5 deletions packages/core/src/components/Carousel/CarouselThumbnails.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { CSSProperties, MouseEvent, forwardRef } from "react";
import { HvBaseProps } from "@core/types";
import { HvPaginationProps, HvStack } from "..";
import { HvButton, HvButtonProps, HvPaginationProps, HvStack } from "..";
import { HvCarouselClasses, HvCarouselProps } from ".";
import { useClasses } from "./Carousel.styles";
import { HvCarouselThumbnail } from "./CarouselThumbnail";

interface HvCarouselThumbnailsProps
extends HvBaseProps<HTMLDivElement, "children">,
Expand All @@ -15,6 +14,7 @@ interface HvCarouselThumbnailsProps
event: MouseEvent<HTMLButtonElement>,
index: number
) => void;
thumbnailProps?: Partial<HvButtonProps>;
}

export const HvCarouselThumbnails = forwardRef<
Expand All @@ -29,6 +29,7 @@ export const HvCarouselThumbnails = forwardRef<
width,
renderThumbnail,
onThumbnailClick,
thumbnailProps,
...others
} = props;
const { classes, cx } = useClasses(classesProp);
Expand All @@ -40,14 +41,19 @@ export const HvCarouselThumbnails = forwardRef<
<div ref={ref} className={cx(classes.panel, className)} {...others}>
<HvStack direction="row" spacing="xs">
{Array.from(Array(numSlides)).map((doc, i) => (
<HvCarouselThumbnail
<HvButton
icon
key={`thumbnail-${i}`}
style={{ width }}
selected={i === selectedIndex}
variant="secondaryGhost"
className={cx(classes.thumbnail, {
[classes.thumbnailSelected]: i === selectedIndex,
})}
onClick={(event) => onThumbnailClick?.(event, i)}
{...thumbnailProps}
>
{renderThumbnail?.(i)}
</HvCarouselThumbnail>
</HvButton>
))}
</HvStack>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/Carousel/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from "./Carousel";
export * from "./CarouselSlide";
export * from "./CarouselControls";
export * from "./CarouselThumbnails";

0 comments on commit 6d413f5

Please sign in to comment.