Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add showIndicators and showNavigators properties to carousel co… #3231

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions components/doc/carousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,24 @@ const responsiveOptions = [
<td>false</td>
<td>Defines if scrolling would be infinite.</td>
</tr>
<tr>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please update \api-generator\components\carousel.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please update \api-generator\components\carousel.js
Thank you for your kind reminder @melloware. I added the necessary attributes to the file as you specified.

<td>showIndicators</td>
<td>boolean</td>
<td>false</td>
<td>Whether to display indicator container.</td>
</tr>
<tr>
<td>showNavigators</td>
<td>boolean</td>
<td>true</td>
<td>Whether to display navigation buttons in container.</td>
</tr>
<tr>
<td>circular</td>
<td>boolean</td>
<td>false</td>
<td>Defines if scrolling would be infinite.</td>
</tr>
<tr>
<td>autoplayInterval</td>
<td>number</td>
Expand Down
10 changes: 6 additions & 4 deletions components/lib/carousel/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ export const Carousel = React.memo(

return (
<div className={className}>
{backwardNavigator}
{props.showNavigators ? backwardNavigator : null}
<div className="p-carousel-items-content" style={{ height: height }} onTouchStart={onTouchStart} onTouchMove={onTouchMove} onTouchEnd={onTouchEnd}>
<div ref={itemsContainerRef} className="p-carousel-items-container" onTransitionEnd={onTransitionEnd}>
{items}
</div>
</div>
{forwardNavigator}
{props.showNavigators ? forwardNavigator : null}
</div>
);
};
Expand Down Expand Up @@ -531,7 +531,7 @@ export const Carousel = React.memo(
{header}
<div className={contentClassName}>
{content}
{indicators}
{!props.showIndicators ? indicators : null}
</div>
{footer}
</div>
Expand Down Expand Up @@ -562,5 +562,7 @@ Carousel.defaultProps = {
contentClassName: null,
containerClassName: null,
indicatorsContentClassName: null,
onPageChange: null
onPageChange: null,
showIndicators: false,
showNavigators: true
};
2 changes: 2 additions & 0 deletions components/lib/carousel/carousel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface CarouselProps extends Omit<React.DetailedHTMLProps<React.HTMLAt
indicatorsContentClassName?: string;
onPageChange?(e: CarouselPageChangeParams): void;
children?: React.ReactNode;
showNavigators: boolean;
showIndicators: boolean;
}

export declare class Carousel extends React.Component<CarouselProps, any> {
Expand Down