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 code action icon position in top heading #2045

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

hichemfantar
Copy link
Contributor

@hichemfantar hichemfantar commented Jan 20, 2025

Eliminate unnecessary top padding from the action icon to improve alignment in the top heading.

before
image

after
image

@hichemfantar hichemfantar changed the title Fix action icon in top heading Fix code action icon in top heading Jan 20, 2025
Copy link

github-actions bot commented Jan 20, 2025

@hichemfantar hichemfantar marked this pull request as ready for review January 20, 2025 19:37
@hichemfantar hichemfantar changed the title Fix code action icon in top heading Fix code action icon position in top heading Jan 20, 2025
@josevalim
Copy link
Member

The alignment is necessary for full page render, otherwise it feels very out of place:

Screenshot 2025-01-20 at 20 41 09

Can we make it work on both cases?

@josevalim
Copy link
Member

josevalim commented Jan 21, 2025

Perhaps as a flex element with some tiny gap between them and vertically aligned in the center?

@hichemfantar
Copy link
Contributor Author

fixed 🚀

@josevalim
Copy link
Member

Apologies but I still see undesired behaviour in your version:

Screenshot 2025-01-21 at 19 12 50

Curiously, it works well on the latest release, so this was a recent regression: https://hexdocs.pm/ex_doc/ - so we should perhaps revert to the behaviour there, which is make it float on top right consistently. This seems to be best behaviour of the ones I tested. WDYT?

@hichemfantar
Copy link
Contributor Author

i feel the new behavior is better because it gives titles more space to work with and bringing the code link lower in the screen makes it easier to mobile users to reach it

old
image

new
image

@hichemfantar
Copy link
Contributor Author

another example

old
image

new
image

@hichemfantar
Copy link
Contributor Author

hichemfantar commented Jan 21, 2025

We also no longer have to worry about perfectly aligning the icon with the title

@hichemfantar
Copy link
Contributor Author

also looks good when the title isn't long and works better because aligning with flex is more consistent instead of padding

image

@hichemfantar
Copy link
Contributor Author

whoever made the change to flex had the right idea but forgot to do some more testing which is addressed in this pr

@elixir-lang elixir-lang deleted a comment from hichemfantar Jan 21, 2025
@josevalim
Copy link
Member

I prefer the currently published version, so let's wait to see if @DavidOliver has a preference.

PS: I deleted yours and mine comment about the alignment, to keep this one on topic and easier for others to review.

@DavidOliver
Copy link
Contributor

If I remember correctly, I switched to Flexbox as part of a commit that dealt with a screenreader issue.

Can we put the action icon(s) below the heading at narrow viewport widths (wrap, both elements full width) and to the right of the heading at wider viewports (nowrap, fixed width for action icon area)? I think that would satisfy both concerns mentioned above?

Thanks.

@hichemfantar
Copy link
Contributor Author

@DavidOliver i think my fixes do just that if I’m not wrong

@DavidOliver
Copy link
Contributor

In this comment, the new screenshot seems to show the action icon below the heading. For wider viewports, I think it makes sense to keep the action icon where it was.

At narrower (mobile portrait) viewports, I can see that it may make sense to allow the heading to take the full width available, with the action icon being underneath.

@hichemfantar
Copy link
Contributor Author

@DavidOliver that only happens when the title is too long then the icon gracefully goes under it

@DavidOliver
Copy link
Contributor

I realise that, and I'm suggesting that it would be better for the icon to stay where it was and that the heading text wraps within its flex item.

Narrow viewports (maximal width for heading text):

Heading text that is
really rather long
and very descriptive
                [icon]

Medium/wide viewports (more visually pleasing alignment?):

Heading text that is really rather long and  [icon]
very descriptive

This would change the flexbox wrap/nowrap at a breakpoint.

However, I think @josevalim may not like the action icon being under the heading text at narrow viewports even if it does allow more horizontal space for the heading text, in which case we can find another way of fixing the issue in your original screenshot. I could do this if you like.

@hichemfantar
Copy link
Contributor Author

I guess enabling flex wrap only on mobile via a breakpoint is a good solution.

@hichemfantar
Copy link
Contributor Author

sure thing you can implement it if you wish

@DavidOliver
Copy link
Contributor

Okay. Let's wait to hear back from José and go from there.

@josevalim
Copy link
Member

Let's try the one @DavidOliver suggested then, because I currently prefer the one on the top always, but maybe I will be happier with the one on the middle always :D

@hichemfantar
Copy link
Contributor Author

alright so the consensus is on this

image

image

@josevalim josevalim merged commit 83e6c28 into elixir-lang:main Jan 22, 2025
4 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@josevalim
Copy link
Member

If the browser thinks that's "center", who am I to disagree :D

@hichemfantar
Copy link
Contributor Author

are you talking center vertically or horizontally?

@josevalim
Copy link
Member

Vertically Anyway, the code is good, I am just surprised by the browser :)

@DavidOliver
Copy link
Contributor

DavidOliver commented Jan 22, 2025

@josevalim, if I understand correctly, this PR doesn't yet reflect @hichemfantar's latest screenshots/mockup. I don't think the change in wrap at a certain breakpoint has been done yet?

Also, I think that if align-items is set to center, the action icon will be centred even for headings that run over multiple lines, which will look strange. (Though I haven't tried any of this out yet.) I had align-items start with padding so that the icon was aligned with the first line.

@josevalim
Copy link
Member

Oh, ok. I see. Apologies for merging too fast @hichemfantar. A new PR is appreciated. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants