Gutenberg: Hide WordPress logo animation for preview

Created on 22 Nov 2018  路  6Comments  路  Source: WordPress/gutenberg

Since the update to 4.1.0 #11022 there is now a WordPress logo animation appearing after hitting the preview button.

Is there any way to hide/change/remove this animation?
Maybe you could provide a filter to alter the animation.

I tried to access the CSS properties from within my own plugin, but to no avail.

[Type] Help Request

Most helpful comment

Because it is a Wordpress brand logo and I would like to put in my own logo, if that's possible.

All 6 comments

The interstitial animation is defined here: https://github.com/WordPress/gutenberg/blob/f090e84828b18f2b1a21bebf68a9a1bdd85324de/packages/editor/src/components/post-preview-button/index.js. It's pretty much hardcoded.

Why do you want to remove the animation though?

Personally I like this little UX addition.

Because it is a Wordpress brand logo and I would like to put in my own logo, if that's possible.

It may also be worth considering a reduced-motion alternative to respond to https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion

I've written a proposal for a filter which would let one customise this UI in https://github.com/WordPress/gutenberg/issues/12238.

Thanks a lot!
But is there a way to work around this before the filter is released?
I can't access the .editor-post-preview-button__interstitial-message class from any css-file and !important is also not working.

I'm not sure that there's a way to do this because the Preview button opens a new window with HTML that's built entirely from within the Preview button component.

A very very hacky approach might be to override window.open() with a function that injects your custom CSS:

var _open = window.open;
window.open = function() {
    var previewWindow = _open.apply( this, arguments );
    if ( /^wp-preview/.test( previewWndow.name ) ) {
        var style = document.createElement( 'style' );
        style.type = 'text/css';
        style.innerText = 'body { background: #222; } /*... more css ..*/';
        previewWindow.document.head.appendChild( style );
    }
    return previewWindow;
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

youknowriad picture youknowriad  路  3Comments

davidsword picture davidsword  路  3Comments

nylen picture nylen  路  3Comments

pfefferle picture pfefferle  路  3Comments

franz-josef-kaiser picture franz-josef-kaiser  路  3Comments