Skip to content

Commit

Permalink
fix(tab, tabs, tab-title, input, input-number, input-text, input-date…
Browse files Browse the repository at this point in the history
…-picker, input-time-picker): bumping the scale of icon to M when parent is scale L (#6267)

**Related Issue:** #5698

## Summary

Bumping the scales of `iconStart` and `iconEnd` to M when the parent
`tab-title`,`input`, `input-number`, `input-text`, `input-date-picker`,
`input-time-picker` components are `scale="l"` for a visual distinction
between larger and smaller components without affecting the height of
the components when icon(s) are added or removed. Added `_testOnly`
snapshots.
  • Loading branch information
Elijbet authored Jan 14, 2023
1 parent 2b8656a commit e8edf6b
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 69 deletions.
13 changes: 10 additions & 3 deletions src/components/input-date-picker/input-date-picker.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,21 @@ export const flipPlacements_TestOnly = (): string => html`
</script>
`;

export const laoNumberingSystem_TestOnly = (): string => html`
export const laoNumberingSystemAndMediumIconForLargeInput_TestOnly = (): string => html`
<div style="width: 400px">
<calcite-input-date-picker
open
value="1/1/1"
lang="zh-CN"
numbering-system="laoo"
></calcite-input-date-picker
</div>`;
scale="l"
start="2020-12-12"
end="2020-12-16"
range=""
layout="horizontal"
></calcite-input-date-picker>
</div>
`;

export const darkModeRTL_TestOnly = (): string => html`
<div style="width: 400px">
Expand Down
8 changes: 6 additions & 2 deletions src/components/input-date-picker/input-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,16 @@ export class InputDatePicker

{this.range && this.layout === "horizontal" && (
<div class="horizontal-arrow-container">
<calcite-icon flipRtl={true} icon="arrow-right" scale="s" />
<calcite-icon
flipRtl={true}
icon="arrow-right"
scale={this.scale === "l" ? "m" : "s"}
/>
</div>
)}
{this.range && this.layout === "vertical" && this.scale !== "s" && (
<div class="vertical-arrow-container">
<calcite-icon icon="arrow-down" scale="s" />
<calcite-icon icon="arrow-down" scale={this.scale === "l" ? "m" : "s"} />
</div>
)}
{this.range && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/input-number/input-number.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
}

:host([icon][scale="l"]) input {
padding-inline-start: theme("padding.12");
padding-inline-start: theme("padding.14");
}

// positioning wrapper for icon and loader
Expand Down
35 changes: 33 additions & 2 deletions src/components/input-number/input-number.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,39 @@ export const darkModeRTL_TestOnly = (): string => html`
`;
darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault };

export const hebrewNumberingSystem_TestOnly = (): string =>
html`<calcite-input-number lang="ar-EG" numbering-system="hebr" value="123456"></calcite-input-number>`;
export const hebrewNumberingSystemAndMediumIconForLargeInputStyling_TestOnly = (): string =>
html`
<calcite-input-number
number-button-type="vertical"
lang="ar-EG"
numbering-system="hebr"
value="123456"
scale="l"
></calcite-input-number
><calcite-input-number
number-button-type="vertical"
lang="ar-EG"
numbering-system="hebr"
value="123456"
scale="l"
icon="pen"
></calcite-input-number>
<calcite-input-number
number-button-type="horizontal"
lang="ar-EG"
numbering-system="hebr"
value="123456"
scale="l"
></calcite-input-number
><calcite-input-number
number-button-type="horizontal"
lang="ar-EG"
numbering-system="hebr"
value="123456"
scale="l"
icon="pen"
></calcite-input-number>
`;

export const arabicLocaleWithLatinNumberingSystem_TestOnly = (): string =>
html`<calcite-input-number lang="ar-EG" numbering-system="latn" value="123456"></calcite-input-number>`;
8 changes: 4 additions & 4 deletions src/components/input-number/input-number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -877,15 +877,15 @@ export class InputNumber
tabIndex={-1}
type="button"
>
<calcite-icon icon="x" scale="s" />
<calcite-icon icon="x" scale={this.scale === "l" ? "m" : "s"} />
</button>
);
const iconEl = (
<calcite-icon
class={CSS.inputIcon}
flipRtl={this.iconFlipRtl}
icon={this.requestedIcon}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
);

Expand All @@ -906,7 +906,7 @@ export class InputNumber
tabIndex={-1}
type="button"
>
<calcite-icon icon="chevron-up" scale="s" />
<calcite-icon icon="chevron-up" scale={this.scale === "l" ? "m" : "s"} />
</button>
);

Expand All @@ -925,7 +925,7 @@ export class InputNumber
tabIndex={-1}
type="button"
>
<calcite-icon icon="chevron-down" scale="s" />
<calcite-icon icon="chevron-down" scale={this.scale === "l" ? "m" : "s"} />
</button>
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/input-text/input-text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ input:focus {
}

:host([icon][scale="l"]) input {
padding-inline-start: theme("padding.12");
padding-inline-start: theme("padding.14");
}

// positioning wrapper for icon and loader
Expand Down
14 changes: 14 additions & 0 deletions src/components/input-text/input-text.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,17 @@ export const darkModeRTL_TestOnly = (): string => html`
</div>
`;
darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault };

export const mediumIconForLargeScaleStyling_TestOnly = (): string => html`
<calcite-label scale="l">
Input Label
<calcite-input-text placeholder="Placeholder" scale="l"></calcite-input-text>
<calcite-input-text
placeholder="Placeholder"
scale="l"
icon="search"
clearable
value="sample input to show x"
></calcite-input-text>
</calcite-label>
`;
4 changes: 2 additions & 2 deletions src/components/input-text/input-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,15 @@ export class InputText
tabIndex={-1}
type="button"
>
<calcite-icon icon="x" scale="s" />
<calcite-icon icon="x" scale={this.scale === "l" ? "m" : "s"} />
</button>
);
const iconEl = (
<calcite-icon
class={CSS.inputIcon}
flipRtl={this.iconFlipRtl}
icon={this.requestedIcon}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
);
const prefixText = <div class={CSS.prefix}>{this.prefixText}</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const simple = (): string => html`
</calcite-input-time-picker>
`;

export const disabled_TestOnly = (): string => html`<calcite-input-time-picker disabled></calcite-input-time-picker>`;
export const disabled_TestOnly = (): string =>
html`<calcite-input-time-picker disabled scale="l" icon step="1" value="01:02"></calcite-input-time-picker>`;

export const darkModeRTL_TestOnly = (): string => html`
<calcite-input-time-picker
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
}

