forked from processing/p5.js-web-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/revoke-blob
- Loading branch information
Showing
219 changed files
with
11,254 additions
and
6,287 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ MAILGUN_KEY=<your-mailgun-api-key> | |
ML5_LIBRARY_USERNAME=ml5 | ||
ML5_LIBRARY_EMAIL=[email protected] | ||
ML5_LIBRARY_PASS=helloml5 | ||
MOBILE_ENABLED=true | ||
MONGO_URL=mongodb://localhost:27017/p5js-web-editor | ||
PORT=8000 | ||
PREVIEW_PORT=8002 | ||
|
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { upperFirst } from 'lodash'; | ||
import React from 'react'; | ||
import styled, { ThemeProvider } from 'styled-components'; | ||
import theme, { prop } from '../client/theme'; | ||
|
||
const PreviewArea = styled.div` | ||
background: ${prop('backgroundColor')}; | ||
flex-grow: 1; | ||
padding: 2rem; | ||
& > h4 { | ||
margin-top: 0; | ||
color: ${prop('primaryTextColor')}; | ||
} | ||
`; | ||
|
||
const themeKeys = Object.keys(theme); | ||
|
||
export const withThemeProvider = (Story, context) => { | ||
const setting = context.globals.theme; | ||
if (setting === 'all') { | ||
return ( | ||
<div style={{ display: 'flex', flexWrap: 'wrap' }}> | ||
{Object.keys(theme).map((themeName) => ( | ||
<ThemeProvider theme={theme[themeName]} key={themeName}> | ||
<PreviewArea className={themeName}> | ||
<h4>{upperFirst(themeName)}</h4> | ||
<Story /> | ||
</PreviewArea> | ||
</ThemeProvider> | ||
))} | ||
</div> | ||
); | ||
} else { | ||
const themeName = setting; | ||
return ( | ||
<ThemeProvider theme={theme[themeName]}> | ||
<PreviewArea className={themeName}> | ||
<Story /> | ||
</PreviewArea> | ||
</ThemeProvider> | ||
); | ||
} | ||
}; | ||
|
||
export const themeToolbarItem = { | ||
description: 'Global theme for components', | ||
defaultValue: 'all', | ||
toolbar: { | ||
title: 'Theme', | ||
icon: 'mirror', | ||
items: [...themeKeys, 'all'] | ||
} | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
/** | ||
* Wraps the react-router `NavLink` with dashboard-header__tab styling. | ||
*/ | ||
const Tab = ({ children, to }) => ( | ||
<li className="dashboard-header__tab"> | ||
<NavLink | ||
className="dashboard-header__tab__title" | ||
activeClassName="dashboard-header__tab--selected" | ||
to={{ pathname: to, state: { skipSavingPath: true } }} | ||
> | ||
{children} | ||
</NavLink> | ||
</li> | ||
); | ||
|
||
Tab.propTypes = { | ||
children: PropTypes.string.isRequired, | ||
to: PropTypes.string.isRequired | ||
}; | ||
|
||
export default Tab; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useEffect, useRef } from 'react'; | ||
import useKeyDownHandlers from './useKeyDownHandlers'; | ||
|
||
/** | ||
* Common logic for Modal, Overlay, etc. | ||
* | ||
* Pass in the `onClose` handler. | ||
* | ||
* Can optionally pass in a ref, in case the `onClose` function needs to use the ref. | ||
* | ||
* Calls the provided `onClose` function on: | ||
* - Press Escape key. | ||
* - Click outside the element. | ||
* | ||
* Returns a ref to attach to the outermost element of the modal. | ||
* | ||
* @param {() => void} onClose | ||
* @param {React.MutableRefObject<HTMLElement | null>} [passedRef] | ||
* @return {React.MutableRefObject<HTMLElement | null>} | ||
*/ | ||
export default function useModalClose(onClose, passedRef) { | ||
const createdRef = useRef(null); | ||
const modalRef = passedRef || createdRef; | ||
|
||
useEffect(() => { | ||
modalRef.current?.focus(); | ||
|
||
function handleClick(e) { | ||
// ignore clicks on the component itself | ||
if (modalRef.current && !modalRef.current.contains(e.target)) { | ||
onClose?.(); | ||
} | ||
} | ||
|
||
document.addEventListener('click', handleClick, false); | ||
|
||
return () => { | ||
document.removeEventListener('click', handleClick, false); | ||
}; | ||
}, [onClose, modalRef]); | ||
|
||
useKeyDownHandlers({ escape: onClose }); | ||
|
||
return modalRef; | ||
} |
Oops, something went wrong.