-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
refactor(theme-classic): consistently add span wrapper for layout links #6846
Conversation
✔️ [V2] 🔨 Explore the source changes: 9b10c23 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6228a39802c58000086cc663 😎 Browse the preview: https://deploy-preview-6846--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6846--docusaurus-2.netlify.app/ |
Size Change: +310 B (0%) Total Size: 791 kB
ℹ️ View Unchanged
|
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 agree but at the same time it does not lead to the exact same result 😅
The footer looks fine, and we don't have preview tests for navbar link item.
Maybe it would be better to add a span consistently to the sidebar item?
Oh, huh, I rather like the current result 😄 I think we once right-aligned the icons but later made them flushed left? Can't remember why though |
For consistency with navbar and footer and UI retro compatibility (this PR is not about design) I'd rather keep the original design for now Open to discussing design changes but IMHO it's not really better. Maybe we can create a poll on discord or something |
Yeah, not saying I want to introduce that difference in this PR, just that I honestly think it makes sense. |
seems to work fine thanks 👍 |
This was actually done intentionally, personally I've always been against extra elements that aren't needed at all. Why is consistency so important in this case? Its lack didn't affect on customization, at least there were no complaints from users, right? Currently I see just a bunch of extra wrapper elements -- it complicates final DOM and increases page size (a bit, but still...).
You just need to target on link element, or use |
I was the one that complained, because I do lots of customizations on my own sites😅 In order to target the text node my CSS has to reach into that
These Infima class names are discouraged to be targeted in our docs because they are implementation details. I also don't feel like it's worth adding another stable class name that's just the direct child of the current I understand the concern of bundle size—I also have a page size OCD. We may do another minor breaking change in the near future to remove that span, but that depends on whether we want the external link icons to be right-aligned (behavior without the span tag) or left-aligned (behavior with the span tag). |
I'm not sure this is efficient, in the sense that it's a rare use case anyway, and it's rather acceptable to target on Infima classes, given that the custom CSS file is designed for that purpose. Why not just target on I mean, curretly this change affects on all sites, regardless of the fact that it was mostly avoidable, which is not a good thing. |
I think in the future it might be worth it to keep this extra spam and add a "stable className" to the label, eventually have a dedicated component just for that kind of sidebar label in our design system There's a tradeoff to be made:
Unfortunately, it's hard to have both at the same time. In general I'd rather optimize for the later, as IMHO nobody ever complained that the site is 5-10% heavier, while many feel the pain of upgrading a highly customized site due to CSS selectors breaking. When we add extra wrappers and stable classNames (non-infima), we increase HTML size on purpose to increase customization robustness. |
Alright, I found a simple solution on how we can get rid of |
Motivation
I'm constantly frustrated by the inconsistent DOM between internal and external links, because that means if I want to apply CSS to the text, I have to target both
a
anda > span
.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Should have no layout changes