-
Notifications
You must be signed in to change notification settings - Fork 89
feat(input-time-zone): add input-time-zone component #6947
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
Changes from all commits
fe0bc8b
502e4ad
e6bd51b
9dd6ee8
a2a60d2
1029ad8
ffb049b
284b4c2
f2308a5
e411271
6a9f373
64b74bf
428b2ec
e5e8996
354a1f2
69b97c4
f2a3645
6ee7cf5
7a88782
de72851
7d1b944
20cfe98
16126ea
d4504c2
349b475
79ec8f7
5529839
54515e7
98bdff0
81e0c09
f8d0aed
b14d8bd
71e6586
3143627
f6c1680
5c53b2d
8971850
e7870d0
5264674
65a835f
70fa991
0c608ac
85a2115
194eb6d
6c03f21
2bc16b3
437e602
af20e65
9b72dd5
4a20965
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { newE2EPage } from "@stencil/core/testing"; | ||
| import { | ||
| accessible, | ||
| defaults, | ||
| disabled, | ||
| focusable, | ||
| formAssociated, | ||
| hidden, | ||
| labelable, | ||
| reflects, | ||
| renders, | ||
| t9n, | ||
| } from "../../tests/commonTests"; | ||
| import { html } from "../../../support/formatting"; | ||
| import { toGMTLabel } from "./utils"; | ||
|
|
||
| describe("calcite-input-time-zone", () => { | ||
| describe("accessible", () => { | ||
| accessible("calcite-input-time-zone"); | ||
| }); | ||
|
|
||
| describe("focusable", () => { | ||
| focusable("calcite-input-time-zone"); | ||
| }); | ||
|
|
||
| describe("formAssociated", () => { | ||
| formAssociated("calcite-input-time-zone", { testValue: "-360", clearable: false }); | ||
| }); | ||
|
|
||
| describe("hidden", () => { | ||
| hidden("calcite-input-time-zone"); | ||
| }); | ||
|
|
||
| describe("renders", () => { | ||
| renders("calcite-input-time-zone", { display: "block" }); | ||
| }); | ||
|
|
||
| describe("labelable", () => { | ||
| labelable("calcite-input-time-zone"); | ||
| }); | ||
|
|
||
| describe("reflects", () => { | ||
| reflects("calcite-input-time-zone", [ | ||
| { propertyName: "disabled", value: true }, | ||
| { propertyName: "open", value: true }, | ||
| { propertyName: "scale", value: "m" }, | ||
| { propertyName: "overlayPositioning", value: "absolute" }, | ||
| ]); | ||
| }); | ||
|
|
||
| describe("defaults", () => { | ||
| defaults("calcite-input-time-zone", [ | ||
| { propertyName: "disabled", defaultValue: false }, | ||
| { propertyName: "messageOverrides", defaultValue: undefined }, | ||
| { propertyName: "open", defaultValue: false }, | ||
| { propertyName: "overlayPositioning", defaultValue: "absolute" }, | ||
| { propertyName: "scale", defaultValue: "m" }, | ||
| ]); | ||
| }); | ||
|
|
||
| describe("disabled", () => { | ||
| disabled("calcite-input-time-zone", { shadowAriaAttributeTargetSelector: "calcite-combobox" }); | ||
| }); | ||
|
|
||
| describe("t9n", () => { | ||
| t9n("calcite-input-time-zone"); | ||
| }); | ||
|
|
||
| describe("selects user's matching timezone offset by default", () => { | ||
| const timeZoneNamesAndOffsets = [ | ||
| { name: "America/Los_Angeles", offset: -420 }, | ||
| { name: "Europe/London", offset: 60 }, | ||
| ]; | ||
|
|
||
| timeZoneNamesAndOffsets.forEach(({ name, offset }) => { | ||
| it(`selects default timezone for "${name}"`, async () => { | ||
| const page = await newE2EPage(); | ||
| await page.emulateTimezone(name); | ||
|
jcfranco marked this conversation as resolved.
|
||
| await page.setContent(html`<calcite-input-time-zone></calcite-input-time-zone>`); | ||
| await page.waitForTimeout(1000); | ||
|
|
||
| const input = await page.find("calcite-input-time-zone"); | ||
|
|
||
| expect(await input.getProperty("value")).toBe(`${offset}`); | ||
|
|
||
| const timeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]"); | ||
|
|
||
| expect(await timeZoneItem.getProperty("textLabel")).toMatch(toGMTLabel(offset / 60)); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it("allows users to preselect a timezone offset", async () => { | ||
| const page = await newE2EPage(); | ||
| await page.emulateTimezone("America/Los_Angeles"); | ||
| await page.setContent(html`<calcite-input-time-zone value="-360"></calcite-input-time-zone>`); | ||
|
|
||
| const input = await page.find("calcite-input-time-zone"); | ||
|
|
||
| expect(await input.getProperty("value")).toBe("-360"); | ||
|
|
||
| const timeZoneItem = await page.find("calcite-input-time-zone >>> calcite-combobox-item[selected]"); | ||
|
|
||
| expect(await timeZoneItem.getProperty("textLabel")).toMatch("GMT-6"); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| :host { | ||
| display: block; | ||
| } | ||
|
jcfranco marked this conversation as resolved.
|
||
|
|
||
| @include base-component(); | ||
| @include disabled(); | ||
| @include hidden-form-input(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { select } from "@storybook/addon-knobs"; | ||
| import { boolean, storyFilters } from "../../../.storybook/helpers"; | ||
| import { modesDarkDefault } from "../../../.storybook/utils"; | ||
| import { html } from "../../../support/formatting"; | ||
| import readme from "./readme.md"; | ||
|
|
||
| export default { | ||
| title: "Components/Controls/InputTimeZone", | ||
| parameters: { | ||
| notes: readme, | ||
| options: { | ||
| timezone: "America/Los_Angeles", | ||
| }, | ||
| }, | ||
| ...storyFilters(), | ||
| }; | ||
|
|
||
| export const simple = (): string => html` | ||
| <calcite-input-time-zone | ||
| ${boolean("disabled", false)} | ||
| scale="${select("scale", ["s", "m", "l"], "m")}" | ||
| ></calcite-input-time-zone> | ||
| `; | ||
|
|
||
| export const initialOffsetSelected_TestOnly = (): string => html` | ||
| <calcite-input-time-zone value="-360"></calcite-input-time-zone> | ||
| `; | ||
|
|
||
| export const displayingTimeZoneOffsets_TestOnly = (): string => html` | ||
| <calcite-input-time-zone open></calcite-input-time-zone> | ||
| `; | ||
|
|
||
| export const disabled_TestOnly = (): string => html`<calcite-input-time-zone disabled></calcite-input-time-zone>`; | ||
|
|
||
| export const darkModeRTL_TestOnly = (): string => html` | ||
| <calcite-input-time-zone dir="rtl" class="calcite-mode-dark"></calcite-input-time-zone> | ||
| `; | ||
| darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault }; |
Uh oh!
There was an error while loading. Please reload this page.