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(menu-item): Update spacing and icon layout #7381

Merged
merged 19 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -68,6 +68,9 @@
--calcite-ui-icon-color: var(--calcite-ui-brand);
}
}
:host([layout="vertical"]) .content {
@apply px-3;
}

.icon--start {
@apply me-3;
Expand All @@ -77,13 +80,25 @@
@apply ms-3;
}

:host([layout="vertical"]) .icon--end {
@apply ms-auto;
}

.icon--dropdown {
@apply ms-auto me-0 ps-2 relative;
--calcite-ui-icon-color: var(--calcite-ui-text-3);
}

:host([layout="vertical"]) .icon--dropdown {
inset-inline-start: theme("spacing.1");
:host([layout="vertical"]) .icon--end ~ .icon--dropdown {
@apply ms-3;
}

:host([layout="vertical"]) .hover-href-icon ~ .icon--end {
@apply ms-4;
}

:host([layout="vertical"]) .hover-href-icon {
@apply ps-2;
}

.icon--breadcrumb {
Expand Down Expand Up @@ -151,7 +166,7 @@ calcite-action {
}

:host([slot="submenu-item"]) .parent--vertical {
padding-inline-start: theme("spacing.7");
@apply ps-6;
}

.dropdown-menu-items.nested.calcite--rtl {
Expand All @@ -163,7 +178,7 @@ calcite-action {
}

.hover-href-icon {
@apply ps-8 ms-auto relative end-1 opacity-0;
@apply ms-auto relative end-1 opacity-0;
transition: all var(--calcite-internal-animation-timing-medium) ease-in-out;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,13 @@ export class CalciteMenuItem implements LoadableComponent, T9nComponent, Localiz
<div class={CSS.textContainer}>
<span>{this.text}</span>
</div>
{this.href && (this.topLevelMenuLayout === "vertical" || !this.isTopLevelItem) ? (
<calcite-icon
class={CSS.hoverHrefIcon}
icon={dir === "rtl" ? "arrow-left" : "arrow-right"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a key attr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to its own render method and added a key.

scale="s"
/>
) : null}
{this.iconEnd && this.renderIconEnd()}
{this.breadcrumb ? this.renderBreadcrumbIcon(dir) : null}
{!this.href && this.hasSubmenu ? this.renderDropdownIcon(dir) : null}
Expand Down Expand Up @@ -480,13 +487,6 @@ export class CalciteMenuItem implements LoadableComponent, T9nComponent, Localiz
ref={(el) => (this.anchorEl = el)}
>
{this.renderItemContent(dir)}
{this.href && (this.topLevelMenuLayout === "vertical" || !this.isTopLevelItem) ? (
<calcite-icon
class={CSS.hoverHrefIcon}
icon={dir === "rtl" ? "arrow-left" : "arrow-right"}
scale="s"
/>
) : null}
</a>
{this.href && this.hasSubmenu ? this.renderDropdownAction(dir) : null}
</div>
Expand Down
58 changes: 57 additions & 1 deletion packages/calcite-components/src/components/menu/menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,63 @@ export const darkModeRTL_TestOnly = (): string => html`<calcite-menu dir="rtl" c
<calcite-menu-item text="Example item 3" text-enabled></calcite-menu-item>
</calcite-menu>`;

export const verticalLyoutInDarkModeRTL_TestOnly = (): string => html`<calcite-menu
export const verticalComplexUseCase_TestOnly = (): string => html`<calcite-shell-panel
slot="panel-start"
width-scale="l"
>
<calcite-panel heading="Example vertical menu">
<calcite-menu layout="vertical">
<calcite-menu-item icon-start="layer" icon-end="layer" text="Home"> </calcite-menu-item>
<calcite-menu-item icon-start="layer" icon-end="layer" href="#" text="Example nested" icon-start="layer">
<calcite-menu-item icon-end="layer" icon-start="layer" slot="submenu-item" text="Capabilities">
</calcite-menu-item>
<calcite-menu-item icon-start="layer" slot="submenu-item" title text="ArcGIS Online">
<calcite-menu-item icon-start="layer" slot="submenu-item" text="Capabilities">
<calcite-menu-item icon-start="layer" slot="submenu-item" text="Capabilities"> </calcite-menu-item>
<calcite-menu-item icon-start="layer" slot="submenu-item" text="Capabilities"> </calcite-menu-item>
<calcite-menu-item icon-start="layer" slot="submenu-item" text="Capabilities"> </calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item text="Example nested" icon-start="layer" icon-end="layer" open>
<calcite-menu-item slot="submenu-item" title text="ArcGIS Online">
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Capabilities">
<calcite-menu-item slot="submenu-item" text="Capabilities"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Something else"> </calcite-menu-item>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: empty tags should avoid whitespace.

<calcite-menu-item slot="submenu-item" text="Another thing">
<calcite-menu-item slot="submenu-item" text="Great examples">
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item open href="#" slot="submenu-item" text="It's stupendous">
<calcite-menu-item slot="submenu-item" text="Very nice example"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Short one">
<calcite-menu-item open slot="submenu-item" text="Another thing">
<calcite-menu-item slot="submenu-item" text="Great examples">
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Great examples"> </calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Capabilities"> </calcite-menu-item>
</calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Capabilities"> </calcite-menu-item>
<calcite-menu-item text="Reference" active> </calcite-menu-item>
<calcite-menu-item text="Reference"> </calcite-menu-item>
<calcite-menu-item text="Reference"> </calcite-menu-item>
</calcite-menu>
</calcite-panel>
</calcite-shell-panel>`;

export const verticalLayoutInDarkModeRTL_TestOnly = (): string => html`<calcite-menu
layout="vertical"
dir="rtl"
class="calcite-mode-dark"
Expand Down