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

Hide the "This is experimental WordPress" notice on click #1082

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import css from './style.module.css';
import AddressBar from '../address-bar';
import { close } from '@wordpress/icons';
import classNames from 'classnames';

interface BrowserChromeProps {
Expand Down Expand Up @@ -29,6 +30,26 @@ export default function BrowserChrome({
[css.hasSmallWindow]: !isFullSize,
[css.hasFullSizeWindow]: isFullSize,
});

const [noticeHidden, setNoticeHidden] = useState(
document.cookie.includes('hideExperimentalNotice=true')
);

const hideNotice = () => {
document.cookie = 'hideExperimentalNotice=true';
setNoticeHidden(true);
};
useEffect(() => {
const hideNoticeTimeout = setTimeout(hideNotice, 20000);
return () => {
clearTimeout(hideNoticeTimeout);
};
}, []);

const experimentalNoticeClass = classNames(css.experimentalNotice, {
[css.isHidden]: noticeHidden,
});

return (
<div className={wrapperClass} data-cy="simulated-browser">
<div className={css.window}>
Expand All @@ -53,7 +74,8 @@ export default function BrowserChrome({
<div className={css.toolbarButtons}>{toolbarButtons}</div>
</div>
<div className={css.content}>{children}</div>
<div className={css.experimentalNotice}>
<div className={experimentalNoticeClass} onClick={hideNotice}>
{close}
This is a cool fun experimental WordPress running in your
browser :) All your changes are private and gone after a
page refresh.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
line-height: 18px;
align-items: center;
color: #1e1e1e;
cursor: pointer;

svg {
margin-right: 10px;
width: 20px;
min-width: 20px;
fill: #e14640;
}

&.is-hidden {
display: none;
}
}

body.is-embedded .fake-window-wrapper {
Expand Down
Loading