Skip to content

Commit 0d44a2d

Browse files
Merge pull request #15040 from IgniteUI/rivanova/feat-carousel-15025
feat(carousel): align with WC carousel
2 parents fe340b4 + 9a25554 commit 0d44a2d

File tree

8 files changed

+71
-42
lines changed

8 files changed

+71
-42
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 19.1.0
6+
### General
7+
- `IgxCarousel`
8+
- **Behavioral Changes** - the `maximumIndicatorsCount` input property now defaults to `10`.
9+
- **Deprecation** - `CarouselIndicatorsOrientation` enum members `top` and `bottom` have been deprecated and will be removed in a future version. Use `start` and `end` instead.
10+
511
## 19.0.0
612
### General
713
- `IgxFilteringService`, `IgxGridBaseDirective`

projects/igniteui-angular/src/lib/carousel/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ A walkthrough of how to get started can be found [here](https://www.infragistics
1717
| `vertical` | boolean | Controls should the carousel be rendered in vertical alignment. Defaults to `false`. |
1818
| `keyboardSupport` | boolean | Controls should the keyboard navigation should be supported. Defaults to `false`. |
1919
| `gesturesSupport` | boolean | Controls should the gestures should be supported. Defaults to `true`. |
20-
| `maximumIndicatorsCount` | number | The number of visible indicators. Defaults to `5`. |
21-
| `indicatorsOrientation` | CarouselIndicatorsOrientation | Controls whether the indicators should be previewed on top or on bottom of carousel. Defaults to `bottom`. |
20+
| `maximumIndicatorsCount` | number | The number of visible indicators. Defaults to `10`. |
21+
| `indicatorsOrientation` | CarouselIndicatorsOrientation | Controls the orientation of the indicators. Defaults to `end`. |
2222
| `animationType` | CarouselAnimationType | Controls what animation should be played when slides are changing. Defaults to `slide`. |
2323
| `total` | number | The number of slides the carousel currently has. |
2424
| `current` | number | The index of the slide currently showing. |

projects/igniteui-angular/src/lib/carousel/carousel.component.spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,20 +385,20 @@ describe('Carousel', () => {
385385
let indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture);
386386
expect(indicatorsContainer).toBeDefined();
387387

388-
carousel.indicatorsOrientation = CarouselIndicatorsOrientation.top;
388+
carousel.indicatorsOrientation = CarouselIndicatorsOrientation.start;
389389
fixture.detectChanges();
390390

391391
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture);
392392
expect(indicatorsContainer).toBeNull();
393-
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.top);
393+
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.start);
394394
expect(indicatorsContainer).toBeDefined();
395395

396-
carousel.indicatorsOrientation = CarouselIndicatorsOrientation.bottom;
396+
carousel.indicatorsOrientation = CarouselIndicatorsOrientation.end;
397397
fixture.detectChanges();
398398

399-
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.top);
399+
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.start);
400400
expect(indicatorsContainer).toBeNull();
401-
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.bottom);
401+
indicatorsContainer = HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.end);
402402
expect(indicatorsContainer).toBeDefined();
403403
});
404404

