Skip to content

Commit 96ddba6

Browse files
authored
Merge branch 'master' into mtsvyatkova/feat-1379-tile-manager
2 parents 9d1a059 + 0c0a329 commit 96ddba6

File tree

5 files changed

+37
-60
lines changed

5 files changed

+37
-60
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
9+
### Changed
10+
11+
- #### Carousel - **Potential visual breaking change.**
12+
- Removed `[part='base']` wrapping container from slide's internal DOM.
713
## [5.2.3] - 2025-02-13
814
### Fixed
915
- #### Chip

src/components/carousel/carousel-slide.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { consume } from '@lit/context';
22
import { LitElement, html } from 'lit';
33
import { property } from 'lit/decorators.js';
44

5-
import { type Ref, createRef, ref } from 'lit/directives/ref.js';
65
import { EaseInOut } from '../../animations/easings.js';
76
import { addAnimationController } from '../../animations/player.js';
87
import { carouselContext } from '../common/context.js';
98
import { registerComponent } from '../common/definitions/register.js';
10-
import { createCounter, formatString, partNameMap } from '../common/util.js';
9+
import { createCounter, formatString } from '../common/util.js';
1110
import { animations } from './animations.js';
1211
import type IgcCarouselComponent from './carousel.js';
1312
import { styles } from './themes/carousel-slide.base.css.js';
@@ -18,8 +17,6 @@ import { styles } from './themes/carousel-slide.base.css.js';
1817
* @element igc-carousel-slide
1918
*
2019
* @slot Default slot for the carousel slide.
21-
*
22-
* @csspart base - The base wrapper of the carousel slide.
2320
*/
2421

