-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(theme-classic): allow specifying width/height in logo #5770
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
Conversation
✔️ [V2] 🔨 Explore the source changes: 55c68e3 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/617fba3a9593f100078960e6 😎 Browse the preview: https://deploy-preview-5770--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5770--docusaurus-2.netlify.app/ |
Let me know what you think about code change I will follow it up with doc change if the code changes are in the right direction. |
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.
Thanks
In any case, we don't want to change the current API and avoid any breaking change.
Using a string remains the simple option for the end user, and Docusaurus should later handle it automatically by transforming it to an ImageObject: it should not be done by the user (or at least it should not be mandatory).
I suggest we could just forward additional props to the img element directly, and write in our own website config:
module.exports = {
themeConfig: {
navbar: {
title: 'Site Title',
logo: {
src: 'img/logo.png',
width: 50,
height: 50,
className: "my-custom-logo"
},
},
},
};
We'll figure out later how to automatically infer a good default width/height for the referenced FS image
Not sure if it is/isn't a problem but in this case width/height would be shared between logo from src and srcDark. |
That does not seem like a big deal: users should use logos of same size to avoid layout shifts anyway, and has the responsibility to not mess things up: we just pass through, no additional logic |
Well had more of responsive logo idea in mind then src/srcDark really, but I guess if there is no plan for it, it can be added later |
Not sure what you mean, but 2 logos with different widths means clicking on the theme switch will shift navbar items: bad UX |
One missing thing in this PR is the documentation change to describe config for width/height @Josh-Cena |
Sure, thanks :) |
I think this is good enough for now. We can try:
But those can be in follow-ups. This solution is fine. |
I still think there is usecase for responsive logos, I would wait for the "PlatformSpecific" feature to be implemented, and then we could add platform specific to the logo setting to support responsive logo usecase if theme supports platforms like high DPI phones. Here are examples of "responsive logos": |
Ah, yes, we could look into that. We don't want logos to be responsive to light/dark, but screen sizes sound fine. Beware though that currently all logo usages are scaled so that their sizes are invariant on all screen sizes. |
Maybe we could allow passing a I think lighthouse might still report an error though, and you'll need to keep the width/height |
|
@alex-drocks this is a different issue. If you are using a base URL you are probably experiencing #5863, which has been fixed in a canary release. |
Thanks Josh, yes in fact I am using a baseUrl. For reference to other readers, it means i am not using the default localhost:port/ base but something like localhost:port/my-base-path/... |
Motivation
Fixes #5724
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Check manually if new config works,
snapshot tests for website should not change with new config