Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/share-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
raclim authored Mar 29, 2024
2 parents 3efa347 + 6c108f8 commit 498f995
Show file tree
Hide file tree
Showing 148 changed files with 8,874 additions and 3,600 deletions.
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"]
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,7 @@ If you have found a bug in the p5.js Web Editor, you can file it under the ["iss

### 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: [PATCH Release](https://github.com/processing/p5.js-web-editor/milestone/10), [MINOR Release](https://github.com/processing/p5.js-web-editor/milestone/8).

Issues and Pull Requests categorized under the PATCH or MINOR Release Milestones will be prioritized since they are planned to be merged for the next release to Production. Please feel free to [comment on this pinned issue](https://github.com/processing/p5.js-web-editor/issues/2534) if you would like your issue to be considered for the next release!


### When Will the Next Production Release Be?

We will aim to deploy on a 1-2 month basis. Here are some dates we’re working towards:

2.9.3 PATCH Release: By November 17, 2023

2.10.0 MINOR Release: By December 15, 2023

[You can read more about Semantic Versioning and the differences between a MINOR and PATCH release](https://semver.org/).
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
Expand Down
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
1 change: 1 addition & 0 deletions client/common/IconButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
File renamed without changes.
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;
}
3 changes: 2 additions & 1 deletion client/components/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import { remSize, prop } from '../theme';
import IconButton from '../common/IconButton';

const DropdownWrapper = styled.ul`
export const DropdownWrapper = styled.ul`
background-color: ${prop('Modal.background')};
border: 1px solid ${prop('Modal.border')};
box-shadow: 0 0 18px 0 ${prop('shadowColor')};
Expand Down Expand Up @@ -52,6 +52,7 @@ const DropdownWrapper = styled.ul`
& button span,
& a {
padding: ${remSize(8)} ${remSize(16)};
font-size: ${remSize(12)};
}
* {
Expand Down
Loading

0 comments on commit 498f995

Please sign in to comment.