Skip to content

Commit

Permalink
Use theme_color_override_with_admin_color_scheme to update meta theme…
Browse files Browse the repository at this point in the history
… color tag
  • Loading branch information
ciampo committed Jan 14, 2025
1 parent 8daf4a8 commit 2ed13df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/layout/color-scheme/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import config from '@automattic/calypso-config';
import { getAdminColor } from 'calypso/state/admin-color/selectors';
import { getPreference } from 'calypso/state/preferences/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
Expand Down Expand Up @@ -48,13 +49,14 @@ export function refreshColorScheme( prevColorScheme, nextColorScheme ) {

if ( nextColorScheme ) {
classList.add( `is-${ nextColorScheme }` );
}

if ( config( 'theme_color_override_with_admin_color_scheme' ) ) {
const themeColor = getComputedStyle( document.body )
.getPropertyValue( '--color-masterbar-background' )
.trim();
const themeColorMeta = document.querySelector( 'meta[name="theme-color"]' );
// We only adjust the `theme-color` meta content value in case we set it in `componentDidMount`
if ( themeColorMeta && themeColorMeta.getAttribute( 'data-colorscheme' ) === 'true' ) {
if ( themeColorMeta && themeColor ) {
themeColorMeta.content = themeColor;
}
}
Expand Down

0 comments on commit 2ed13df

Please sign in to comment.