Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(dropdown)!: rename width property to widthScale #8251

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("calcite-dropdown", () => {

it("renders requested props when valid props are provided", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-dropdown placement="bottom-end" width="l">
await page.setContent(html`<calcite-dropdown placement="bottom-end" width-scale="l">
<calcite-button slot="trigger">Open dropdown</calcite-button>
<calcite-dropdown-group id="group-1" selection-mode="multiple">
<calcite-dropdown-item id="item-1"> Dropdown Item Content </calcite-dropdown-item>
Expand All @@ -157,7 +157,7 @@ describe("calcite-dropdown", () => {
const element = await page.find("calcite-dropdown");
const group1 = await element.find("calcite-dropdown-group[id='group-1']");

expect(element).toEqualAttribute("width", "l");
expect(element).toEqualAttribute("width-scale", "l");
expect(element).toEqualAttribute("placement", "bottom-end");
expect(group1).toEqualAttribute("selection-mode", "multiple");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
}

// width
:host([width="s"]) {
:host([width-scale="s"]) {
--calcite-dropdown-width: theme("spacing.48");
}
:host([width="m"]) {
:host([width-scale="m"]) {
--calcite-dropdown-width: theme("spacing.56");
}
:host([width="l"]) {
:host([width-scale="l"]) {
--calcite-dropdown-width: theme("spacing.64");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const simple = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -68,7 +68,7 @@ export const simpleFullWidth = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand All @@ -91,7 +91,7 @@ export const withIcons = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -129,7 +129,7 @@ export const groupsAndSelectionModes = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -157,7 +157,7 @@ export const itemsAsLinks = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -190,7 +190,7 @@ export const darkModeRTL_TestOnly = (): string => html`
class="calcite-mode-dark"
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -225,7 +225,7 @@ export const itemsAsLinksDarkMode = (): string => html`
class="calcite-mode-dark"
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -259,7 +259,7 @@ export const scrollingAfterCertainItems_TestOnly = (): string => html`
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
max-items="${number("max-items", 7, { min: 0, max: 10, step: 1 })}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -343,7 +343,7 @@ export const disabled_TestOnly = (): string => html` <calcite-dropdown disabled>

export const flipPositioning_TestOnly = (): string => html`
<div style="margin:10px;">
<calcite-dropdown width="m" placement="${select("placement", menuPlacements, "top")}" open>
<calcite-dropdown width-scale="m" placement="${select("placement", menuPlacements, "top")}" open>
<calcite-button slot="trigger">Open Dropdown</calcite-button>
<calcite-dropdown-group>
<calcite-dropdown-item>1</calcite-dropdown-item>
Expand All @@ -365,7 +365,7 @@ export const alignedCenter_TestOnly = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand All @@ -389,7 +389,7 @@ export const alignedCenterRTL_TestOnly = (): string => html`
open
placement="${select("placement", menuPlacements, defaultMenuPlacement)}"
scale="${select("scale", ["s", "m", "l"], "m")}"
width="${select("width", ["s", "m", "l"], "m")}"
width-scale="${select("width-scale", ["s", "m", "l"], "m")}"
type="${select("type", ["click", "hover"], "click")}"
${boolean("close-on-select-disabled", false)}
${boolean("disabled", false)}
Expand Down Expand Up @@ -439,7 +439,7 @@ export const flipPlacements_TestOnly = (): string => html`
`;

export const mediumIconForLargeDropdownItem_TestOnly = (): string => html`
<calcite-dropdown scale="l" width="m" open>
<calcite-dropdown scale="l" width-scale="m" open>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item scale="l">Table</calcite-dropdown-item>
<calcite-dropdown-item icon-start="grid" scale="l">Grid</calcite-dropdown-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class Dropdown
/**
* Specifies the width of the component.
*/
@Prop({ reflect: true }) width: Scale;
@Prop({ reflect: true }) widthScale: Scale;

/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: Scale = "m";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe("calcite-split-button", () => {
element.setProperty("scale", elementScale);
await page.waitForChanges();
const dropdownScale = elementScaleToDropdownScale[elementScale];
expect(dropdown).toEqualAttribute("width", dropdownScale);
expect(dropdown).toEqualAttribute("width-scale", dropdownScale);
expect(dropdown).toEqualAttribute("scale", dropdownScale);
expect(primaryButton).toEqualAttribute("scale", elementScaleToButtonScale[elementScale]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class SplitButton implements InteractiveComponent, LoadableComponent {
overlayPositioning={this.overlayPositioning}
placement="bottom-end"
scale={this.scale}
width={this.scale}
width-scale={this.scale}
>
<calcite-button
appearance={this.appearance}
Expand Down
24 changes: 12 additions & 12 deletions packages/calcite-components/src/demos/dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@

<!-- Width S -->
<div class="parent">
<div class="child right-aligned-text">width S</div>
<div class="child right-aligned-text">widthScale S</div>

<div class="child">
<calcite-dropdown scale="s" width="s">
<calcite-dropdown scale="s" width-scale="s">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale S</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -67,7 +67,7 @@
</div>

<div class="child">
<calcite-dropdown scale="m" width="s">
<calcite-dropdown scale="m" width-scale="s">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale M</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -78,7 +78,7 @@
</div>

<div class="child">
<calcite-dropdown scale="l" width="s">
<calcite-dropdown scale="l" width-scale="s">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale L</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -91,10 +91,10 @@

<!-- Width M -->
<div class="parent">
<div class="child right-aligned-text">width M</div>
<div class="child right-aligned-text">widthScale M</div>

<div class="child">
<calcite-dropdown scale="s" width="m">
<calcite-dropdown scale="s" width-scale="m">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale S</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -105,7 +105,7 @@
</div>

<div class="child">
<calcite-dropdown scale="m" width="m">
<calcite-dropdown scale="m" width-scale="m">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale M</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -116,7 +116,7 @@
</div>

<div class="child">
<calcite-dropdown scale="l" width="m">
<calcite-dropdown scale="l" width-scale="m">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale L</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -129,10 +129,10 @@

<!-- Width L -->
<div class="parent">
<div class="child right-aligned-text">width L</div>
<div class="child right-aligned-text">widthScale L</div>

<div class="child">
<calcite-dropdown scale="s" width="l">
<calcite-dropdown scale="s" width-scale="l">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale S</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -143,7 +143,7 @@
</div>

<div class="child">
<calcite-dropdown scale="m" width="l">
<calcite-dropdown scale="m" width-scale="l">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale M</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand All @@ -154,7 +154,7 @@
</div>

<div class="child">
<calcite-dropdown scale="l" width="l">
<calcite-dropdown scale="l" width-scale="l">
<calcite-button icon-end="hamburger" appearance="outline" slot="trigger">Scale L</calcite-button>
<calcite-dropdown-group group-title="View">
<calcite-dropdown-item icon-end="list-bullet" active>List</calcite-dropdown-item>
Expand Down