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

Add site manager view and sidebar #1661

Merged
merged 49 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4644ba0
Update ws dependency
bgrgicak Jul 31, 2024
742e68e
Move main content into a view
bgrgicak Jul 31, 2024
ed0b88a
Add site manager view
bgrgicak Jul 31, 2024
4272269
Load site manager if flag set to true
bgrgicak Jul 31, 2024
3150b30
Merge branch 'trunk' into add/website-view-switcher
bgrgicak Jul 31, 2024
53967e4
Open site manager from site view
bgrgicak Aug 1, 2024
1d1f3fb
Add sidebar site switching
bgrgicak Aug 1, 2024
7f2dbe7
Responsive sidebar
bgrgicak Aug 1, 2024
cca77fd
Fix type issue
bgrgicak Aug 1, 2024
09a4d16
Add resources
bgrgicak Aug 1, 2024
f59de26
Read sites from OPFS
bgrgicak Aug 1, 2024
0c5b031
Update comment
bgrgicak Aug 1, 2024
c937e00
Merge branch 'trunk' into add/website-view-switcher
bgrgicak Aug 1, 2024
58022b7
Change view query string
bgrgicak Aug 1, 2024
f2eed46
Update packages/playground/website/src/components/browser-chrome/inde…
bgrgicak Aug 1, 2024
58e076b
Apply suggestions from code review
bgrgicak Aug 1, 2024
b6c3ba3
Fix sidebar responsive issue
bgrgicak Aug 1, 2024
cc9e90b
Capitalize name
bgrgicak Aug 1, 2024
0ccc318
Unrelated open error report links in a new tab
bgrgicak Aug 1, 2024
d69fe76
Update WordPress packages
bgrgicak Aug 5, 2024
3206084
Merge branch 'trunk' into update/wordpress-packages
bgrgicak Aug 5, 2024
16b4875
Merge branch 'update/wordpress-packages' into add/website-view-switcher
bgrgicak Aug 5, 2024
8817d59
Merge branch 'update/wordpress-packages' into add/website-view-switcher
bgrgicak Aug 5, 2024
4f5700d
Use Navigator for views
bgrgicak Aug 5, 2024
db154de
Matching animation time
bgrgicak Aug 5, 2024
618afa7
Add borders
bgrgicak Aug 5, 2024
5cb582a
Responsive issues
bgrgicak Aug 5, 2024
3914f5b
Fix typo
bgrgicak Aug 5, 2024
87d5fff
Merge branch 'trunk' into add/website-view-switcher
bgrgicak Aug 5, 2024
ba559c5
Fix site manager responsive
bgrgicak Aug 5, 2024
4303ded
Remove editor component
bgrgicak Aug 5, 2024
921df43
Update header and nav to use WordPress components
bgrgicak Aug 6, 2024
377a42e
Replace remaining sidebar components
bgrgicak Aug 6, 2024
0676c79
Replace default icon
bgrgicak Aug 7, 2024
9448b3a
Fix site-view radius
bgrgicak Aug 7, 2024
3b0c7c3
Make entire sidebar scrollable
bgrgicak Aug 7, 2024
e3c7bb4
Remove extra titles
bgrgicak Aug 7, 2024
d9d1ed2
Move menu icon to new component
bgrgicak Aug 7, 2024
3728dd2
Disable logo clicks
bgrgicak Aug 7, 2024
c23040b
Fix animation
bgrgicak Aug 7, 2024
9503c35
Change site on sidebar item click
bgrgicak Aug 7, 2024
47d436f
Small css changes
bgrgicak Aug 7, 2024
84176fd
Merge branch 'trunk' into add/website-view-switcher
brandonpayton Aug 7, 2024
291c12a
Add comment length fixes to site-view
brandonpayton Aug 7, 2024
edacf40
Add ESLint rules to limit comment width (#1613)
bgrgicak Aug 6, 2024
eff01f1
Return to site view on click
bgrgicak Aug 8, 2024
a8f3078
Small css fixes
bgrgicak Aug 8, 2024
454ab61
Update menu button style
bgrgicak Aug 8, 2024
463b2eb
Refactor header
bgrgicak Aug 8, 2024
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
21 changes: 21 additions & 0 deletions packages/playground/website/public/site-manager-background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 39 additions & 12 deletions packages/playground/website/src/components/browser-chrome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import css from './style.module.css';
import AddressBar from '../address-bar';
import { close } from '@wordpress/icons';
import classNames from 'classnames';
import { OpenSiteManagerButton } from '../open-site-manager-button';

interface BrowserChromeProps {
children?: React.ReactNode;
toolbarButtons?: Array<React.ReactElement | false | null>;
url?: string;
showAddressBar?: boolean;
onUrlChange?: (url: string) => void;
hideToolbar?: boolean;
className?: string;
}

export default function BrowserChrome({
Expand All @@ -18,6 +21,8 @@ export default function BrowserChrome({
onUrlChange,
showAddressBar = true,
toolbarButtons,
hideToolbar,
className,
}: BrowserChromeProps) {
const addressBarClass = classNames(css.addressBarSlot, {
[css.isHidden]: !showAddressBar,
Expand All @@ -43,20 +48,42 @@ export default function BrowserChrome({
[css.isHidden]: noticeHidden,
});

/**
* Temporary feature flag to enable the site manager
* while using browser storage.
*
* TODO: Remove this once the site manager supports all storage options.
*/
const query = new URL(window.location.href).searchParams;
bgrgicak marked this conversation as resolved.
Show resolved Hide resolved
const showSiteManager = query.get('storage') === 'browser';

return (
<div className={wrapperClass} data-cy="simulated-browser">
<div className={css.window}>
<header className={css.toolbar} aria-label="Playground toolbar">
<div
className={`${wrapperClass} ${className}`}
data-cy="simulated-browser"
>
<div className={`${css.window} browser-chrome-window`}>
<header
className={`${css.toolbar} ${
showSiteManager ? css.hasSiteManager : ''
} ${hideToolbar ? css.toolbarHidden : ''}`}
aria-label="Playground toolbar"
>
<div className={css.windowControls}>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
{showSiteManager && <OpenSiteManagerButton />}
{!showSiteManager && (
<>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
<div
className={`${css.windowControl} ${css.isNeutral}`}
></div>
</>
)}
</div>

<div className={addressBarClass}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ body.is-embedded .fake-window-wrapper {
max-width: 100vw;
width: 100%;
height: 100%;
border-radius: 0;
}

.window {
Expand Down Expand Up @@ -103,6 +102,13 @@ body.is-embedded .fake-window-wrapper {
height: 50px;
flex-direction: row;
align-items: center;
max-height: 100px;
overflow: hidden;
transition: max-height 0.14s ease-in-out;
Copy link
Member

Choose a reason for hiding this comment

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

These transitions feel a bit jarring to me. Subjectively, they feel too fast and also out-of sync. Specifically, the side bar transition in and the toolbar transition out feel out-of-sync with one another and jerky.

I think one of the reasons is timing, and the other may be that the sidebar appears immediately on the left while the contents slide into the sidebar from the right.

Screen.Recording.2024-08-06.at.2.54.19.PM.mov

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, this isn't great. I updated the animation to work similarly to the site-editor and synced the sidebar and toolbar animations. How does this look?

Screen.Recording.2024-08-07.at.11.19.39.mov

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The back animation could be a bit smoother, but I couldn't find a good way of doing it because the sidebar component is removed from DOM.

Copy link
Member

Choose a reason for hiding this comment

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

You are right, this isn't great. I updated the animation to work similarly to the site-editor and synced the sidebar and toolbar animations. How does this look?

This looks much better to me, and I no longer feel jarred when opening the sidebar.

}

.toolbar-hidden {
max-height: 0;
Copy link
Member

Choose a reason for hiding this comment

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

Why is the toolbar hidden when the sidebar is expanded? As a user, it feels like a distracting change and one that unnecessarily takes away the embedded WP navigation bar.

It seems practical to take away (or disable) the site configuration menus while the sidebar is opened to avoid conflicts between the two, but would it be possible to slide those out and let the embedded nav bar remain so users can continue seeing and setting the WP URL for the active session?

Leaving the toolbar in place might also reduce the number of moving parts mentioned in the "jarring" feedback above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted it to match the future design where the toolbar won't be visible.

Also the idea was for the site view to be disabled here but I changed it based on @adamziel feedback.

The current toolbar will eventually be removed, so I don't want to spend time adjusting it to work here for example we would need to hide the new menu button, adjust it to match visually, and add extra breakpoints to keep responsive support.

@jarekmorawski what do you think?

}

.toolbar-buttons {
Expand All @@ -117,7 +123,7 @@ body.is-embedded .fake-window-wrapper {
margin-right: auto;
margin-left: 100px;
min-width: 200px;
width: 100%;
width: calc(100% - 36px);
opacity: 1;
transition: opacity ease-in 0.25s;
}
Expand Down Expand Up @@ -188,6 +194,15 @@ body.is-embedded .fake-window-wrapper {
.window-controls {
display: none;
}
.has-site-manager {
.window-controls {
display: flex;
align-items: center;
}
.address-bar-slot {
margin-left: 36px;
}
}
}

@media (max-width: 902px) {
Expand All @@ -201,7 +216,7 @@ body.is-embedded .fake-window-wrapper {
}

@media (max-width: 812px) {
.toolbar {
.toolbar:not(.toolbar-hidden) {
padding: 10px;
flex-direction: column;
height: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ export function ErrorReportModal(props: { blueprint: Blueprint }) {
<>
We were unable to submit the error report. Please try again
or open an{' '}
<a href="https://github.com/WordPress/wordpress-playground/issues/">
<a
brandonpayton marked this conversation as resolved.
Show resolved Hide resolved
href="https://github.com/WordPress/wordpress-playground/issues/"
target="_blank"
rel="noopener noreferrer"
>
issue on GitHub.
</a>
</>
Expand All @@ -128,7 +132,11 @@ export function ErrorReportModal(props: { blueprint: Blueprint }) {
return (
<>
Your report has been submitted to the{' '}
<a href="https://wordpress.slack.com/archives/C06Q5DCKZ3L">
<a
href="https://wordpress.slack.com/archives/C06Q5DCKZ3L"
target="_blank"
rel="noopener noreferrer"
>
Making WordPress #playground-logs Slack channel
</a>{' '}
and will be reviewed by the team.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import css from './style.module.css';

import { __experimentalNavigatorButton as NavigatorButton } from '@wordpress/components';

export function OpenSiteManagerButton() {
return (
<NavigatorButton
path="/manager"
aria-label="Open Site Manager"
className={css.openSiteManagerButton}
iconSize={14}
icon={
<svg
bgrgicak marked this conversation as resolved.
Show resolved Hide resolved
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M1.99967 1.58301H4.49967C4.72979 1.58301 4.91634 1.76956 4.91634 1.99967V4.49967C4.91634 4.72979 4.72979 4.91634 4.49967 4.91634H1.99967C1.76956 4.91634 1.58301 4.72979 1.58301 4.49967V1.99967C1.58301 1.76956 1.76956 1.58301 1.99967 1.58301ZM0.333008 1.99967C0.333008 1.0792 1.0792 0.333008 1.99967 0.333008H4.49967C5.42015 0.333008 6.16634 1.0792 6.16634 1.99967V4.49967C6.16634 5.42015 5.42015 6.16634 4.49967 6.16634H1.99967C1.0792 6.16634 0.333008 5.42015 0.333008 4.49967V1.99967ZM9.49967 1.58301H11.9997C12.2298 1.58301 12.4163 1.76956 12.4163 1.99967V4.49967C12.4163 4.72979 12.2298 4.91634 11.9997 4.91634H9.49967C9.26956 4.91634 9.08301 4.72979 9.08301 4.49967V1.99967C9.08301 1.76956 9.26956 1.58301 9.49967 1.58301ZM7.83301 1.99967C7.83301 1.0792 8.5792 0.333008 9.49967 0.333008H11.9997C12.9201 0.333008 13.6663 1.0792 13.6663 1.99967V4.49967C13.6663 5.42015 12.9201 6.16634 11.9997 6.16634H9.49967C8.5792 6.16634 7.83301 5.42015 7.83301 4.49967V1.99967ZM11.9997 9.08301H9.49967C9.26956 9.08301 9.08301 9.26956 9.08301 9.49967V11.9997C9.08301 12.2298 9.26956 12.4163 9.49967 12.4163H11.9997C12.2298 12.4163 12.4163 12.2298 12.4163 11.9997V9.49967C12.4163 9.26956 12.2298 9.08301 11.9997 9.08301ZM9.49967 7.83301C8.5792 7.83301 7.83301 8.5792 7.83301 9.49967V11.9997C7.83301 12.9201 8.5792 13.6663 9.49967 13.6663H11.9997C12.9201 13.6663 13.6663 12.9201 13.6663 11.9997V9.49967C13.6663 8.5792 12.9201 7.83301 11.9997 7.83301H9.49967ZM1.99967 9.08301H4.49967C4.72979 9.08301 4.91634 9.26956 4.91634 9.49967V11.9997C4.91634 12.2298 4.72979 12.4163 4.49967 12.4163H1.99967C1.76956 12.4163 1.58301 12.2298 1.58301 11.9997V9.49967C1.58301 9.26956 1.76956 9.08301 1.99967 9.08301ZM0.333008 9.49967C0.333008 8.5792 1.0792 7.83301 1.99967 7.83301H4.49967C5.42015 7.83301 6.16634 8.5792 6.16634 9.49967V11.9997C6.16634 12.9201 5.42015 13.6663 4.49967 13.6663H1.99967C1.0792 13.6663 0.333008 12.9201 0.333008 11.9997V9.49967Z"
fill="white"
/>
</svg>
}
></NavigatorButton>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@media (max-width: 812px) {
.open-site-manager-button {
position: relative;
top: -4px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,44 @@ interface PlaygroundViewportProps {
toolbarButtons?: Array<React.ReactElement | false | null>;
children?: React.ReactNode;
siteSlug?: string;
hideToolbar?: boolean;
className?: string;
}

export const PlaygroundViewport = React.forwardRef<
HTMLIFrameElement,
PlaygroundViewportProps
>(({ displayMode = 'browser', toolbarButtons }, ref) => {
const { playground, currentUrl: url } = usePlaygroundContext();
>(
(
{ displayMode = 'browser', toolbarButtons, hideToolbar, className },
ref
) => {
const { playground, currentUrl: url } = usePlaygroundContext();

if (displayMode === 'seamless') {
// No need to boot the playground if seamless.
return <JustViewport iframeRef={ref} />;
if (displayMode === 'seamless') {
// No need to boot the playground if seamless.
return <JustViewport iframeRef={ref} />;
}
return (
<BrowserChrome
showAddressBar={!!playground}
url={url}
toolbarButtons={toolbarButtons}
onUrlChange={(url) => playground?.goTo(url)}
hideToolbar={hideToolbar}
className={className}
>
<JustViewport iframeRef={ref} />
</BrowserChrome>
);
}
return (
<BrowserChrome
showAddressBar={!!playground}
url={url}
toolbarButtons={toolbarButtons}
onUrlChange={(url) => playground?.goTo(url)}
>
<JustViewport iframeRef={ref} />
</BrowserChrome>
);
});
);

interface JustViewportProps {
iframeRef: Ref<HTMLIFrameElement>;
}

const JustViewport = function LoadedViewportComponent({
export const JustViewport = function LoadedViewportComponent({
iframeRef,
}: JustViewportProps) {
useEffect(() => {
Expand Down
60 changes: 60 additions & 0 deletions packages/playground/website/src/components/site-manager/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export const Logo = () => {
return (
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<rect
width="10.4176"
height="10.4176"
rx="3.86258"
transform="matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)"
stroke="white"
strokeWidth="0.965644"
/>
<rect
width="13.2346"
height="13.2346"
rx="3.86258"
transform="matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)"
stroke="white"
strokeWidth="1.44847"
/>
<rect
width="17.451"
height="17.451"
rx="3.86258"
transform="matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)"
stroke="white"
strokeWidth="1.93129"
/>
</svg>
);
};

export const TemporaryStorageIcon = () => {
return (
<svg
width="16"
height="17"
viewBox="0 0 16 17"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z"
fill="#949494"
/>
</svg>
);
};

export const DefaultLogoDataURL = {
mime: 'image/png',
data: 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAYAAABG1c6oAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAALFSURBVHgBlVVLaxpRFL6OLpLdJIssko0kixQSqJAHNCilC6UbJf0H7T/IRhE3mo0Iumh/QV27SapLhVZ84EKpBXWnDC6kuPCB+ABRe76LZ5hYE9oPxpl7zz3f+c45915N4gUEAgHbcrnEY11PVS0WixYOh6vP+Zi2Tfp8vuDu7u4dEamHh4dif39fzvd6PdHpdMRsNtNoeB+NRuMvEvr9futisXg4Pj62uVwuQe9t8US5XBbpdFr0+33NbDa/i0Qi2l+Ea7KfTqdTpUf8C5LJpMjn8xp9fiC1sgyKgez7/5DV63WplGCl5yEUCqkYWPBDZEGqlXVvb48XicvLS6mA6iUwj/d0OpVlgA2EmFvDOplMvkKpGepWq1V8NBrJRSg6mnByciLa7bacw4Nv4PT0VBwcHEhyzAPUQEG1fHV9fZ1VSN3d2dmZ2NnZkcajoyPBaePtdrv1NLEGazkDY9MwpkxuUcPXFxcXcgJoNpsyOgNKOVir1XpiYx/YQT4cDt+C0IYUz8/PpREOlUpFd0I67AgYbQgGoMbIjEpnBaEKJ0SAAajVasIIQ/Gf2FitIaAKwsFmCkgNzWGgDAzYaEPLb14DpWvyAQg1drDb7bojd5CdjA3grQXydTPksSRUQZhlJ04doBOgq4MCHEUG25A+Z9VoNPD6pVAhH1ForgdvC4yhAGp4i3C3YUskEroAqAM57cXPSiwW+0ELHnHYuY7siDk0hFUbu41A3OVMJoN1cVwS8izP5/NPhUJBwyJExZVlTJfBW4uBjZ/L5bCVcOvcY86Mn1KpNLu5uclSHd7TUL26utIL7/F49O2EN4Kgy6w6lUoNiOwNX2FmjlYsFn87HI5v5HBL8tVutysJQGgEyPjEkIDqs/ehEV6v96PJZApi50PJ5o2tKMpgPB5/ofqHNn23EhqI5f8JqbBhTAE0elX5Mt2GP/1pl0TWF7M6AAAAAElFTkSuQmCC',
};
31 changes: 31 additions & 0 deletions packages/playground/website/src/components/site-manager/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { SiteManagerSidebar } from './site-manager-sidebar';

import css from './style.module.css';

export function SiteManager({
iframeRef,
siteSlug,
}: {
iframeRef: React.RefObject<HTMLIFrameElement>;
siteSlug?: string;
}) {
const onSiteChange = (siteSlug?: string) => {
const url = new URL(window.location.href);
if (siteSlug) {
url.searchParams.set('site-slug', siteSlug);
} else {
url.searchParams.delete('site-slug');
}
window.location.assign(url.toString());
};

return (
<div className={css.siteManager}>
<SiteManagerSidebar
className={css.siteManagerSidebar}
onSiteChange={onSiteChange}
siteSlug={siteSlug}
/>
</div>
);
}
Loading
Loading