Skip to content

Commit

Permalink
fix(accordion-item): bumping the scale of icon to M when parent accor…
Browse files Browse the repository at this point in the history
…dion 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.
  • Loading branch information
Elijbet authored Jan 12, 2023
1 parent efd08f1 commit a6bb7da
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/accordion-item/accordion-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from "../../utils/conditionalSlot";
import { getElementDir, getElementProp, getSlotted, toAriaBoolean } from "../../utils/dom";
import { CSS_UTILITY } from "../../utils/resources";
import { FlipContext, Position } from "../interfaces";
import { SLOTS, CSS } from "./resources";
import { FlipContext, Position, Scale } from "../interfaces";
import { RegistryEntry, RequestedItem } from "./interfaces";
import { CSS, SLOTS } from "./resources";

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

connectConditionalSlotComponent(this);
}
Expand Down Expand Up @@ -142,7 +143,7 @@ export class AccordionItem implements ConditionalSlotComponent {
flipRtl={iconFlipRtl === "both" || iconFlipRtl === "start"}
icon={this.iconStart}
key="icon-start"
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
) : null;
const iconEndEl = this.iconEnd ? (
Expand All @@ -151,7 +152,7 @@ export class AccordionItem implements ConditionalSlotComponent {
flipRtl={iconFlipRtl === "both" || iconFlipRtl === "end"}
icon={this.iconEnd}
key="icon-end"
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
) : null;
const { description } = this;
Expand Down Expand Up @@ -191,7 +192,7 @@ export class AccordionItem implements ConditionalSlotComponent {
? "minus"
: "plus"
}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
</div>
{this.renderActionsEnd()}
Expand Down Expand Up @@ -260,6 +261,10 @@ export class AccordionItem implements ConditionalSlotComponent {

/** handle clicks on item header */
private itemHeaderClickHandler = (): void => this.emitRequestedItem();

/** Specifies the scale of the `accordion-item` controlled by the parent, defaults to m */
scale: Scale = "m";

//--------------------------------------------------------------------------
//
// Private Methods
Expand Down
26 changes: 26 additions & 0 deletions src/components/accordion/accordion.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,29 @@ export const withIconStartAndEnd_TestOnly = (): string =>
)}
`
);

export const mediumIconForLargeAccordionItem_TestOnly = (): string => html`
<calcite-accordion scale="l" style="width: 400px">
<calcite-accordion-item heading="Accordion Item" scale="l"></calcite-accordion-item>
<calcite-accordion-item
heading="Accordion Item IconStart/End"
icon-start="plane"
icon-end="plane"
scale="l"
></calcite-accordion-item>
<calcite-accordion-item heading="Accordion Item" scale="l" description="A great subtitle"></calcite-accordion-item>
<calcite-accordion-item
heading="Accordion Item IconStart/End"
icon-start="plane"
icon-end="plane"
scale="l"
description="A great subtitle"
></calcite-accordion-item>
<calcite-accordion-item
heading="Accordion Item IconStart/End with a potentially two line title"
icon-start="banana"
icon-end="banana"
scale="l"
></calcite-accordion-item>
</calcite-accordion>
`;

0 comments on commit a6bb7da

Please sign in to comment.