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

feat(navigation): remove prefix nav for menu and menu-item #6774

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
4 changes: 4 additions & 0 deletions src/components/menu-item/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface MenuItemEvent {
event: KeyboardEvent;
children: HTMLCalciteMenuItemElement[];
}
110 changes: 110 additions & 0 deletions src/components/menu-item/menu-item.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { newE2EPage } from "@stencil/core/testing";
import { html } from "../../../support/formatting";
import { accessible, focusable, hidden, reflects, renders } from "../../tests/commonTests";

describe("calcite-menu-item", () => {
it("renders", async () => renders("calcite-menu-item", { display: "flex" }));

it("reflects", async () =>
reflects("calcite-menu-item", [
{
propertyName: "active",
value: "true"
},
{
propertyName: "editable",
value: "true"
},
{
propertyName: "iconStart",
value: "layers"
},
{
propertyName: "iconEnd",
value: "layers"
},
{
propertyName: "href",
value: "www.esri.com"
},
{
propertyName: "target",
value: "_blank"
},
{
propertyName: "text",
value: "Calcite"
}
]));

it("honors hidden attribute", async () => hidden("calcite-menu-item"));

it("is accessible", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-menu> <calcite-menu-item text="calcite"> </calcite-menu-item> </calcite-menu>`);
await accessible("calcite-menu-item", page);
});

it("is focusable", () => focusable("calcite-menu-item"));

describe("mouse support", () => {
it("should open the submenu on click", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-menu>
<calcite-menu-item id="ArcGISOnline" text="ArcGISOnline">
<calcite-menu-item id="ArcGISJS" text="ArcGISJS" slot="menu-item-dropdown">
<calcite-menu-item text="API" id="API" slot="menu-item-dropdown"></calcite-menu-item>
<calcite-menu-item text="Widgets" id="Widgets" slot="menu-item-dropdown"> </calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item text="Calcite" id="Calcite" slot="menu-item-dropdown"> </calcite-menu-item>
</calcite-menu-item>
</calcite-menu>`);

const menuItem = await page.find("calcite-menu-item[id='ArcGISOnline']");
const menuItemMenu = await page.find("calcite-menu-item[id='ArcGISOnline'] >>> calcite-menu");

expect(await menuItemMenu.isVisible()).toBe(false);

await menuItem.click();
await page.waitForChanges();
expect(await menuItemMenu.isVisible()).toBe(true);
expect(await page.evaluate(() => document.activeElement.id)).toBe("ArcGISOnline");

const subMenuItem = await page.find("calcite-menu-item[text='ArcGISJS']");
const subMenuItemMenu = await page.find("calcite-menu-item[text='ArcGISJS'] >>> calcite-menu");
expect(await subMenuItemMenu.isVisible()).toBe(false);
await subMenuItem.click();
await page.waitForChanges();
expect(await subMenuItemMenu.isVisible()).toBe(true);
expect(await page.evaluate(() => document.activeElement.id)).toBe("ArcGISJS");
});

it("should close any opened submenu when clicked outside", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-menu>
<calcite-menu-item id="ArcGISOnline" text="ArcGISOnline">
<calcite-menu-item text="ArcGISJS" slot="menu-item-dropdown"> </calcite-menu-item>
<calcite-menu-item text="Calcite" slot="menu-item-dropdown"> </calcite-menu-item>
</calcite-menu-item>
</calcite-menu>`);

const menuItem = await page.find("calcite-menu-item[id='ArcGISOnline']");
const menuItemMenu = await page.find("calcite-menu-item[id='ArcGISOnline'] >>> calcite-menu");

expect(await menuItemMenu.isVisible()).toBe(false);

await menuItem.click();
await page.waitForChanges();
expect(await menuItemMenu.isVisible()).toBe(true);
expect(await page.evaluate(() => document.activeElement.id)).toBe("ArcGISOnline");

const menuElement = await page.$("calcite-menu");
const { x, y, width, height } = await menuElement.boundingBox();

await page.mouse.click(x + width + 50, y + height + 50);
await page.waitForChanges();
expect(await menuItemMenu.isVisible()).toBe(false);
expect(await page.evaluate(() => document.activeElement.id)).not.toBe("ArcGISOnline");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
&:hover > calcite-action {
border-inline-start-color: var(-calcite-ui-border-3);
}
--calcite-nav-menu-item-font-weight: 400;
--calcite-menu-item-font-weight: 400;
}

.container,
Expand Down Expand Up @@ -56,7 +56,7 @@ a:hover ~ calcite-action {
text-0
text-color-2 box-border;
text-decoration: none;
font-weight: var(--calcite-nav-menu-item-font-weight);
font-weight: var(--calcite-menu-item-font-weight);
border-block-end: 2px solid transparent;

& span {
Expand Down Expand Up @@ -213,7 +213,7 @@ a:active {

box-shadow: none;
border: none;
& ::slotted(calcite-nav-menu-item) {
& ::slotted(calcite-menu-item) {
padding-inline-start: 28px;
inline-size: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default {
};

export const simple = (): string => html`<calcite-nav
><calcite-nav-menu slot="primary-content-center">
<calcite-nav-menu-item
><calcite-menu slot="primary-content-center">
<calcite-menu-item
text="${text("text", "My nav item")}"
src="${text("src", "")}"
href="${text("href", "")}"
Expand All @@ -23,12 +23,12 @@ export const simple = (): string => html`<calcite-nav
${boolean("breadcrumb", false)}
${boolean("editable", false)}
${boolean("text-enabled", true)}
/> </calcite-nav-menu
/> </calcite-menu
></calcite-nav>`;

export const iconStart = (): string => html`<calcite-nav
><calcite-nav-menu slot="primary-content-center">
<calcite-nav-menu-item
><calcite-menu slot="primary-content-center">
<calcite-menu-item
text="${text("text", "My nav item")}"
src="${text("src", "")}"
href="${text("href", "")}"
Expand All @@ -39,12 +39,12 @@ export const iconStart = (): string => html`<calcite-nav
${boolean("breadcrumb", false)}
${boolean("editable", false)}
${boolean("text-enabled", true)}
/> </calcite-nav-menu
/> </calcite-menu
></calcite-nav>`;

export const iconEnd = (): string => html`<calcite-nav
><calcite-nav-menu slot="primary-content-center">
<calcite-nav-menu-item
><calcite-menu slot="primary-content-center">
<calcite-menu-item
text="${text("text", "My nav item")}"
src="${text("src", "")}"
href="${text("href", "")}"
Expand All @@ -55,12 +55,12 @@ export const iconEnd = (): string => html`<calcite-nav
${boolean("breadcrumb", false)}
${boolean("editable", false)}
${boolean("text-enabled", true)}
/> </calcite-nav-menu
/> </calcite-menu
></calcite-nav>`;

export const iconsBoth = (): string => html`<calcite-nav
><calcite-nav-menu slot="primary-content-center">
<calcite-nav-menu-item
><calcite-menu slot="primary-content-center">
<calcite-menu-item
text="${text("text", "My nav item")}"
src="${text("src", "")}"
href="${text("href", "")}"
Expand All @@ -72,5 +72,5 @@ export const iconsBoth = (): string => html`<calcite-nav
${boolean("breadcrumb", false)}
${boolean("editable", false)}
${boolean("text-enabled", true)}
/> </calcite-nav-menu
/> </calcite-menu
></calcite-nav>`;
Loading