Skip to content

Commit 8cb4376

Browse files
authored
Adjust sidenotes to not rely on border width subtraction (#58)
Closes #26. [As I outlined in the issue:](#26 (comment)) > The reason you're still seeing the issue is that borders (and borders in particular) are rounded by the browser to device pixel boundaries. Thus, the computation for the [smaller padding to compensate for the bigger border] doesn't exactly match the change in border width. The end result is a barely-noticeable layout shift. > There's no way to soundly fix this since rounding behavior depends on display, pixel density, and zoom. Instead, I can change our style to change the border color and add a drop shadow to highlight the hovered-over note. This precludes the need for the computation I described (because the border width now remains constant), and thus removes any place where rounding can make its way in. This PR does this. | No Hover | Old Hover | New Hover | |-|-|-| |![notenohover](https://github.com/user-attachments/assets/df2e6830-2bd2-4f39-b750-1d6fb339a13b)|![noteoldhover](https://github.com/user-attachments/assets/d65ff3cd-a15d-4fde-9065-615ae2ded0ca)|![notenewhover](https://github.com/user-attachments/assets/9cef7c6f-ba53-42b8-8f1f-bd76b1909aed)| I think it looks pretty nice: <img width="1034" height="476" alt="Screenshot 2026-02-23 at 10 34 02 AM" src="https://github.com/user-attachments/assets/bf17a322-2dfe-40d2-9cae-417cba8d9ac3" /> Reviewed by @benharsh -- thanks! ## Testing - [x] hover no longer changes line breaks in sidenotes on any zoom level I tried in the 10 myths, part 7 post from the original issue.
2 parents 60b99a2 + c5d2ad0 commit 8cb4376

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

themes/chapel-theme/assets/scss/sidenotes.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@import "margin.scss";
44

55
$sidenote-padding: 1rem;
6-
$sidenote-highlight-border-width: .2rem;
6+
$sidenote-highlight-border-width: $standard-border-width;
77

88
.sidenote {
99
&:hover {
@@ -13,10 +13,11 @@ $sidenote-highlight-border-width: .2rem;
1313
}
1414

1515
.sidenote-content {
16-
border: $sidenote-highlight-border-width dashed;
16+
border: $sidenote-highlight-border-width solid;
1717
padding: $sidenote-padding -
1818
($sidenote-highlight-border-width - $standard-border-width);
1919
border-color: $primary-color;
20+
box-shadow: 0 0 0.4rem rgba(darken($primary-color, 20%), 0.3);
2021
}
2122
}
2223
}

0 commit comments

Comments
 (0)