Skip to content

Remove visual highlight for anchored method links #1363

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JuanitoFatas
Copy link
Member

@JuanitoFatas JuanitoFatas commented May 7, 2025

It feels a bit awkward with the scroll bar on the left 😅 E.g. Process#kill. This PR changes the visual highlight to only apply on the heading for anchored method links.

Before After
CleanShot 2025-05-07 at 23 38 43@2x CleanShot 2025-05-13 at 09 46 31@2x

@@ -581,7 +581,6 @@ main .method-detail {

main .method-detail:target {
margin-left: -10px;
border-left: 10px solid var(--border-color);
Copy link
Member

Choose a reason for hiding this comment

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

The value margin-left: -10px should be "-#{border_left_width}px". If border-left is 0, margin-left should also be 0.

However, this border-left is a highlight of the focused method. Could you suggest a better highlight instead of completely removing it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, that makes sense now. Given that the anchor link reliably brings the method to the top of the viewport, I think we could remove both border-left and margin-left.

The method name is easy to spot without extra highlighting. It will look like this if we remove both the border and margin:

CleanShot.2025-05-07.at.23.29.28.mp4

Copy link
Member

Choose a reason for hiding this comment

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

This is one of the features of RDoc. I don't want to remove it as possible if it is fixable.

This border-left exists in other links to heading tags, not only to method links.
heading_borderleft_style

Differences are:
Border-left to method links are applied to the whole div.method-detail content while border-left to other links are only applied to heading tags.

How about changing the border-left target to heading of the method detail?
It will be more consistent between method links and other links to heading tags.

- main .method-detail:target {
+ main .method-detail:target .method-heading {

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this! Pushed up 212b284 and updated the screenshot in PR body.

Copy link
Member

Choose a reason for hiding this comment

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

Can you leave the margin-left and border style as is?

There is a layout shift. On the other hand, h2:target and the original .method-detail:target doesn't have this layout shift.
layout_shift

Of course we can discuss adding a padding to h2:target and/or .method-detail:target .method-heading, with or without this layout shift.
But it's easy to merge if the point of this pull request is clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure thing. Sorry for all the back and forth. Updated.

@JuanitoFatas JuanitoFatas force-pushed the remove-border-left-from-method-details branch from 1033728 to e6fd1f8 Compare May 7, 2025 14:36
@JuanitoFatas JuanitoFatas changed the title Remove border-left from method details Remove visual highlight for anchored method links May 7, 2025
@p8
Copy link
Contributor

p8 commented May 12, 2025

In SDoc we show a small highlight next to the method as well:
image

@JuanitoFatas JuanitoFatas force-pushed the remove-border-left-from-method-details branch from e6fd1f8 to 212b284 Compare May 13, 2025 00:45
@JuanitoFatas JuanitoFatas force-pushed the remove-border-left-from-method-details branch from 212b284 to 8c02435 Compare May 14, 2025 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants