Skip to content

Commit

Permalink
Merge branch 'develop' into fix/revoke-blob
Browse files Browse the repository at this point in the history
  • Loading branch information
raclim authored Mar 29, 2024
2 parents 813ae96 + 680bffb commit 5d4c746
Show file tree
Hide file tree
Showing 219 changed files with 11,254 additions and 6,287 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions .storybook/decorator-theme.js
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']
}
};
8 changes: 6 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router';

import ThemeProvider from '../client/modules/App/components/ThemeProvider';
import configureStore from '../client/store';
import '../client/i18n-test';
import '../client/styles/storybook.css'
import { withThemeProvider, themeToolbarItem } from './decorator-theme';

const initialState = window.__INITIAL_STATE__;

Expand All @@ -21,5 +21,9 @@ export const decorators = [
</MemoryRouter>
</Provider>
),
]
withThemeProvider
];

export const globalTypes = {
theme: themeToolbarItem
};
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ FROM base as development
ENV NODE_ENV development
COPY package.json package-lock.json ./
RUN npm install
RUN npm rebuild node-sass
COPY .babelrc index.js nodemon.json ./
COPY ./webpack ./webpack
COPY client ./client
Expand All @@ -27,6 +26,5 @@ FROM base as production
ENV NODE_ENV=production
COPY package.json package-lock.json index.js ./
RUN npm install --production
RUN npm rebuild node-sass
COPY --from=build $APP_HOME/dist ./dist
CMD ["npm", "run", "start:prod"]
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ The p5.js Editor is a collaborative project created by many individuals, mostly

