Skip to content

Commit a2bf1bb

Browse files
feat(accordion-group): add the shape property and styles for the ionic theme (#29971)
- Adds support for the `shape` property in accordion group. - Adds styles for the `"soft"`, `"round"` and `"rectangular"` shapes in the `ionic` theme - Defaults the shape to `"round"` for the ionic theme - Adds an e2e test for `shape` with screenshots of all shapes - Renames the `accordion.e2e.ts` files in other tests to `accordion-group.e2e.ts` which also renames the screenshot folder
1 parent 3306d71 commit a2bf1bb

File tree

35 files changed

+237
-6
lines changed

35 files changed

+237
-6
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ion-accordion-group,prop,expand,"compact" | "inset",'compact',false,false
1818
ion-accordion-group,prop,mode,"ios" | "md",undefined,false,false
1919
ion-accordion-group,prop,multiple,boolean | undefined,undefined,false,false
2020
ion-accordion-group,prop,readonly,boolean,false,false,false
21+
ion-accordion-group,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
2122
ion-accordion-group,prop,theme,"ios" | "md" | "ionic",undefined,false,false
2223
ion-accordion-group,prop,value,null | string | string[] | undefined,undefined,false,false
2324
ion-accordion-group,event,ionChange,AccordionGroupChangeEventDetail<any>,true

core/src/components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ export namespace Components {
136136
* This method is used to ensure that the value of ion-accordion-group is being set in a valid way. This method should only be called in response to a user generated action.
137137
*/
138138
"requestAccordionToggle": (accordionValue: string | undefined, accordionExpand: boolean) => Promise<void>;
139+
/**
140+
* Set to `"soft"` for an accordion group with slightly rounded corners, `"round"` for an accordion group with fully rounded corners, or `"rectangular"` for an accordion group without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. Only applies when `expand` is set to `"inset"`.
141+
*/
142+
"shape"?: 'soft' | 'round' | 'rectangular';
139143
/**
140144
* The theme determines the visual appearance of the component.
141145
*/
@@ -5392,6 +5396,10 @@ declare namespace LocalJSX {
53925396
* If `true`, the accordion group cannot be interacted with, but does not alter the opacity.
53935397
*/
53945398
"readonly"?: boolean;
5399+
/**
5400+
* Set to `"soft"` for an accordion group with slightly rounded corners, `"round"` for an accordion group with fully rounded corners, or `"rectangular"` for an accordion group without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. Only applies when `expand` is set to `"inset"`.
5401+
*/
5402+
"shape"?: 'soft' | 'round' | 'rectangular';
53955403
/**
53965404
* The theme determines the visual appearance of the component.
53975405
*/

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@
1212

1313
// Inset Accordion Group
1414
// --------------------------------------------------
15-
1615
// Shape and padding only apply if the group is inset
16+
1717
:host(.accordion-group-expand-inset) {
18-
@include globals.border-radius(globals.$ion-border-radius-400);
1918
@include globals.padding(globals.$ion-space-100);
2019
}
20+
21+
:host(.accordion-group-expand-inset.accordion-group-shape-round) {
22+
@include globals.border-radius(globals.$ion-border-radius-400);
23+
}
24+
25+
:host(.accordion-group-expand-inset.accordion-group-shape-soft) {
26+
@include globals.border-radius(globals.$ion-border-radius-200);
27+
}
28+
29+
:host(.accordion-group-expand-inset.accordion-group-shape-rectangular) {
30+
@include globals.border-radius(globals.$ion-border-radius-0);
31+
}

core/src/components/accordion-group/accordion-group.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ export class AccordionGroup implements ComponentInterface {
6060
*/
6161
@Prop() expand: 'compact' | 'inset' = 'compact';
6262

63+
/**
64+
* Set to `"soft"` for an accordion group with slightly rounded corners,
65+
* `"round"` for an accordion group with fully rounded corners, or
66+
* `"rectangular"` for an accordion group without rounded corners.
67+
*
68+
* Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
69+
* Only applies when `expand` is set to `"inset"`.
70+
*/
71+
@Prop() shape?: 'soft' | 'round' | 'rectangular';
72+
6373
/**
6474
* Emitted when the value property has changed as a result of a user action such as a click.
6575
*
@@ -278,9 +288,26 @@ export class AccordionGroup implements ComponentInterface {
278288
return Array.from(this.el.querySelectorAll(':scope > ion-accordion')) as HTMLIonAccordionElement[];
279289
}
280290

291+
private getShape(): string | undefined {
292+
const theme = getIonTheme(this);
293+
const { shape } = this;
294+
295+
// TODO(ROU-11328): Remove theme check when shapes are defined for all themes.
296+
if (theme !== 'ionic') {
297+
return undefined;
298+
}
299+
300+
if (shape === undefined) {
301+
return 'round';
302+
}
303+
304+
return shape;
305+
}
306+
281307
render() {
282308
const { disabled, readonly, expand } = this;
283309
const theme = getIonTheme(this);
310+
const shape = this.getShape();
284311

285312
return (
286313
<Host
@@ -289,6 +316,7 @@ export class AccordionGroup implements ComponentInterface {
289316
'accordion-group-disabled': disabled,
290317
'accordion-group-readonly': readonly,
291318
[`accordion-group-expand-${expand}`]: true,
319+
[`accordion-group-shape-${shape}`]: shape !== undefined,
292320
}}
293321
role="presentation"
294322
>

0 commit comments

Comments
 (0)