Skip to content
Merged
8 changes: 4 additions & 4 deletions src/components/DocsFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Copy link
Member

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

Copy link
Member

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',
},

Copy link
Contributor Author

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.
case1
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.
case5

case2

However, longer strings are rendered on multiple lines, so we retain the overflow-hidden.
case3

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.

Copy link
Member

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?

Copy link
Contributor Author

@prajwalkulkarni prajwalkulkarni Jan 12, 2024

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.
wrap2

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.
wrap

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.

<span className="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">
{type}
</span>
<span className="block text-lg group-hover:underline">{title}</span>
</span>
<span className="overflow-hidden whitespace-nowrap text-ellipsis text-lg group-hover:underline" title={title}>{title}</span>
</div>
</NextLink>
);
}