-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move WordPress & Gutenberg PR Preview to Playground website (#1938)
## Motivation for the change, related issues #1655 (comment) I moved wordpress.html and gutenberg.html to Playground itself. By the way, I also made a mini appearance refactor for the modal, based on Figma. And I used components from WordPress packages. ## Implementation details - [x] Add modals with input to fill PR number - [x] Move & unify logic to fetch PR by number - [x] Error handling - [x] Appearance refactor for Modals - [x] Implement new Modal to other components - [x] Fetch PR number directly from query - [x] New Dropdown Menu in main sidebar (thanks to this, we can import playground when we don't have any active one) ## Testing Instructions (or ideally a Blueprint) - Any blueprint - Go to Playground settings - Click three dots next to ~~Homepage button~~ future Logo place - Select Preview a WordPress PR or Preview a Gutenberg PR It is also possible to open modal via URL params: /?modal=preview-pr-wordpress or /?modal=preview-pr-gutenberg ![image](https://github.com/user-attachments/assets/56bf1e59-2186-47b0-8991-b55f32237289) ![image](https://github.com/user-attachments/assets/821703ed-0fe4-4a7d-a266-2981a312370c) ![image](https://github.com/user-attachments/assets/765f3b91-c42a-4635-8e6b-00d4a631291b) --------- Co-authored-by: Brandon Payton <[email protected]>
- Loading branch information
1 parent
07200bf
commit c795006
Showing
30 changed files
with
575 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
packages/playground/website/src/components/error-report-modal/style.module.css
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 18 additions & 55 deletions
73
packages/playground/website/src/components/modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,24 @@ | ||
import ReactModal from 'react-modal'; | ||
import React from 'react'; | ||
import { Modal as WordPressModal } from '@wordpress/components'; | ||
import type { ModalProps as WordPressModalProps } from '@wordpress/components/build-types/modal/types'; | ||
import classNames from 'classnames'; | ||
import css from './style.module.css'; | ||
|
||
ReactModal.setAppElement('#root'); | ||
|
||
interface ModalProps extends ReactModal.Props { | ||
styles?: ReactModal.Styles; | ||
interface ModalProps extends WordPressModalProps { | ||
small?: boolean; | ||
} | ||
export const defaultStyles: ReactModal.Styles = { | ||
content: { | ||
top: '50%', | ||
left: '50%', | ||
right: 'auto', | ||
bottom: 'auto', | ||
marginRight: '-50%', | ||
transform: 'translate(-50%, -50%)', | ||
width: 400, | ||
maxWidth: '100vw', | ||
zIndex: 200, | ||
textAlign: 'center', | ||
color: '#000', | ||
border: '#000 1px solid', | ||
borderRadius: '6px', | ||
background: '#fff', | ||
}, | ||
overlay: { | ||
background: '#1e2327d0', | ||
zIndex: 10, | ||
}, | ||
}; | ||
export default function Modal(props: ModalProps) { | ||
const styles = { | ||
overlay: { ...defaultStyles.overlay, ...props.styles?.overlay }, | ||
content: { ...defaultStyles.content, ...props.styles?.content }, | ||
}; | ||
export function Modal({ small, className, children, ...rest }: ModalProps) { | ||
const modalClass = classNames( | ||
css.modal, | ||
{ | ||
[css.modalSmall]: small, | ||
}, | ||
className | ||
); | ||
|
||
return ( | ||
<ReactModal style={styles} {...props}> | ||
<div className={css.modalInner} id="modal-content"> | ||
<button | ||
id="import-close-modal--btn" | ||
onClick={props.onRequestClose} | ||
className={`${css.btn} ${css.btnClose}`} | ||
aria-label="Close" | ||
title="Close" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
width="32" | ||
height="32" | ||
aria-hidden="true" | ||
focusable="false" | ||
> | ||
<path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path> | ||
</svg> | ||
</button> | ||
{props.children} | ||
</div> | ||
</ReactModal> | ||
<WordPressModal className={modalClass} {...rest}> | ||
{children} | ||
</WordPressModal> | ||
); | ||
} |
Oops, something went wrong.