-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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 overflowing text content in footer link #6519
Conversation
Add an ellipsis to overflowing text in the footer section for navigating between different references.
Fix overflowing text content in footer link
Size changes📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Three Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
@Huxpro could you kindly review this fix and let me know if there are any further changes to be made? |
@@ -78,12 +78,12 @@ function FooterLink({ | |||
className="text-tertiary dark:text-tertiary-dark inline group-focus:text-link dark:group-focus:text-link-dark" | |||
displayDirection={type === 'Previous' ? 'start' : 'end'} | |||
/> | |||
<span> | |||
<span className="block no-underline text-sm tracking-wide text-secondary dark:text-secondary-dark uppercase font-bold group-focus:text-link dark:group-focus:text-link-dark group-focus:text-opacity-100"> | |||
<div className="flex flex-col overflow-hidden"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hiding the overflow, what if we update the NextLink classes above, with this:
- md:w-80
+ md:w-fit md:min-w-80
This will expand the hoverable area to fit the content, with a minimum width of 80, so you can read the full API name, but shorter names will still be 80w:
Screen.Recording.2024-01-09.at.12.24.22.PM.mov
Note: this will require either adding { minWidth: { 80: '20rem' } }
to the tailwind config, or upgrading to the latest tailwind version because min-w-x
was added in 3.4: https://tailwindcss.com/blog/tailwindcss-v3-4#extended-min-width-max-width-and-min-height-scales
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably update the tailwind config in this PR and do the tailwind upgrade in a separate PR.
In tailwind.config.js
replace:
maxWidth: {
xs: '21rem',
},
With:
maxWidth: {
// add this because it should be there anyway
...defaultTheme.maxWidth,
xs: '21rem',
},
minWidth: {
...defaultTheme.minWidth,
80: '20rem',
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rickhanlonii thank you for reviewing my PR. I agree with your suggestions, but I feel there's a small caveat. If we set the width to w-fit
on the NextLink
directly, there'd be no upper limit, meaning extra long strings would overlap the adjacent PREVIOUS card.
I could think of 2 ways to solve this:
METHOD 1 - Remove explicit width
Instead we could remove the explicit width on the NextLink
and add only md:w-fit
to the child div
(since there's no width defined on the parent wrapper element, each hoverable card would occupy the full space, i.e, 50% of the total space available) regardless of the size of the content rendered within.
However, longer strings are rendered on multiple lines, so we retain the overflow-hidden
.
METHOD 2 - Set max width along with min width
We add min-w-80
and w-fit
and along with it we also set the max-width (max-w-md
), and retain the overflow property to handle the string that is longer than what the max width can accommodate.
recording.mp4
Currently, I have implemented the second approach. But I'd love to know your thoughts on this and if I should change anything further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'm not concerned about it for APIs, but for translations this could be a problem.
Can method 2 wrap at max width instead of truncating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that's a good idea. I tried adding a long string to the footer link with wrap instead of truncating it, and, we're able to show the complete string without loss of information(non-truncating). It is also in line with how long strings are rendered on the sidebar.
I've implemented break-words
to break-normal
for wrapping the string. Below is a snapshot of a long string with no spaces in it.
Since I'm using a class sorter extension on my VSCode, a few class names in DocsFooter.tsx
have been re-arranged. I hope that's not an issue. But let me know if I have to revert it.
Looks great, thanks a ton for working on this! |
💫 Changelog
⭐ Fixes issue: #6460
⭐ Added
text-overflow: ellipsis
to show ellipsis on lengthy strings, with the addition oftitle
attribute on thespan
element that shows the complete string on a tooltip on hovering the truncated string.⭐
block
property is now removed from thespan
element asspan
s are inherentlyinline
and I feel making them behave as ablock
level element is semantically wrong. Instead, now we render the elements in a column-oriented flex container.⭐ The parent container of the link string and the "Next/Previous" string is now housed by a
div
instead of aspan
Existing UI
Updated UI