:host([icon][scale="l"]) input {
padding-inline-start: theme("padding.12");
padding-inline-start: theme("padding.14");
}

// positioning wrapper for icon and loader
Expand Down
10 changes: 5 additions & 5 deletions src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1019,15 +1019,15 @@ export class Input
tabIndex={-1}
type="button"
>
<calcite-icon icon="x" scale="s" />
<calcite-icon icon="x" scale={this.scale === "l" ? "m" : "s"} />
</button>
);
const iconEl = (
<calcite-icon
class={CSS.inputIcon}
flipRtl={this.iconFlipRtl}
icon={this.requestedIcon}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
);

Expand All @@ -1048,7 +1048,7 @@ export class Input
tabIndex={-1}
type="button"
>
<calcite-icon icon="chevron-up" scale="s" />
<calcite-icon icon="chevron-up" scale={this.scale === "l" ? "m" : "s"} />
</button>
);

Expand All @@ -1067,7 +1067,7 @@ export class Input
tabIndex={-1}
type="button"
>
<calcite-icon icon="chevron-down" scale="s" />
<calcite-icon icon="chevron-down" scale={this.scale === "l" ? "m" : "s"} />
</button>
);

Expand Down Expand Up @@ -1153,7 +1153,7 @@ export class Input
/>,
this.isTextarea ? (
<div class={CSS.resizeIconWrapper}>
<calcite-icon icon="chevron-down" scale="s" />
<calcite-icon icon="chevron-down" scale={this.scale === "l" ? "m" : "s"} />
</div>
) : null
]
Expand Down
8 changes: 8 additions & 0 deletions src/components/tab-title/resources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const CSS = {
container: "container",
containerHasText: "container--has-text",
iconEnd: "icon-end",
iconStart: "icon-start",
iconPresent: "icon-present",
titleIcon: "calcite-tab-title--icon"
};
15 changes: 9 additions & 6 deletions src/components/tab-title/tab-title.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { newE2EPage } from "@stencil/core/testing";
import { disabled, HYDRATED_ATTR, renders, hidden } from "../../tests/commonTests";
import { CSS } from "./resources";

