Skip to content

Commit a6bb7da

Browse files
authored
fix(accordion-item): bumping the scale of icon to M when parent accordion is scale L (#6252)
**Related Issue:** #5698 ## Summary Bumping the scale of the icon to M when the parent `accordion-item` is `scale="l"` for a visual distinction between larger and smaller components without affecting the height of the `accordion-item` when icon(s) are added or removed. Added a _testOnly snapshot.
1 parent efd08f1 commit a6bb7da

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/components/accordion-item/accordion-item.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import {
1616
} from "../../utils/conditionalSlot";
1717
import { getElementDir, getElementProp, getSlotted, toAriaBoolean } from "../../utils/dom";
1818
import { CSS_UTILITY } from "../../utils/resources";
19-
import { FlipContext, Position } from "../interfaces";
19+
import { SLOTS, CSS } from "./resources";
20+
import { FlipContext, Position, Scale } from "../interfaces";
2021
import { RegistryEntry, RequestedItem } from "./interfaces";
21-
import { CSS, SLOTS } from "./resources";
2222

2323
/**
2424
* @slot - A slot for adding custom content, including nested `calcite-accordion-item`s.
@@ -93,6 +93,7 @@ export class AccordionItem implements ConditionalSlotComponent {
9393
this.selectionMode = getElementProp(this.el, "selection-mode", "multiple");
9494
this.iconType = getElementProp(this.el, "icon-type", "chevron");
9595
this.iconPosition = getElementProp(this.el, "icon-position", this.iconPosition);
96+
this.scale = getElementProp(this.el, "scale", this.scale);
9697

9798
connectConditionalSlotComponent(this);
9899
}
@@ -142,7 +143,7 @@ export class AccordionItem implements ConditionalSlotComponent {
142143
flipRtl={iconFlipRtl === "both" || iconFlipRtl === "start"}
143144
icon={this.iconStart}
144145
key="icon-start"
145-
scale="s"
146+
scale={this.scale === "l" ? "m" : "s"}
146147
/>
147148
) : null;
148149
const iconEndEl = this.iconEnd ? (
@@ -151,7 +152,7 @@ export class AccordionItem implements ConditionalSlotComponent {
151152
flipRtl={iconFlipRtl === "both" || iconFlipRtl === "end"}
152153
icon={this.iconEnd}
153154
key="icon-end"
154-
scale="s"
155+
scale={this.scale === "l" ? "m" : "s"}
155156
/>
156157
) : null;
157158
const { description } = this;
@@ -191,7 +192,7 @@ export class AccordionItem implements ConditionalSlotComponent {
191192
? "minus"
192193
: "plus"
193194
}
194-
scale="s"
195+
scale={this.scale === "l" ? "m" : "s"}
195196
/>
196197
</div>
197198
{this.renderActionsEnd()}
@@ -260,6 +261,10 @@ export class AccordionItem implements ConditionalSlotComponent {
260261

261262
/** handle clicks on item header */
262263
private itemHeaderClickHandler = (): void => this.emitRequestedItem();
264+
265+
/** Specifies the scale of the `accordion-item` controlled by the parent, defaults to m */
266+
scale: Scale = "m";
267+
263268
//--------------------------------------------------------------------------
264269
//
265270
// Private Methods

src/components/accordion/accordion.stories.ts

+26
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,29 @@ export const withIconStartAndEnd_TestOnly = (): string =>
263263
)}
264264
`
265265
);
266+
267+
export const mediumIconForLargeAccordionItem_TestOnly = (): string => html`
268+
<calcite-accordion scale="l" style="width: 400px">
269+
<calcite-accordion-item heading="Accordion Item" scale="l"></calcite-accordion-item>
270+
<calcite-accordion-item
271+
heading="Accordion Item IconStart/End"
272+
icon-start="plane"
273+
icon-end="plane"
274+
scale="l"
275+
></calcite-accordion-item>
276+
<calcite-accordion-item heading="Accordion Item" scale="l" description="A great subtitle"></calcite-accordion-item>
277+
<calcite-accordion-item
278+
heading="Accordion Item IconStart/End"
279+
icon-start="plane"
280+
icon-end="plane"
281+
scale="l"
282+
description="A great subtitle"
283+
></calcite-accordion-item>
284+
<calcite-accordion-item
285+
heading="Accordion Item IconStart/End with a potentially two line title"
286+
icon-start="banana"
287+
icon-end="banana"
288+
scale="l"
289+
></calcite-accordion-item>
290+
</calcite-accordion>
291+
`;

0 commit comments

Comments
 (0)