Skip to content

Enhance : Make logo inherit the site background/gradient - #69693

Closed
Mayank-Tripathi32 wants to merge 5 commits into
WordPress:trunkfrom
Mayank-Tripathi32:try/enhance-add-logo-bg-effect
Closed

Mayank-Tripathi32 wants to merge 5 commits into
WordPress:trunkfrom
Mayank-Tripathi32:try/enhance-add-logo-bg-effect

Conversation

@Mayank-Tripathi32

@Mayank-Tripathi32 Mayank-Tripathi32 commented Mar 25, 2025 •

Copy link
Copy Markdown
Member

Fixes #49501

What?

When a user uploads an image to the Site Logo block for the first time, a square crop of that image is also used as the Site Icon. In common setups—like sites with white logos on transparent backgrounds and dark text—this results in a barely visible site icon.

To solve this, we apply the site's background color behind the site logo image directly via inline styles. This ensures that the logo maintains its intended contrast regardless of transparency in both site editor and post editor.

Why?

  • Improves visual accessibility and brand clarity by preserving the intended logo contrast (if logo is still not visible then user could adjust background color/gradiant of site.
  • Prevents a poor user experience where the site icon appears invisible or unclear due to a transparent or white logo without a contrasting background.

How?

I used the internal globalStylesDataKey from the block editor’s private APIs to fetch the global styles set in the Site Editor. Then, we applied the background and text color directly to the image element within the Site Logo block using inline styles:

import {
	privateApis as blockEditorPrivateApis,
	store as blockEditorStore,
} from '@wordpress/block-editor';
import { unlock } from '../../lock-unlock';

const { globalStylesDataKey } = unlock(blockEditorPrivateApis);

const globalStyles = useSelect((select) => {
	const settings = select(blockEditorStore).getSettings();
	return settings[globalStylesDataKey];
}, []);

style={{
	background: globalStyles?.color?.gradient
		? globalStyles?.color?.gradient
		: globalStyles?.color?.background, // apply the gradiant, color to background of icon
	color: globalStyles?.color?.text, // apply the color for border on hover
}}

This ensures the logo always renders on a background consistent with the site's design system.

ScreenShots

image
image
image

@carolinan

Copy link
Copy Markdown
Contributor

Can you please update the title and description so that it is clear that this pull request is not related to the site logo block.

@Mayank-Tripathi32 Mayank-Tripathi32 changed the title Enhance Site Logo: Make logo inherit the site background/gradient Enhance : Make logo inherit the site background/gradient Apr 7, 2025
@Mayank-Tripathi32
Mayank-Tripathi32 force-pushed the try/enhance-add-logo-bg-effect branch from fda6e57 to 6685508 Compare April 11, 2025 15:06
@Mayank-Tripathi32
Mayank-Tripathi32 marked this pull request as ready for review April 11, 2025 16:35
@github-actions

github-actions Bot commented Apr 11, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @filipanoscampos.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: filipanoscampos.

Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: SirLouen <sirlouen@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: courtneyr-dev <courane01@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: lukecarbis <lukecarbis@git.wordpress.org>
Co-authored-by: aurooba <aurooba@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mayank-Tripathi32

Copy link
Copy Markdown
Member Author

Hi @t-hamano, Can you help me re-run the tests whenever possible? They been stuck for days now.

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Block] Site Logo Affects the Site Logo Block labels Jun 4, 2025
@Mayank-Tripathi32
Mayank-Tripathi32 force-pushed the try/enhance-add-logo-bg-effect branch from 9c49fa4 to 3cd6fd7 Compare June 4, 2025 11:51
@Mayank-Tripathi32
Mayank-Tripathi32 force-pushed the try/enhance-add-logo-bg-effect branch from 3cd6fd7 to 96b66b1 Compare December 28, 2025 19:13
@github-actions github-actions Bot added [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site labels Dec 28, 2025
@jasmussen
jasmussen requested a review from a team December 29, 2025 09:17
@jasmussen

Copy link
Copy Markdown
Contributor

One question, can we inherit just the background color? And can we make sure it applies also here?

image

@SirLouen SirLouen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test Report

Description

❌ This report can't validate that the indicated patch works as expected.

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.2.29
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 143.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Three 1.6
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 22.3.0
    • Test Reports 1.2.1

Actual Results

  1. ❌ Issue failing with this patch.

Additional Notes

I've found one major issue

Using this Playground instance:
https://playground.wordpress.net/?gutenberg-branch=trunk&gutenberg-pr=69693&theme=twentytwentythree

Without site logo, this is the default:

Image

But with this PR it looks like this

Image

@SirLouen

Copy link
Copy Markdown
Member

One question, can we inherit just the background color? And can we make sure it applies also here?

image

In fact, I don't understand why the site logo is being added there, isntead of fixing to the W logo just like in the Admin UI

image

@SirLouen

Copy link
Copy Markdown
Member

This was implemented back in #46736 when the editor looked like this

image

I truly believe that we could open a PR and switch from SiteIcon to the generic WordPress icon that looks better there.

cc @youknowriad

@youknowriad

Copy link
Copy Markdown
Contributor

The logic is that the site icon used there is important in multi-site contexts to understand what site you're in.

@t-hamano

t-hamano commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

What do you think about applying the site background to the logo only when a custom site logo is used, and keeping the dark background otherwise?

@youknowriad

Copy link
Copy Markdown
Contributor

What's the idea behind applying the site background?

I feel like the site logo is something that should stand on its own irrelevant of background (kind of like the site icon on browser tabs) so maybe I'm missing something but I don't really see why we should reflect the site background in the site icon.

@t-hamano

t-hamano commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

A typical problem is that the site icon is hard to see when it's gray:

229053332-f6ace5de-bc6d-4ca4-86a9-0be50b505a85

Another approach was to add a stroke around the logo: #73816

@youknowriad

Copy link
Copy Markdown
Contributor

I think we'd be just swapping some set of issues with another set of issues + a lot of added complexity. Nothing guarantees that the site icon applies well on top of the site top level background.

@richtabor

Copy link
Copy Markdown
Member

I think we'd be just swapping some set of issues with another set of issues + a lot of added complexity. Nothing guarantees that the site icon applies well on top of the site top level background.

Agreed. Or that the site logo is applied over the site background (could be within a header with a background color).

@SirLouen

SirLouen commented Jan 5, 2026

Copy link
Copy Markdown
Member

The logic is that the site icon used there is important in multi-site contexts to understand what site you're in.

Not sure if the logo is the ideal solution (for all the problems expressed here). I would have opted for a similar solution as the current admin dashboard (name of the site in the multisite).

@t-hamano

t-hamano commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

So should we close this PR, assuming the current behavior is correct? Or should we always show the W logo instead of the custom icon?

@SirLouen

SirLouen commented Jan 6, 2026 •

Copy link
Copy Markdown
Member

So should we close this PR, assuming the current behavior is correct? Or should we always show the W logo instead of the custom icon?

The idea is definitely an improvement for the back button.

The problem I see frequently is that we loosely expand the scope of the PR because someone notices something else, and then the whole discussion ends at a frustration point when we consider closing it all around.

I truly believe that this must fix the back button issue. As soon as de logo color collides with the default background of the back button, it will be a monocolor weird square. The PR is heading in the right direction but still needs more of work.

For the little logo in the editor that @jasmussen commented on, open or ignore with a future PR. Don't try to kill 2 birds with one stone.

@SirLouen

SirLouen commented Feb 6, 2026

Copy link
Copy Markdown
Member

Feel free to unblock this. I cannot unblock it myself other than accepting changes.

@jasmussen

Copy link
Copy Markdown
Contributor

I'd love to see this land so that transparent black PNG logos are visible as "back" buttons.

@Mayank-Tripathi32

Copy link
Copy Markdown
Member Author

So, Are we moving forward with this solution? Or should we close this? I am honestly a bit out of touch here considering this PR has been up for almost a year.

I would be happy to retest and rebase the PR if we plan to move forward.

@jasmussen

Copy link
Copy Markdown
Contributor

I would be happy to retest and rebase the PR if we plan to move forward.

I feel like we have tried the other mechanisms: adding a stroke, etc.

And the issue still feels valid: you can upload a black, transparent PNG as site logo, which makes it illegible.

Between both of those, I feel the solution proposed here, at least functionally, is the most promising path forward, and if you'd be up for it, I'd welcome a rebase.

@t-hamano

Copy link
Copy Markdown
Contributor

Nothing guarantees that the site icon applies well on top of the site top level background.

I think we need to explore how to address this issue.

For example, if a site has a white background, a black header background, and a site logo is placed inside the header, the site logo will likely be close to white. However, if we apply the site's white background to that icon, it will likely become invisible.

@jasmussen

Copy link
Copy Markdown
Contributor

For example, if a site has a white background, a black header background, and a site logo is placed inside the header, the site logo will likely be close to white. However, if we apply the site's white background to that icon, it will likely become invisible.

Very valid, but do you think the BG could still be a starting point? It seems the simplest alternative to what we've tried, that will work in most contexts.

@youknowriad

Copy link
Copy Markdown
Contributor

For me it's really not clear to me whether this will work in most contexts than what we already have in trunk. If any I feel it works in less contexts, and the solution to update the logo of the site is less drastic than updating the design of the site.

…ean up styles.

- Added global styles support for the button background and text color based on the current theme.
- Removed hardcoded background color from the SCSS file to allow for dynamic styling.
- Improved code readability and organization in fullscreen-mode-close.js.
…improve styling logic.

- Added support for global styles in the SiteIcon component to dynamically set background and text colors.
- Updated the EditSiteEditor to utilize global styles for the view mode toggle icon.
- Removed hardcoded background color from the SiteIcon styles to allow for dynamic styling based on the current theme.
- Improved the SiteIcon component to accept a style prop for better customization.
Added the original border effect on hover
@Mayank-Tripathi32
Mayank-Tripathi32 force-pushed the try/enhance-add-logo-bg-effect branch from a614c69 to 572c3f8 Compare February 16, 2026 22:10
@Mayank-Tripathi32

Copy link
Copy Markdown
Member Author

I have refreshed with trunk, I do feel that if we are not sure on this then it be best to avoid shipping this for now. Maybe explore possibility of detecting transparent logos and forcing a static color on them? Maybe add another way to control this via site logo component, User can pick bg color for logo?

@jasmussen

Copy link
Copy Markdown
Contributor

Thanks for refreshing. I took the PR for a spin, and found some small things:

status

If we're going to do this, we should apply that background color also in the site view context, here:

image

There was also an issue in the post editor, that only shows the background.

I personally think this is the right thing to do: if you use an image with no transparency, it will be like old times. If you use an image WITH transparency, you'll have the site backdrop. Because of that, this feels a mostly harmless improvement over the suboptimal state that exists.

Edge cases have been mentioned, where the background would not be ideal, e.g. the header with the logo inside has a different background than the site itself. But that seems both rare, but it also doesn't seem to necessarily be something that's blocked from improving, even after landing this solution. So in the name of shipping a good improvement rather than waiting for perfect, I'm personally for this.

A CC: to @WordPress/gutenberg-design for any instincts, but with no rush.

@jasmussen

Copy link
Copy Markdown
Contributor

I wonder: with the adminbar now everywhere, is this issue still relevant?

@t-hamano

t-hamano commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

At the very least, the site logo should no longer be present in the UI rendered by Gutenberg, so I don't think this issue needs to be addressed anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Site Logo Affects the Site Logo Block [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Site Logo: Dark transparent site logos are invisible

8 participants