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

fix(menu)!: reimplement text truncating #2299

Merged
merged 14 commits into from
Jan 9, 2024
61 changes: 35 additions & 26 deletions components/menu/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ governing permissions and limitations under the License.
--spectrum-menu-item-icon-width: var(--spectrum-workflow-icon-size-100);
--spectrum-menu-item-label-font-size: var(--spectrum-font-size-100);
--spectrum-menu-item-label-text-to-visual: var(--spectrum-text-to-visual-100);

--spectrum-menu-item-label-inline-edge-to-content: var(--spectrum-component-edge-to-text-100);
--spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-100);
--spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-100);
Expand Down Expand Up @@ -71,7 +71,7 @@ governing permissions and limitations under the License.
--spectrum-menu-section-header-font-weight: var(--spectrum-bold-font-weight);
--spectrum-menu-section-header-color: var(--spectrum-gray-900);
--spectrum-menu-collapsible-icon-color: var(--spectrum-gray-900);

--spectrum-menu-checkmark-icon-color-default: var(--spectrum-accent-color-900);
--spectrum-menu-checkmark-icon-color-hover: var(--spectrum-accent-color-1000);
--spectrum-menu-checkmark-icon-color-down: var(--spectrum-accent-color-1100);
Expand Down Expand Up @@ -120,7 +120,7 @@ governing permissions and limitations under the License.
--spectrum-menu-item-icon-width: var(--spectrum-workflow-icon-size-75);
--spectrum-menu-item-label-font-size: var(--spectrum-font-size-75);
--spectrum-menu-item-label-text-to-visual: var(--spectrum-text-to-visual-75);

--spectrum-menu-item-label-inline-edge-to-content: var(--spectrum-component-edge-to-text-75);
--spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-75);
--spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-75);
Expand All @@ -147,7 +147,7 @@ governing permissions and limitations under the License.
--spectrum-menu-item-icon-width: var(--spectrum-workflow-icon-size-200);
--spectrum-menu-item-label-font-size: var(--spectrum-font-size-200);
--spectrum-menu-item-label-text-to-visual: var(--spectrum-text-to-visual-200);

--spectrum-menu-item-label-inline-edge-to-content: var(--spectrum-component-edge-to-text-200);
--spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-200);
--spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-200);
Expand All @@ -174,7 +174,7 @@ governing permissions and limitations under the License.
--spectrum-menu-item-icon-width: var(--spectrum-workflow-icon-size-300);
--spectrum-menu-item-label-font-size: var(--spectrum-font-size-300);
--spectrum-menu-item-label-text-to-visual: var(--spectrum-text-to-visual-300);

--spectrum-menu-item-label-inline-edge-to-content: var(--spectrum-component-edge-to-text-300);
--spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-300);
--spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-300);
Expand Down Expand Up @@ -227,7 +227,7 @@ governing permissions and limitations under the License.
--highcontrast-checkbox-highlight-color-hover: ButtonText;
--highcontrast-checkbox-highlight-color-default: ButtonText;
}

.spectrum-Menu-itemSwitch {
--highcontrast-switch-handle-border-color-hover: ButtonText;
--highcontrast-switch-handle-border-color-selected-default: ButtonText;
Expand Down Expand Up @@ -281,7 +281,7 @@ governing permissions and limitations under the License.
.spectrum-Menu-divider {
--spectrum-menu-divider-thickness: var(--spectrum-divider-thickness-medium);
&.spectrum-Divider--sizeS {
--spectrum-menu-divider-thickness: var(--spectrum-divider-thickness-small);
--spectrum-menu-divider-thickness: var(--spectrum-divider-thickness-small);
}

overflow: visible;
Expand Down Expand Up @@ -339,14 +339,14 @@ governing permissions and limitations under the License.
box-sizing: border-box;

background-color: var(--highcontrast-menu-item-background-color-default, var(--mod-menu-item-background-color-default, var(--spectrum-menu-item-background-color-default)));

line-height: var(--mod-menu-item-label-line-height, var(--spectrum-menu-item-label-line-height));

min-block-size: var(--mod-menu-item-min-height, var(--spectrum-menu-item-min-height));
padding-block-start: var(--mod-menu-item-top-edge-to-text, var(--spectrum-menu-item-top-edge-to-text));
padding-block-end: var(--mod-menu-item-bottom-edge-to-text, var(--spectrum-menu-item-bottom-edge-to-text));
padding-inline: var(--mod-menu-item-label-inline-edge-to-content, var(--spectrum-menu-item-label-inline-edge-to-content));

margin: 0;
text-decoration: none;

Expand All @@ -365,7 +365,7 @@ governing permissions and limitations under the License.

.spectrum-Menu-itemSwitch {
min-block-size: 0;

.spectrum-Switch-switch {
margin-block-start: var(--mod-menu-item-top-to-action, var(--spectrum-menu-item-top-to-action));;
margin-block-end: 0;
Expand All @@ -377,11 +377,11 @@ governing permissions and limitations under the License.
display: grid;
/* stylelint-disable declaration-block-no-redundant-longhand-properties */
grid-template-areas:
". chevronAreaCollapsible . iconArea sectionHeadingArea . . . "
". chevronAreaCollapsible . headingIconArea sectionHeadingArea . . . "
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this previously had two iconAreas which causes some issues with menu item icons and labels not being on the correct row with in the grid.

"selectedArea chevronAreaCollapsible checkmarkArea iconArea labelArea valueArea actionsArea chevronAreaDrillIn"
". . . . descriptionArea . . . "
". . . . submenuArea . . . ";

grid-template-columns: auto auto auto auto 1fr auto auto auto;
grid-template-rows: 1fr auto;
}
Expand Down Expand Up @@ -422,7 +422,7 @@ governing permissions and limitations under the License.
> .spectrum-Menu-itemValue {
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-focus, var(--spectrum-menu-item-value-color-focus)));
}

> .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-focus, var(--spectrum-menu-item-label-icon-color-focus)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-focus, var(--spectrum-menu-item-label-icon-color-focus)));
Expand Down Expand Up @@ -469,7 +469,7 @@ governing permissions and limitations under the License.
> .spectrum-Menu-itemValue {
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-hover, var(--spectrum-menu-item-value-color-hover)));
}

