Skip to content

Commit

Permalink
feat: new prop to center corousel component (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-rosa-jsm authored Dec 19, 2023
1 parent cdd4a91 commit e4e10a9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export namespace Components {
interface AtomCarousel {
"autoplay"?: boolean;
"autoplayDelay"?: AutoplayOptions['delay'];
"centerInsufficientSlides"?: boolean;
"freeMode"?: boolean;
"loop"?: boolean;
"navigation"?: boolean;
Expand Down Expand Up @@ -496,6 +497,7 @@ declare namespace LocalJSX {
interface AtomCarousel {
"autoplay"?: boolean;
"autoplayDelay"?: AutoplayOptions['delay'];
"centerInsufficientSlides"?: boolean;
"freeMode"?: boolean;
"loop"?: boolean;
"navigation"?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/carousel/carousel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('AtomCarousel', () => {
it('should render component with passed props', async () => {
const page = await newSpecPage({
components: [AtomCarousel],
html: `<atom-carousel pagination="false" navigation="false" slides-per-group="4" slides-per-view="2">
html: `<atom-carousel center-insufficient-slides="true" pagination="false" navigation="false" slides-per-group="4" slides-per-view="2">
<atom-carousel-item> Slide 1</atom-carousel-item>
<atom-carousel-item> Slide 2</atom-carousel-item>
</atom-carousel>`,
Expand All @@ -42,6 +42,7 @@ describe('AtomCarousel', () => {
expect(swiperContainer?.outerHTML).not.toContain('navigation')
expect(swiperContainer?.outerHTML).toContain('slides-per-view="2"')
expect(swiperContainer?.outerHTML).toContain('slides-per-group="4"')
expect(swiperContainer?.outerHTML).toContain('center-insufficient-slides')
})

it('should render component with default props', async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/carousel/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class AtomCarousel {
@Prop({ mutable: true })
autoplayDelay?: AutoplayOptions['delay']
@Prop({ mutable: true })
centerInsufficientSlides?: boolean = false
@Prop({ mutable: true })
freeMode?: boolean
@Prop({ mutable: true })
loop?: boolean
Expand Down Expand Up @@ -112,6 +114,7 @@ export class AtomCarousel {
autoplay-delay={this.autoplayDelay}
injectStyles={this.injectStyles}
touch-start-prevent-default='false'
center-insufficient-slides={this.centerInsufficientSlides}
></swiper-container>
</Host>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const CarouselStoryArgs = {
category: Category.PROPERTIES,
},
},
centerInsufficientSlides: {
description:
'When enabled it center slides if the amount of slides less than slidesPerView',
defaultValue: { summary: false },

table: {
category: Category.PROPERTIES,
},
},
freeMode: {
description: 'Set to `true` to enable free mode functionality',
defaultValue: { summary: false },
Expand Down

0 comments on commit e4e10a9

Please sign in to comment.