Skip to content

Commit d4ff124

Browse files
feat(accordion): add shape styles for the ionic theme (#29973)
- Applies border radius based on the `shape` defined on the parent accordion group - Adds an e2e test for shape with focused items to show the border radius - Adds screenshots for the e2e test
1 parent 4f61e01 commit d4ff124

17 files changed

+216
-19
lines changed

core/src/components/accordion-group/accordion-group.ionic.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
}
2020

2121
:host(.accordion-group-expand-inset.accordion-group-shape-round) {
22+
--border-radius: #{globals.$ion-border-radius-400};
23+
2224
@include globals.border-radius(globals.$ion-border-radius-400);
2325
}
2426

2527
:host(.accordion-group-expand-inset.accordion-group-shape-soft) {
28+
--border-radius: #{globals.$ion-border-radius-200};
29+
2630
@include globals.border-radius(globals.$ion-border-radius-200);
2731
}
2832

2933
:host(.accordion-group-expand-inset.accordion-group-shape-rectangular) {
34+
--border-radius: #{globals.$ion-border-radius-0};
35+
3036
@include globals.border-radius(globals.$ion-border-radius-0);
3137
}

core/src/components/accordion/accordion.common.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// @import "../../themes/functions.string";
2-
// @import "../../themes/mixins";
3-
41
// Accordion: Common
52
// --------------------------------------------------
63

core/src/components/accordion/accordion.ionic.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// The border is removed from the item in the header because
4343
// we are adding a border to the ::after element of the accordion.
4444
::slotted(ion-item[slot="header"]) {
45-
--border-radius: #{globals.$ion-border-radius-0};
45+
--border-radius: inherit;
4646
--color: #{globals.$ion-primitives-neutral-1200};
4747
--border-width: 0;
4848
--inner-border-width: 0;
@@ -55,11 +55,6 @@
5555
@include globals.typography(globals.$ion-heading-h6-medium);
5656
}
5757

58-
// Shape only applies when inside an inset accordion group
59-
:host(.in-accordion-group-expand-inset) ::slotted(ion-item[slot="header"]) {
60-
--border-radius: #{globals.$ion-border-radius-400};
61-
}
62-
6358
// Accordion Content
6459
// --------------------------------------------------
6560

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => {
5+
test.describe(title('accordion: shape'), () => {
6+
['round', 'soft', 'rectangular'].forEach((shape) => {
7+
test(`${shape} - should not have visual regressions`, async ({ page }) => {
8+
await page.setContent(
9+
`
10+
<style>
11+
/* Background styles to show the border radius */
12+
:root {
13+
background: #222;
14+
}
15+
</style>
16+
17+
<!-- Focused accordion to show the border radius -->
18+
<ion-accordion-group value="first" expand="inset" shape="${shape}">
19+
<ion-accordion value="first">
20+
<ion-item slot="header" class="ion-focused">
21+
<ion-label>Accordion title</ion-label>
22+
</ion-item>
23+
<div slot="content">This is the body of the accordion.</div>
24+
</ion-accordion>
25+
<ion-accordion value="second">
26+
<ion-item slot="header">
27+
<ion-label>Accordion title</ion-label>
28+
</ion-item>
29+
<div slot="content">This is the body of the accordion.</div>
30+
</ion-accordion>
31+
<ion-accordion value="third">
32+
<ion-item slot="header">
33+
<ion-label>Accordion title</ion-label>
34+
</ion-item>
35+
<div slot="content">This is the body of the accordion.</div>
36+
</ion-accordion>
37+
</ion-accordion-group>
38+
`,
39+
config
40+
);
41+
42+
const accordionGroup = page.locator('ion-accordion-group');
43+
44+
await expect(accordionGroup).toHaveScreenshot(screenshot(`accordion-shape-${shape}`));
45+
});
46+
});
47+
});
48+
});
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)