> .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-hover, var(--spectrum-menu-item-label-icon-color-hover)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-hover, var(--spectrum-menu-item-label-icon-color-hover)));
Expand All @@ -492,7 +492,7 @@ governing permissions and limitations under the License.
> .spectrum-Menu-itemLabel {
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-content-color-down, var(--spectrum-menu-item-label-content-color-down)));
}

> .spectrum-Menu-sectionHeading {
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-section-header-color, var(--spectrum-menu-section-header-color)));
}
Expand All @@ -504,7 +504,7 @@ governing permissions and limitations under the License.
> .spectrum-Menu-itemValue {
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-down, var(--spectrum-menu-item-value-color-down)));
}

> .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-down, var(--spectrum-menu-item-label-icon-color-down)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-down, var(--spectrum-menu-item-label-icon-color-down)));
Expand All @@ -526,6 +526,17 @@ governing permissions and limitations under the License.
align-self: start;
}

.spectrum-Menu-item--collapsible .spectrum-Menu-itemIcon {
grid-area: headingIconArea;
}

.is-selectableMultiple .spectrum-Menu-item {
align-items: start;
}
.is-selectableMultiple .spectrum-Menu-itemCheckbox {
grid-area: iconArea;
}

.spectrum-Menu-checkmark {
grid-area: checkmarkArea;
align-self: start;
Expand All @@ -537,8 +548,6 @@ governing permissions and limitations under the License.

.spectrum-Menu-itemLabel {
grid-area: labelArea;
display: flex;
align-items: flex-start;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flex was causing text-overflow: ellipsis; to not work, was able to refactor the itemLabel to not need to rely on flex. This is what appeared to of broken the truncating functionality.

font-size: var(--mod-menu-item-label-font-size, var(--spectrum-menu-item-label-font-size));
color: var(--highcontrast-menu-item-color-default, var(--mod-menu-item-label-content-color-default, var(--spectrum-menu-item-label-content-color-default)));
}
Expand Down Expand Up @@ -640,7 +649,7 @@ governing permissions and limitations under the License.
margin-inline-start: var(--mod-menu-item-label-to-value-area-min-spacing, var(--spectrum-menu-item-label-to-value-area-min-spacing));
}

.spectrum-Menu-itemLabel--wrapping {
.spectrum-Menu-itemLabel--truncate {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
Expand Down Expand Up @@ -694,11 +703,11 @@ governing permissions and limitations under the License.
}

[dir="rtl"] .spectrum-Menu-chevron {
transform: rotate(-180deg);
transform: rotate(-180deg);
}

/*
assume that if an item is collapsible, it will
assume that if an item is collapsible, it will
have a chevron and we need to adjust position of submenu items to account for that
*/
.spectrum-Menu-item--collapsible .spectrum-Menu {
Expand Down Expand Up @@ -745,22 +754,22 @@ governing permissions and limitations under the License.
.spectrum-Menu-chevron {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-hover, var(--spectrum-menu-drillin-icon-color-hover)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-hover, var(--spectrum-menu-drillin-icon-color-hover)));
}
}
}

&:focus,
&.is-focused {
.spectrum-Menu-chevron {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-focus, var(--spectrum-menu-drillin-icon-color-focus)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-focus, var(--spectrum-menu-drillin-icon-color-focus)));
}
}
}

&:active {
.spectrum-Menu-chevron {
fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-down, var(--spectrum-menu-drillin-icon-color-down)));
color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-drillin-icon-color-down, var(--spectrum-menu-drillin-icon-color-down)));
}
}
}
}

Expand All @@ -773,11 +782,11 @@ governing permissions and limitations under the License.
.spectrum-Menu-sectionHeading {
color: var(--highcontrast-menu-item-color-disabled, var(--mod-menu-item-label-content-color-disabled, var(--spectrum-menu-item-label-content-color-disabled)));
}

.spectrum-Menu-itemDescription {
color: var(--highcontrast-menu-item-color-disabled, var(--mod-menu-item-description-color-disabled, var(--spectrum-menu-item-description-color-disabled)));
}

.spectrum-Menu-itemIcon {
fill: var(--highcontrast-menu-item-color-disabled, var(--mod-menu-item-label-icon-color-disabled, var(--spectrum-menu-item-label-icon-color-disabled)));
color: var(--highcontrast-menu-item-color-disabled, var(--mod-menu-item-label-icon-color-disabled, var(--spectrum-menu-item-label-icon-color-disabled)));
Expand Down
Loading
Loading