Learn more about [our community](https://p5js.org/community/) and read our community statement and [code of conduct](./.github/CODE_OF_CONDUCT.md). You can directly support our work with p5.js by [donating to the Processing Foundation](https://processingfoundation.org/support).

## Get Started
## Getting Started

Make your first sketch in the [p5.js Editor](https://editor.p5js.org/)! Learn more about sketching with p5.js on the [Get Started](https://p5js.org/get-started/) and find everything you can do in the [Reference](https://p5js.org/reference/). You can also look at [examples](https://editor.p5js.org/p5/sketches) and remix them in the p5.js Editor.

## Setting Up the Development Environment

- Refer to [this documentation for setting up your environment](https://github.com/processing/p5.js-web-editor/blob/develop/contributor_docs/installation.md)



## Issues

Expand All @@ -31,10 +26,32 @@ If you have found a bug in the p5.js Web Editor, you can file it under the ["iss
* p5.sound: [https://github.com/processing/p5.js-sound/issues](https://github.com/processing/p5.js-sound/issues)
* p5.js website: [https://github.com/processing/p5.js-website/issues](https://github.com/processing/p5.js-website/issues)


### How Do I Know My Issue or Pull Request is Getting Reviewed?

To see which pull requests and issues are currently being reviewed, check the [PR Review Board](https://github.com/processing/p5.js-web-editor/projects/9) or the following Milestones: [MINOR Release](https://github.com/processing/p5.js-web-editor/milestone/8).


## References for Contributing to the p5.js Web Editor

[Code of Conduct](https://editor.p5js.org/code-of-conduct)

[Contribution Guidelines for p5.js](https://p5js.org/contributor-docs/#/)

[Contribution Guidelines for the p5.js Web Editor](https://github.com/processing/p5.js-web-editor/tree/develop/contributor_docs)

[p5.js Community Statement](https://p5js.org/community/)


## Acknowledgements

Support for this project has come from [Processing Foundation](https://processingfoundation.org/), [NYU ITP](https://tisch.nyu.edu/itp), [CS4All, NYC DOE](http://cs4all.nyc/), [COSA at DU](https://liberalarts.du.edu/emergent-digital-practices/open-source-arts), [STUDIO for Creative Inquiry](https://studioforcreativeinquiry.org/), [Grant for the Web](https://www.grantfortheweb.org/), [New Media Rights](https://www.newmediarights.org/), and many others.

Hosting and technical support has come from: <br />
<a href="https://releasehub.com/" target="_blank"><img width="100" src="https://assets.website-files.com/603dd147c5b0a480611bd348/603dd147c5b0a469bc1bd451_logo--dark.svg" /></a>
Hosting and technical support has come from:
<br />
<br />
<a href="https://releasehub.com/" target="_blank"><img width="100" src="https://assets.website-files.com/603dd147c5b0a480611bd348/603dd147c5b0a469bc1bd451_logo--dark.svg" /></a>
<br />
<a href="https://www.browserstack.com/" target="_blank"><img width="100" src="https://user-images.githubusercontent.com/6063380/46976166-ab280a80-d096-11e8-983b-18dd38c8cc9b.png" /></a>
<br />
<a href="https://www.fastly.com/" target="_blank"><img width="100" src="https://cdn-assets-us.frontify.com/s3/frontify-enterprise-files-us/eyJwYXRoIjoiZmFzdGx5XC9hY2NvdW50c1wvYzJcLzQwMDEwMjNcL3Byb2plY3RzXC8xMVwvYXNzZXRzXC80ZVwvNzc0XC9lZTZmYzlkOWYzNWE1NjBkNjUzNjFkNGI0NGQ2MTNmZi0xNjIxNTIyODg4LnBuZyJ9:fastly:nVuY3PxyFqQMI6elJsMzxAGLH3IFlmiuMdacHAGRMkE?width=2400" /></a>
64 changes: 5 additions & 59 deletions client/common/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const displays = {
const StyledButton = styled.button`
&&& {
font-weight: bold;
display: flex;
display: ${({ display }) =>
display === displays.inline ? 'inline-flex' : 'flex'};
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -107,57 +108,6 @@ const StyledInlineButton = styled.button`
}
`;

const StyledIconButton = styled.button`
&&& {
display: flex;
justify-content: center;
align-items: center;
width: ${remSize(32)}px;
height: ${remSize(32)}px;
text-decoration: none;
color: ${({ kind }) => prop(`Button.${kind}.default.foreground`)};
background-color: ${({ kind }) => prop(`Button.${kind}.hover.background`)};
cursor: pointer;
border: 1px solid transparent;
border-radius: 50%;
padding: ${remSize(8)} ${remSize(25)};
line-height: 1;
&:hover:not(:disabled) {
color: ${({ kind }) => prop(`Button.${kind}.hover.foreground`)};
background-color: ${({ kind }) =>
prop(`Button.${kind}.hover.background`)};
svg * {
fill: ${({ kind }) => prop(`Button.${kind}.hover.foreground`)};
}
}
&:active:not(:disabled) {
color: ${({ kind }) => prop(`Button.${kind}.active.foreground`)};
background-color: ${({ kind }) =>
prop(`Button.${kind}.active.background`)};
svg * {
fill: ${({ kind }) => prop(`Button.${kind}.active.foreground`)};
}
}
&:disabled {
color: ${({ kind }) => prop(`Button.${kind}.disabled.foreground`)};
background-color: ${({ kind }) =>
prop(`Button.${kind}.disabled.background`)};
cursor: not-allowed;
}
> * + * {
margin-left: ${remSize(8)};
}
}
`;

/**
* A Button performs an primary action
*/
Expand All @@ -184,12 +134,8 @@ const Button = ({
);
let StyledComponent = StyledButton;

if (display === displays.inline) {
StyledComponent = StyledInlineButton;
}

if (iconOnly) {
StyledComponent = StyledIconButton;
StyledComponent = StyledInlineButton;
}

if (href) {
Expand Down Expand Up @@ -265,7 +211,7 @@ Button.propTypes = {
/**
* The display type of the button—inline or block
*/
display: PropTypes.string,
display: PropTypes.oneOf(Object.values(displays)),
/**
* SVG icon to place after child content
*/
Expand All @@ -286,7 +232,7 @@ Button.propTypes = {
* Specifying an href will use an <a> to link to the URL
*/
href: PropTypes.string,
/*
/**
* An ARIA Label used for accessibility
*/
'aria-label': PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Button from '../../common/Button';
import { remSize } from '../../theme';
import Button from './Button';
import { remSize } from '../theme';

const ButtonWrapper = styled(Button)`
width: ${remSize(48)};
Expand All @@ -19,6 +19,7 @@ const IconButton = (props) => {
return (
<ButtonWrapper
iconBefore={icon && <Icon />}
iconOnly
display={Button.displays.inline}
focusable="false"
{...otherProps}
Expand Down
25 changes: 25 additions & 0 deletions client/common/RouterTab.jsx
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;
6 changes: 4 additions & 2 deletions client/common/icons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import Account from '../images/account.svg';
import Code from '../images/code.svg';
import Save from '../images/save.svg';
import Terminal from '../images/terminal.svg';

import Folder from '../images/folder-padded.svg';

import CircleTerminal from '../images/circle-terminal.svg';
import CircleFolder from '../images/circle-folder.svg';
import CircleInfo from '../images/circle-info.svg';
import Add from '../images/add.svg';
import Filter from '../images/filter.svg';
import Cross from '../images/cross.svg';

// HOC that adds the right web accessibility props
Expand Down Expand Up @@ -100,3 +100,5 @@ export const CrossIcon = withLabel(Cross);
export const CircleTerminalIcon = withLabel(CircleTerminal);
export const CircleFolderIcon = withLabel(CircleFolder);
export const CircleInfoIcon = withLabel(CircleInfo);
export const AddIcon = withLabel(Add);
export const FilterIcon = withLabel(Filter);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapKeys from 'lodash/mapKeys';
import { mapKeys } from 'lodash';
import PropTypes from 'prop-types';
import { useCallback, useEffect, useRef } from 'react';

Expand All @@ -20,7 +20,7 @@ export default function useKeyDownHandlers(keyHandlers) {
const handlers = useRef(keyHandlers);

useEffect(() => {
handlers.current = mapKeys(keyHandlers, (value, key) => key.toLowerCase());
handlers.current = mapKeys(keyHandlers, (value, key) => key?.toLowerCase());
}, [keyHandlers]);

/**
Expand All @@ -29,14 +29,15 @@ export default function useKeyDownHandlers(keyHandlers) {
* @type {(function(KeyboardEvent): void)}
*/
const handleEvent = useCallback((e) => {
if (!e.key) return;
const isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
const isCtrl = isMac ? e.metaKey : e.ctrlKey;
if (e.shiftKey && isCtrl) {
handlers.current[`ctrl-shift-${e.key.toLowerCase()}`]?.(e);
} else if (isCtrl) {
handlers.current[`ctrl-${e.key.toLowerCase()}`]?.(e);
}
handlers.current[e.key.toLowerCase()]?.(e);
handlers.current[e.key?.toLowerCase()]?.(e);
}, []);

useEffect(() => {
Expand Down
45 changes: 45 additions & 0 deletions client/common/useModalClose.js
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;
}
Loading

0 comments on commit 5d4c746

Please sign in to comment.