Skip to content

Commit

Permalink
fix(combobox): ensure icon scales are consistent (#8075)
Browse files Browse the repository at this point in the history
**Related Issue:** #8067

## Summary

Uses `getIconScale` util to set proper scale for placeholder and chevron
icons.
  • Loading branch information
jcfranco authored Oct 30, 2023
1 parent f6d6d35 commit babba3b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@

.icon-end,
.icon-start {
@apply flex
w-4 cursor-pointer
items-center;
@apply flex cursor-pointer items-center;
}

.icon-end {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,21 +497,45 @@ export const clearDisabled_TestOnly = (): string => html`
`;

export const openInAllScales_TestOnly = (): string => html`
<calcite-combobox open scale="s">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open scale="m">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open scale="l">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<div style="display: flex">
<calcite-combobox open placeholder="choose a number" scale="s">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open placeholder="choose a number" scale="m">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open placeholder="choose a number" scale="l">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
</div>
`;

export const openWithPlaceholderIconInAllScales_TestOnly = (): string => html`
<div style="display: flex">
<calcite-combobox open placeholder="choose a number" placeholder-icon="number" scale="s">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open placeholder="choose a number" placeholder-icon="number" scale="m">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
<br />
<calcite-combobox open placeholder="choose a number" placeholder-icon="number" scale="l">
<calcite-combobox-item value="one" text-label="one"></calcite-combobox-item>
<calcite-combobox-item value="two" text-label="two"></calcite-combobox-item>
<calcite-combobox-item value="three" text-label="three"></calcite-combobox-item>
</calcite-combobox>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { ComboboxChildElement } from "./interfaces";
import { ComboboxChildSelector, ComboboxItem, ComboboxItemGroup, CSS } from "./resources";
import { getItemAncestors, getItemChildren, hasActiveChildren, isSingleLike } from "./utils";
import { XButton, CSS as XButtonCSS } from "../functional/XButton";
import { getIconScale } from "../../utils/component";

interface ItemData {
label: string;
Expand Down Expand Up @@ -1294,7 +1295,7 @@ export class Combobox
class="selected-icon"
flipRtl={this.open && selectedItem ? selectedItem.iconFlipRtl : placeholderIconFlipRtl}
icon={!this.open && selectedItem ? selectedIcon : placeholderIcon}
scale="s"
scale={getIconScale(this.scale)}
/>
</span>
)
Expand All @@ -1305,7 +1306,10 @@ export class Combobox
const { open } = this;
return (
<span class="icon-end">
<calcite-icon icon={open ? "chevron-up" : "chevron-down"} scale="s" />
<calcite-icon
icon={open ? "chevron-up" : "chevron-down"}
scale={getIconScale(this.scale)}
/>
</span>
);
}
Expand Down

0 comments on commit babba3b

Please sign in to comment.