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

[core] Fix MenuItem text clipping #2265

Merged
merged 13 commits into from
Mar 20, 2018
19 changes: 15 additions & 4 deletions packages/core/src/components/menu/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ $half-grid-size: $pt-grid-size / 2 !default;

$menu-item-border-radius: $pt-border-radius - 1 !default;

// Set line-height of menu items to be a multiple of the font size. This is
// needed because if the line-height does not extend far enough past the font's
// baseline, clipping will occur when the .pt-text-overflow-ellipsis class is
// applied to it (#2177).
$menu-item-line-height-factor: 1.5;
$menu-item-line-height: $pt-font-size * $menu-item-line-height-factor;
$menu-item-line-height-large: $pt-font-size-large * $menu-item-line-height-factor;

$menu-min-width: $pt-grid-size * 18 !default;
$menu-item-padding: ($pt-button-height - $pt-icon-size-standard) / 2 !default;
$menu-item-padding-large: ($pt-button-height-large - $pt-icon-size-large) / 2 !default;
$menu-item-padding-vertical: ($pt-button-height - $menu-item-line-height) / 2 !default;
$menu-item-padding-vertical-large:
($pt-button-height-large - $menu-item-line-height-large) / 2 !default;

$menu-background-color: $white !default;
$dark-menu-background-color: $dark-gray4 !default;
Expand All @@ -23,9 +34,9 @@ $dark-menu-item-color-active: $dark-minimal-button-background-color-active !defa
@include pt-flex-container(row, $menu-item-padding);
align-items: center;
border-radius: $menu-item-border-radius;
padding: $menu-item-padding;
padding: $menu-item-padding-vertical $menu-item-padding;
text-decoration: none;
line-height: $pt-icon-size-standard;
line-height: $menu-item-line-height;
color: inherit;
user-select: none;

Expand Down Expand Up @@ -103,8 +114,8 @@ $dark-menu-item-color-active: $dark-minimal-button-background-color-active !defa
}

@mixin menu-item-large() {
padding: $menu-item-padding-large $menu-item-padding;
line-height: $pt-icon-size-large;
padding: $menu-item-padding-vertical-large $menu-item-padding;
line-height: $menu-item-line-height-large;
font-size: $pt-font-size-large;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/menu/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Styleguide pt-menu
&::before,
.pt-icon {
align-self: flex-start;
Copy link
Contributor

Choose a reason for hiding this comment

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

that flex-start works for the icon on the left side, but not for the item label on the right. can you also add flex start for .pt-menu-item-label on line 69?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

margin-top: ($menu-item-line-height - $pt-icon-size-standard) / 2;
color: $pt-icon-color;
}

Expand Down Expand Up @@ -99,6 +100,7 @@ Styleguide pt-menu

&::before {
@include pt-icon($pt-icon-size-large);
margin-top: ($menu-item-line-height-large - $pt-icon-size-large) / 2;
margin-right: $menu-item-padding-large;
}
}
Expand Down