2522
export default class IgcCarouselSlideComponent extends LitElement {
@@ -34,8 +31,7 @@ export default class IgcCarouselSlideComponent extends LitElement {
3431
private static readonly increment = createCounter();
3532

3633
private _internals: ElementInternals;
37-
private _slideRef: Ref<HTMLElement> = createRef();
38-
private _animationPlayer = addAnimationController(this, this._slideRef);
34+
private _animationPlayer = addAnimationController(this);
3935

4036
@consume({ context: carouselContext, subscribe: true })
4137
private _carousel?: IgcCarouselComponent;
@@ -70,7 +66,7 @@ export default class IgcCarouselSlideComponent extends LitElement {
7066
public active = false;
7167

7268
/* blazorSuppress */
73-
@property({ attribute: false })
69+
@property({ type: Boolean, reflect: true })
7470
public previous = false;
7571

7672
public async toggleAnimation(
@@ -117,17 +113,7 @@ export default class IgcCarouselSlideComponent extends LitElement {
117113
}
118114

119115
protected override render() {
120-
const parts = partNameMap({
121-
base: true,
122-
current: this.active,
123-
previous: this.previous,
124-
});
125-
126-
return html`
127-
<div ${ref(this._slideRef)} part=${parts}>
128-
<slot></slot>
129-
</div>
130-
`;
116+
return html` <slot></slot> `;
131117
}
132118
}
133119

src/components/carousel/carousel.spec.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
fixture,
55
html,
66
nextFrame,
7+
waitUntil,
78
} from '@open-wc/testing';
89

910
import { type SinonFakeTimers, spy, useFakeTimers } from 'sinon';
@@ -199,22 +200,12 @@ describe('Carousel', () => {
199200
</igc-carousel-slide>`,
200201
DIFF_OPTIONS
201202
);
202-
expect(slides[0]).shadowDom.to.equal(
203-
`<div part="base current">
204-
<slot></slot>
205-
</div>`
206-
);
207203
expect(slides[1]).dom.to.equal(
208204
`<igc-carousel-slide>
209205
<span>2</span>
210206
</igc-carousel-slide>`,
211207
DIFF_OPTIONS
212208
);
213-
expect(slides[1]).shadowDom.to.equal(
214-
`<div part="base">
215-
<slot></slot>
216-
</div>`
217-
);
218209

219210
slides[1].active = true;
220211
await elementUpdated(slides[1]);
@@ -225,22 +216,12 @@ describe('Carousel', () => {
225216
</igc-carousel-slide>`,
226217
DIFF_OPTIONS
227218
);
228-
expect(slides[0]).shadowDom.to.equal(
229-
`<div part="base">
230-
<slot></slot>
231-
</div>`
232-
);
233219
expect(slides[1]).dom.to.equal(
234220
`<igc-carousel-slide active>
235221
<span>2</span>
236222
</igc-carousel-slide>`,
237223
DIFF_OPTIONS
238224
);
239-
expect(slides[1]).shadowDom.to.equal(
240-
`<div part="base current">
241-
<slot></slot>
242-
</div>`
243-
);
244225
});
245226

246227
it('should not render indicators if `hideIndicators` is true', async () => {
@@ -525,7 +506,7 @@ describe('Carousel', () => {
525506
expect(defaultIndicators[0].active).to.be.true;
526507

527508
simulateClick(nextButton!);
528-
await slideChangeComplete(slides[0], slides[1]);
509+
await waitUntil(() => eventSpy.calledWith('igcSlideChanged'));
529510

530511
expect(carousel.current).to.equal(1);
531512
expect(defaultIndicators[0].active).to.be.false;
@@ -539,7 +520,7 @@ describe('Carousel', () => {
539520
expect(defaultIndicators[0].active).to.be.true;
540521

541522
simulateClick(prevButton!);
542-
await slideChangeComplete(slides[0], slides[2]);
523+
await waitUntil(() => eventSpy.calledWith('igcSlideChanged'));
543524

544525
expect(carousel.current).to.equal(2);
545526
expect(defaultIndicators[0].active).to.be.false;
@@ -554,7 +535,9 @@ describe('Carousel', () => {
554535

555536
// select second slide
556537
simulateClick(defaultIndicators[1]);
557-
await slideChangeComplete(slides[0], slides[1]);
538+
await waitUntil(() =>
539+
eventSpy.calledWith('igcSlideChanged', { detail: 1 })
540+
);
558541

559542
expect(carousel.current).to.equal(1);
560543
expect(defaultIndicators[0].active).to.be.false;
@@ -563,7 +546,9 @@ describe('Carousel', () => {
563546

564547
// select first slide
565548
simulateClick(defaultIndicators[0]);
566-
await slideChangeComplete(slides[1], slides[0]);
549+
await waitUntil(() =>
550+
eventSpy.calledWith('igcSlideChanged', { detail: 0 })
551+
);
567552

568553
expect(carousel.current).to.equal(0);
569554
expect(defaultIndicators[0].active).to.be.true;

src/components/carousel/themes/carousel-slide.base.scss

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
width: 100%;
77
height: 100%;
88
inset: 0;
9+
z-index: -1;
10+
visibility: hidden;
911

1012
::slotted(img) {
1113
width: 100%;
@@ -16,19 +18,12 @@
1618
}
1719
}
1820

19-
[part~='base'] {
20-
width: 100%;
21-
height: 100%;
22-
z-index: -1;
23-
visibility: hidden;
24-
}
25-
26-
[part='base current'] {
21+
:host([active]) {
2722
z-index: 2;
2823
visibility: visible;
2924
}
3025

31-
[part='base previous'] {
26+
:host([previous]) {
3227
z-index: 1;
3328
visibility: visible;
3429
}

stories/carousel.stories.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,26 @@ export const InputsTemplate: Story = {
293293
<style>
294294
igc-carousel {
295295
border-radius: 10px;
296-
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
296+
box-shadow: 0 6px 12px oklch(from #333 l c h / 0.1);
297+
border: 1px solid var(--ig-gray-200);
297298
max-width: 75%;
298299
margin-inline: auto;
299300
height: 350px;
300301
}
302+
301303
igc-carousel-slide {
302-
display: flex;
303-
align-items: center;
304-
justify-content: center;
305-
max-width: 75%;
304+
display: grid;
305+
place-items: center stretch;
306306
margin-inline: auto;
307-
padding-block: 8px;
307+
padding-inline: 96px;
308+
padding-block-start: 8px;
309+
padding-block-end: 32px;
308310
}
309-
igc-carousel-slide > * {
310-
margin-block: 8px;
311+
312+
igc-carousel-slide > igc-button {
313+
max-width: fit-content;
311314
}
315+
312316
igc-carousel-slide div {
313317
text-align: center;
314318
}
@@ -329,7 +333,8 @@ export const InputsTemplate: Story = {
329333
>
330334
<igc-carousel-slide>
331335
<igc-input type="text" placeholder="Username">
332-
<span slot="prefix">🐱‍💻</span>
336+
<span slot="prefix">🐱</span>
337+
<span slot="prefix">💻</span>
333338
</igc-input>
334339
<igc-textarea label="Leave your comment">
335340
<span slot="prefix">💬</span>

0 commit comments

Comments
 (0)