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: wiggling nav items #123

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
22 changes: 11 additions & 11 deletions common/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,18 @@ body.no-ember {
}

.d-header-icons .icon {
height: 34px;
width: 38px;
height: 38px;
width: 42px;
padding: 2px;
margin: 0px;
border: 0px;
}
box-sizing: border-box;
border: 0px $i;
Copy link
Member Author

Choose a reason for hiding this comment

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

Took me longer than I wanted to figure this out.

The issue is:

  • The element has box-sizing being content-box, meaning its width and height don't account for padding or border.
  • We do have height being 34px (instead of 38px) to account for the top and bottom padding (2px each).
  • However, Discourse adds a border to the element when it is hovered, causing the total width and height to change.
  • The border: 0px rule here doesn't have any effect because its specificity is still lower than the selector Discourse uses.

The fix is:

  • Changing the box model to border-box, so that padding and border are accounted into the width and height (meaning we or Discourse can adjust the padding and border, but the total width and height won't change).
  • Adding the !important flag to border: 0px to remove the border.
  • Updating the width and height values to account for the padding.
    • new value = original value + 2px * 2


.drop-down-mode .d-header-icons .active .icon,
.d-header-icons .icon:hover,
.d-header-icons .icon:focus {
border: 0px;
background-color: $--gray75;
&:active,
&:hover,
&:focus {
border: 0px $i;
background-color: $--gray75 $i;
Copy link
Member Author

Choose a reason for hiding this comment

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

Without the !important flag, this rule has no effect.

}
}

.d-header-icons .btn .d-icon {
Expand Down Expand Up @@ -540,7 +540,7 @@ a.curriculum-nav:focus {
top: 0px;
}
.d-header-icons .icon {
width: 45px;
width: 49px;
}
body.no-ember .d-header #site-logo {
position: absolute;
Expand Down
Loading