Skip to content

Apply style to demos page and relocate "More demos" menu #2197

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
Expand Up @@ -13,6 +13,7 @@ import classNames from 'classnames';
import { forwardRef } from 'react';
import { setSiteManagerOpen } from '../../lib/state/redux/slice-ui';
import { BlueprintsPanel } from './blueprints-panel';
import { PlaygroundDemos } from './playground-demos';

export const SiteManager = forwardRef<
HTMLDivElement,
Expand Down Expand Up @@ -61,6 +62,11 @@ export const SiteManager = forwardRef<
/>
) : null;
break;
case 'playground-demos':
activePanel = (
<PlaygroundDemos />
);
break;
default:
activePanel = null;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import styles from './style.module.css';
import React, { useEffect } from 'react';

export const PlaygroundDemos = () => {
useEffect(() => {
const codeEditorBlueprint = {
landingPage: '/wp-admin/post.php?post=1&action=edit',
steps: [
{ step: 'login' },
{
step: 'installPlugin',
pluginData: {
resource: 'wordpress.org/plugins',
slug: 'interactive-code-block',
},
},
{
step: 'writeFile',
path: '/wordpress/post.txt',
data: '<!-- wp:wordpress-playground/playground {"codeEditor":true,"files":[{"name":"index.php","contents":"<?php\\n/**\\n * Plugin Name: A WordPress plugin\\n */\\nadd_action(\'init\', function() {\\n update_option(\'blogname\', \'This is a Playground demo!\');\\n});"}]} /-->',
},
{
step: 'runPHP',
code: "<?php require '/wordpress/wp-load.php'; kses_remove_filters(); wp_update_post(['ID'=>1,'post_title' => 'Playground Plugin Editor', 'post_content'=>file_get_contents('/wordpress/post.txt')]);",
},
],
};

const link = document.getElementById('code-editor') as HTMLAnchorElement;
if (link) {
link.href = `../#${JSON.stringify(codeEditorBlueprint)}`;
}
}, []);

return (
<div className={styles.playgroundDemos}>
<h2>WordPress Playground demos</h2>
<p>This is a collection of cool apps and demos built with WordPress Playground.</p>
<ul>
<li><a href="wp-cli.html" target="_blank">WP-CLI</a></li>
<li><a id="code-editor" target="_blank">Code editor (as a Gutenberg block)</a></li>

Check warning on line 41 in packages/playground/website/src/components/site-manager/playground-demos/index.tsx

View workflow job for this annotation

GitHub Actions / Lint and typecheck

The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md
<li><a href="sync.html" target="_blank">Synchronization between two Playgrounds</a></li>
<li><a href="time-traveling.html" target="_blank">Time Travel</a></li>
<li><a href="../wordpress.html" target="_blank">WordPress Pull Request Previewer</a></li>
<li><a href="../gutenberg.html" target="_blank">Gutenberg Pull Request Previewer</a></li>
</ul>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Playground Demos Component Styles */
.playground-demos {
--padding-size: 24px;
background-color: #fdfdfd;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
border-radius: 12px;
padding: var(--padding-size);
margin: 32px auto;
max-width: 720px;
font-family: 'Segoe UI', sans-serif;
min-height: 430px;
}

.playground-demos h2 {
font-size: 1.8rem;
color: #222;
margin-bottom: 16px;
border-bottom: 2px solid #ddd;
padding-bottom: 8px;
}

.playground-demos p {
font-size: 1rem;
color: #555;
margin-bottom: 20px;
}

.playground-demos ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 10px;
}

.playground-demos li a {
display: block;
background-color: #f0f4f8;
color: #0073aa;
text-decoration: none;
padding: 12px 16px;
border-radius: 8px;
transition: all 0.2s ease-in-out;
}

.playground-demos li a:hover {
background-color: #0073aa;
color: white;
transform: translateY(-2px);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export function Sidebar({
label: 'Preview WordPress PR',
href: '/wordpress.html',
},
{
label: 'More demos',
href: '/demos/index.html',
},
{
label: 'Documentation',
href: 'https://wordpress.github.io/wordpress-playground/',
Expand Down Expand Up @@ -200,6 +196,36 @@ export function Sidebar({
</FlexBlock>
</HStack>
</MenuItem>
<MenuItem
className={classNames(css.sidebarItem, {
[css.sidebarItemSelected]:
activeSiteManagerSection === 'playground-demos',
})}
onClick={() =>
dispatch(setSiteManagerSection('playground-demos'))
}
isSelected={
activeSiteManagerSection === 'playground-demos'
}
>
<HStack justify="flex-start" alignment="center">
<Flex
style={{
width: 24,
}}
align="center"
justify="center"
>
<Icon
icon={page}
className={css.sidebarItemLogo}
/>
</Flex>
<FlexBlock className={css.sidebarItemSiteName}>
Playground Demos
</FlexBlock>
</HStack>
</MenuItem>
</MenuGroup>
{storedSites.length > 0 && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type SiteError =
// @TODO: Improve name?
| 'site-boot-failed';

export type SiteManagerSection = 'sidebar' | 'site-details' | 'blueprints';
export type SiteManagerSection = 'sidebar' | 'site-details' | 'blueprints' | 'playground-demos';
export interface UIState {
activeSite?: {
slug: string;
Expand Down