describe("calcite-tab-title", () => {
const tabTitleHtml = "<calcite-tab-title></calcite-tab-title>";
const iconStartHtml = `calcite-tab-title >>> .${CSS.titleIcon}.${CSS.iconStart}`;
const iconEndHtml = `calcite-tab-title >>> .${CSS.titleIcon}.${CSS.iconEnd}`;

it("renders", async () => renders(tabTitleHtml, { display: "block" }));

Expand All @@ -14,8 +17,8 @@ describe("calcite-tab-title", () => {
const page = await newE2EPage();
await page.setContent(`<calcite-tab-title icon-start='plus'>Text</calcite-tab-title>`);
const element = await page.find("calcite-tab-title");
const iconStart = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-start");
const iconEnd = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-end");
const iconStart = await page.find(iconStartHtml);
const iconEnd = await page.find(iconEndHtml);
expect(element).toHaveAttribute(HYDRATED_ATTR);
expect(iconStart).not.toBeNull();
expect(iconEnd).toBeNull();
Expand All @@ -25,8 +28,8 @@ describe("calcite-tab-title", () => {
const page = await newE2EPage();
await page.setContent(`<calcite-tab-title icon-end='plus'>Text</calcite-tab-title>`);
const element = await page.find("calcite-tab-title");
const iconStart = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-start");
const iconEnd = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-end");
const iconStart = await page.find(iconStartHtml);
const iconEnd = await page.find(iconEndHtml);
expect(element).toHaveAttribute(HYDRATED_ATTR);
expect(iconStart).toBeNull();
expect(iconEnd).not.toBeNull();
Expand All @@ -36,8 +39,8 @@ describe("calcite-tab-title", () => {
const page = await newE2EPage();
await page.setContent(`<calcite-tab-title icon-start='plus' icon-end='plus'>Text</calcite-tab-title>`);
const element = await page.find("calcite-tab-title");
const iconStart = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-start");
const iconEnd = await page.find("calcite-tab-title >>> .calcite-tab-title--icon.icon-end");
const iconStart = await page.find(iconStartHtml);
const iconEnd = await page.find(iconEndHtml);
expect(element).toHaveAttribute(HYDRATED_ATTR);
expect(iconStart).not.toBeNull();
expect(iconEnd).not.toBeNull();
Expand Down
8 changes: 5 additions & 3 deletions src/components/tab-title/tab-title.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
:host([scale="l"]) {
margin-inline-end: 1.5rem;
.container {
@apply text-0h py-3;
@apply text-0h py-2.5;
}
}

Expand All @@ -77,8 +77,7 @@
justify-center
truncate
border-b-2
px-0
py-2;
px-0;
border-block-end-style: solid;
}

Expand Down Expand Up @@ -169,6 +168,9 @@
.container {
@apply px-4;
}
.icon-present {
padding-block: 11px;
}
}

@media (forced-colors: active) {
Expand Down
12 changes: 7 additions & 5 deletions src/components/tab-title/tab-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { InteractiveComponent, updateHostInteraction } from "../../utils/interac
import { createObserver } from "../../utils/observers";
import { FlipContext, Scale } from "../interfaces";
import { TabChangeEventDetail } from "../tab/interfaces";
import { CSS } from "./resources";
import { TabID, TabLayout, TabPosition } from "../tabs/interfaces";

/**
Expand Down Expand Up @@ -148,19 +149,19 @@ export class TabTitle implements InteractiveComponent {

const iconStartEl = (
<calcite-icon
class="calcite-tab-title--icon icon-start"
class={{ [CSS.titleIcon]: true, [CSS.iconStart]: true }}
flipRtl={this.iconFlipRtl === "start" || this.iconFlipRtl === "both"}
icon={this.iconStart}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
);

const iconEndEl = (
<calcite-icon
class="calcite-tab-title--icon icon-end"
class={{ [CSS.titleIcon]: true, [CSS.iconEnd]: true }}
flipRtl={this.iconFlipRtl === "end" || this.iconFlipRtl === "both"}
icon={this.iconEnd}
scale="s"
scale={this.scale === "l" ? "m" : "s"}
/>
);

Expand All @@ -175,7 +176,8 @@ export class TabTitle implements InteractiveComponent {
<div
class={{
container: true,
"container--has-text": this.hasText
[CSS.iconPresent]: this.iconStart || this.iconEnd ? true : null,
[CSS.containerHasText]: this.hasText
}}
ref={(el) => this.resizeObserver?.observe(el)}
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/tab/tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ section,
}

:host([scale="l"]) {
@apply text-0h py-3;
@apply text-0h;
padding-block: 13px;
}
Loading

0 comments on commit e8edf6b

Please sign in to comment.