@@ -487,7 +487,7 @@ describe('Carousel', () => {
487487
expect(carousel.nativeElement.getAttribute('role')).toEqual(expectedRole);
488488
expect(carousel.nativeElement.getAttribute('aria-roledescription')).toEqual(expectedRoleDescription);
489489

490-
const indicators = carousel.nativeElement.querySelector(HelperTestFunctions.INDICATORS_BOTTOM_CLASS);
490+
const indicators = carousel.nativeElement.querySelector(HelperTestFunctions.INDICATORS_END_CLASS);
491491

492492
expect(indicators).toBeDefined();
493493
expect(indicators.getAttribute('role')).toEqual('tablist');
@@ -851,7 +851,7 @@ describe('Carousel', () => {
851851

852852
expect(carousel.total).toEqual(0);
853853
expect(HelperTestFunctions.getIndicatorsContainer(fixture)).toBeNull();
854-
expect(HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.top)).toBeNull();
854+
expect(HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.start)).toBeNull();
855855
expect(HelperTestFunctions.getNextButton(fixture)).toBeNull();
856856
expect(HelperTestFunctions.getPreviousButton(fixture)).toBeNull();
857857

@@ -862,7 +862,7 @@ describe('Carousel', () => {
862862

863863
expect(carousel.total).toEqual(2);
864864
expect(HelperTestFunctions.getIndicatorsContainer(fixture)).toBeDefined();
865-
expect(HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.top)).toBeDefined();
865+
expect(HelperTestFunctions.getIndicatorsContainer(fixture, CarouselIndicatorsOrientation.start)).toBeDefined();
866866
expect(HelperTestFunctions.getNextButton(fixture).hidden).toBeFalsy();
867867
expect(HelperTestFunctions.getPreviousButton(fixture).hidden).toBeFalsy();
868868
}));
@@ -1054,8 +1054,8 @@ class HelperTestFunctions {
10541054
public static BUTTON_ARROW_CLASS = '.igx-nav-arrow';
10551055
public static ACTIVE_SLIDE_CLASS = 'igx-slide--current';
10561056
public static PREVIOUS_SLIDE_CLASS = 'igx-slide--previous';
1057-
public static INDICATORS_TOP_CLASS = '.igx-carousel-indicators--top';
1058-
public static INDICATORS_BOTTOM_CLASS = '.igx-carousel-indicators--bottom';
1057+
public static INDICATORS_START_CLASS = '.igx-carousel-indicators--start';
1058+
public static INDICATORS_END_CLASS = '.igx-carousel-indicators--end';
10591059
public static INDICATORS_LABEL_CLASS = '.igx-carousel__label';
10601060
public static INDICATOR_CLASS = '.igx-carousel-indicators__indicator';
10611061
public static INDICATOR_DOT_CLASS = '.igx-nav-dot';
@@ -1079,26 +1079,26 @@ class HelperTestFunctions {
10791079
return prev.querySelector(HelperTestFunctions.BUTTON_ARROW_CLASS);
10801080
}
10811081

1082-
public static getIndicatorsContainer(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.bottom): HTMLElement {
1082+
public static getIndicatorsContainer(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.end): HTMLElement {
10831083
const carouselNative = fixture.nativeElement;
1084-
if (position === CarouselIndicatorsOrientation.bottom) {
1085-
return carouselNative.querySelector(HelperTestFunctions.INDICATORS_BOTTOM_CLASS);
1084+
if (position === CarouselIndicatorsOrientation.end) {
1085+
return carouselNative.querySelector(HelperTestFunctions.INDICATORS_END_CLASS);
10861086
} else {
1087-
return carouselNative.querySelector(HelperTestFunctions.INDICATORS_TOP_CLASS);
1087+
return carouselNative.querySelector(HelperTestFunctions.INDICATORS_START_CLASS);
10881088
}
10891089
}
10901090

1091-
public static getIndicatorsLabel(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.bottom) {
1091+
public static getIndicatorsLabel(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.end) {
10921092
const indContainer = HelperTestFunctions.getIndicatorsContainer(fixture, position);
10931093
return indContainer.querySelector(HelperTestFunctions.INDICATORS_LABEL_CLASS);
10941094
}
10951095

1096-
public static getIndicators(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.bottom) {
1096+
public static getIndicators(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.end) {
10971097
const indContainer = HelperTestFunctions.getIndicatorsContainer(fixture, position);
10981098
return indContainer.querySelectorAll(HelperTestFunctions.INDICATOR_CLASS);
10991099
}
11001100

1101-
public static getIndicatorsDots(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.bottom) {
1101+
public static getIndicatorsDots(fixture, position: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.end) {
11021102
const indContainer = HelperTestFunctions.getIndicatorsContainer(fixture, position);
11031103
return indContainer.querySelectorAll(HelperTestFunctions.INDICATOR_DOT_CLASS);
11041104
}

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,36 +230,36 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
230230

231231
/**
232232
* Controls the maximum indexes that can be shown.
233-
* Default value is `5`.
233+
* Default value is `10`.
234234
* ```html
235-
* <igx-carousel [maximumIndicatorsCount]="10"></igx-carousel>
235+
* <igx-carousel [maximumIndicatorsCount]="5"></igx-carousel>
236236
* ```
237237
*
238238
* @memberOf IgxCarouselComponent
239239
*/
240-
@Input() public maximumIndicatorsCount = 5;
240+
@Input() public maximumIndicatorsCount = 10;
241241

242242
/**
243-
* Gets/sets the display mode of carousel indicators. It can be top or bottom.
244-
* Default value is `bottom`.
243+
* Gets/sets the display mode of carousel indicators. It can be `start` or `end`.
244+
* Default value is `end`.
245245
* ```html
246-
* <igx-carousel indicatorsOrientation='top'>
246+
* <igx-carousel indicatorsOrientation="start">
247247
* <igx-carousel>
248248
* ```
249249
*
250-
* @memberOf IgxSlideComponent
250+
* @memberOf IgxCarouselComponent
251251
*/
252-
@Input() public indicatorsOrientation: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.bottom;
252+
@Input() public indicatorsOrientation: CarouselIndicatorsOrientation = CarouselIndicatorsOrientation.end;
253253

254254
/**
255255
* Gets/sets the animation type of carousel.
256256
* Default value is `slide`.
257257
* ```html
258-
* <igx-carousel animationType='none'>
258+
* <igx-carousel animationType="none">
259259
* <igx-carousel>
260260
* ```
261261
*
262-
* @memberOf IgxSlideComponent
262+
* @memberOf IgxCarouselComponent
263263
*/
264264
@Input() public override animationType: CarouselAnimationType = CarouselAnimationType.slide;
265265

@@ -472,7 +472,7 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
472472
public get indicatorsClass() {
473473
return {
474474
['igx-carousel-indicators--focused']: this._hasKeyboardFocusOnIndicators,
475-
[`igx-carousel-indicators--${this.indicatorsOrientation}`]: true
475+
[`igx-carousel-indicators--${this.getIndicatorsClass()}`]: true
476476
};
477477
}
478478

@@ -1011,6 +1011,17 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
10111011
}
10121012
}
10131013

1014+
private getIndicatorsClass(): string {
1015+
switch (this.indicatorsOrientation) {
1016+
case CarouselIndicatorsOrientation.top:
1017+
return CarouselIndicatorsOrientation.start;
1018+
case CarouselIndicatorsOrientation.bottom:
1019+
return CarouselIndicatorsOrientation.end;
1020+
default:
1021+
return this.indicatorsOrientation;
1022+
}
1023+
}
1024+
10141025
private getNextIndex(): number {
10151026
return (this.current + 1) % this.total;
10161027
}

projects/igniteui-angular/src/lib/carousel/enums.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export const CarouselAnimationType = /*@__PURE__*/mkenum({
88
export type CarouselAnimationType = (typeof CarouselAnimationType)[keyof typeof CarouselAnimationType];
99

1010
export const CarouselIndicatorsOrientation = /*@__PURE__*/mkenum({
11+
/**
12+
* @deprecated in version 19.1.0. Use `end` instead.
13+
*/
1114
bottom: 'bottom',
12-
top: 'top'
15+
/**
16+
* @deprecated in version 19.1.0. Use `start` instead.
17+
*/
18+
top: 'top',
19+
start: 'start',
20+
end: 'end'
1321
});
1422
export type CarouselIndicatorsOrientation = (typeof CarouselIndicatorsOrientation)[keyof typeof CarouselIndicatorsOrientation];

projects/igniteui-angular/src/lib/core/styles/components/carousel/_carousel-component.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
@extend %igx-carousel-indicator !optional;
1212
}
1313

14-
@include m(top) {
14+
@include m(start) {
1515
@extend %igx-carousel-indicators !optional;
16-
@extend %igx-carousel-indicators--top !optional;
16+
@extend %igx-carousel-indicators--start !optional;
1717
}
1818

19-
@include m(bottom) {
19+
@include m(end) {
2020
@extend %igx-carousel-indicators !optional;
21-
@extend %igx-carousel-indicators--bottom !optional;
21+
@extend %igx-carousel-indicators--end !optional;
2222
}
2323

2424
@include m(focused) {

projects/igniteui-angular/src/lib/core/styles/components/carousel/_carousel-theme.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@
320320
}
321321
}
322322

323-
%igx-carousel-indicators--bottom {
323+
%igx-carousel-indicators--end {
324324
bottom: 0;
325325
}
326326

327-
%igx-carousel-indicators--top {
327+
%igx-carousel-indicators--start {
328328
top: 0;
329329
}
330330

@@ -563,16 +563,19 @@
563563
}
564564
}
565565

566+
566567
%igx-carousel-arrow--prev {
567568
inset-block-start: 0;
568569
margin-block-start: rem(16px);
569570
}
570571

572+
571573
%igx-carousel-arrow--next {
572574
inset-block-end: 0;
573575
margin-block-end: rem(16px);
574576
}
575577

578+
576579
%igx-carousel-indicators {
577580
inset-inline-end: 0;
578581
inset-inline-start: unset;
@@ -590,7 +593,7 @@
590593
padding: rem(4px) rem(6px);
591594
}
592595

593-
%igx-carousel-indicators--top {
596+
%igx-carousel-indicators--start {
594597
inset-inline-end: unset;
595598
inset-inline-start: 0;
596599
margin-inline-start: rem(16px);
@@ -603,12 +606,13 @@
603606
padding: rem(6px);
604607
}
605608

609+
606610
%igx-carousel-label-indicator {
607611
padding: rem(4px) rem(6px);
608612
margin-inline-end: rem(16px);
609613
}
610614

611-
%igx-carousel-indicators--top {
615+
%igx-carousel-indicators--start {
612616
margin-inline-start: rem(16px);
613617
}
614618
}

src/app/carousel/carousel.sample.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export class CarouselSampleComponent {
4141
}
4242

4343
public changeOrientation() {
44-
if (this.car.indicatorsOrientation === CarouselIndicatorsOrientation.top) {
45-
this.car.indicatorsOrientation = CarouselIndicatorsOrientation.bottom;
44+
if (this.car.indicatorsOrientation === CarouselIndicatorsOrientation.start) {
45+
this.car.indicatorsOrientation = CarouselIndicatorsOrientation.end;
4646
} else {
47-
this.car.indicatorsOrientation = CarouselIndicatorsOrientation.top;
47+
this.car.indicatorsOrientation = CarouselIndicatorsOrientation.start;
4848
}
4949
}
5050

0 commit comments

Comments
 (0)