Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ ion-item-divider,css-prop,--padding-start,ios
ion-item-divider,css-prop,--padding-start,md
ion-item-divider,css-prop,--padding-top,ios
ion-item-divider,css-prop,--padding-top,md
ion-item-divider,part,content
ion-item-divider,part,inner

ion-item-group,none

Expand Down
7 changes: 5 additions & 2 deletions core/src/components/item-divider/item-divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import type { Color } from '../../interface';
* @slot - Content is placed between the named slots if provided without a slot.
* @slot start - Content is placed to the left of the divider text in LTR, and to the right in RTL.
* @slot end - Content is placed to the right of the divider text in LTR, and to the left in RTL.
*
* @part inner - The inner container element that wraps the divider content.
* @part content - The wrapper element that contains the default slot.
*/
@Component({
tag: 'ion-item-divider',
Expand Down Expand Up @@ -50,8 +53,8 @@ export class ItemDivider implements ComponentInterface {
})}
>
<slot name="start"></slot>
<div class="item-divider-inner">
<div class="item-divider-wrapper">
<div class="item-divider-inner" part="inner">
<div class="item-divider-wrapper" part="content">
<slot></slot>
</div>
<slot name="end"></slot>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

/**
* This behavior does not vary across modes/directions
*/
configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, config }) => {
test.describe(title('item-divider: custom'), () => {
test.describe(title('CSS shadow parts'), () => {
test('should be able to customize inner part', async ({ page }) => {
await page.setContent(
`
<style>
ion-item-divider::part(inner) {
background-color: red;
}
</style>

<ion-item-divider>Divider</ion-item-divider>
`,
config
);

const divider = page.locator('ion-item-divider');
const backgroundColor = await divider.evaluate((el) => {
const shadowRoot = el.shadowRoot;
const inner = shadowRoot?.querySelector('.item-divider-inner');
return inner ? window.getComputedStyle(inner).backgroundColor : '';
});
expect(backgroundColor).toBe('rgb(255, 0, 0)');
});

test('should be able to customize content part', async ({ page }) => {
await page.setContent(
`
<style>
ion-item-divider::part(content) {
background-color: green;
}
</style>

<ion-item-divider>Divider</ion-item-divider>
`,
config
);

const divider = page.locator('ion-item-divider');
const backgroundColor = await divider.evaluate((el) => {
const shadowRoot = el.shadowRoot;
const content = shadowRoot?.querySelector('.item-divider-wrapper');
return content ? window.getComputedStyle(content).backgroundColor : '';
});
expect(backgroundColor).toBe('rgb(0, 128, 0)');
});
});
});
});
Loading