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

refactor(v2): introduce Logo component, remove useLogo hook #3745

Merged
merged 3 commits into from
Nov 16, 2020

Conversation

Simek
Copy link
Contributor

@Simek Simek commented Nov 13, 2020

Motivation

Since the ThemedImage component has been added, it would be nice to utilize it in the theme files. First thing that came to my mind was the site logo component. After studying a code for a bit, it came apparent that very similar code is used in the all places, so it can be quite easily extracted to the separate file.

When I have finished the extraction, the next thing that picked up my attention was useLogo hook, which after the refactor seems redundant too (code can be moved to the newly created Logo component).

This hook has not been documented yet on the website - https://v2.docusaurus.io/docs/theme-classic#hooks - (in opposition to the theme-bootstrap hook - https://v2.docusaurus.io/docs/theme-bootstrap/#uselogo), so I think that the removal shouldn't hurt any users. This change also makes code structure a bit simpler.

In addition to the changes described above this refactor fixes a HTML check warning when user do not specified the logo.alt field in the navbar config (fallback to title, then just to "Logo" string).

Unfortunately the sources had to be extracted to the variable due to Rule of Hooks conditional call warnings.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Refactor has been tested on the Docusuaurs V2 website locally.

Related PRs

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 13, 2020
@netlify
Copy link

netlify bot commented Nov 13, 2020

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit f49c56c

https://deploy-preview-3745--docusaurus-2.netlify.app

@netlify
Copy link

netlify bot commented Nov 13, 2020

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 41afde2

https://deploy-preview-3745--docusaurus-2.netlify.app

Copy link
Contributor

@lex111 lex111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! 👍

@lex111 lex111 added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Nov 13, 2020
@lex111 lex111 changed the title fix(v2): refactor theme-classic logo, remove useLogo hook refactor(v2): introduce Logo component, remove useLogo hook Nov 13, 2020
@slorber
Copy link
Collaborator

slorber commented Nov 16, 2020

LGTM thanks, happy to remove that useLogo hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants