Skip to content

Commit dc1b51d

Browse files
committed
Merge branch 'develop' into connie-develop
2 parents f7cbcab + a8dbd59 commit dc1b51d

File tree

27 files changed

+199
-103
lines changed

27 files changed

+199
-103
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@
6262
}
6363
]
6464
]
65+
},
66+
"test": {
67+
"presets": [
68+
"@babel/preset-env",
69+
[
70+
"@babel/preset-react",
71+
{
72+
"runtime": "automatic"
73+
}
74+
]
75+
],
76+
"plugins": [
77+
"babel-plugin-styled-components"
78+
]
6579
}
6680
},
6781
"plugins": [

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For first-time contributors or those who want to start with a small task, [check
4646
If you're looking for a bigger project to take on, look through the issues tagged [good medium issue](https://github.com/processing/p5.js-web-editor/labels/good%20medium%20issue). These issues are self-contained projects that may take longer to work on, but are great if you're looking to get more deeply involved in contributing!
4747

4848
### Project Board
49-
Many issues are related to each other and fall under bigger projects. To get a bigger picture, look at the [All Projects](https://github.com/processing/p5.js-web-editor/projects/4) board.
49+
Many issues are related to each other and fall under bigger projects. To get a bigger picture, look at the [All Projects](https://github.com/processing/p5.js-web-editor/projects/) board.
5050

5151
### Project Ideas
5252
If you're looking for inspiration for Google Summer of Code or a bigger project, there's a [project list](https://github.com/processing/processing/wiki/Project-List#p5js-web-editor) maintained on the Processing wiki.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Learn more about [our community](https://p5js.org/community/) and read our commu
1414

1515
## Getting Started
1616

17-
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.
17+
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/tutorials/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.
1818

1919

2020
## Issues

client/modules/IDE/components/Editor/index.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class Editor extends React.Component {
151151
},
152152
Enter: 'emmetInsertLineBreak',
153153
Esc: 'emmetResetAbbreviation',
154+
[`Shift-Tab`]: false,
154155
[`${metaKey}-Enter`]: () => null,
155156
[`Shift-${metaKey}-Enter`]: () => null,
156157
[`${metaKey}-F`]: 'findPersistent',
@@ -192,10 +193,6 @@ class Editor extends React.Component {
192193
if (/^[a-z]$/i.test(e.key) && (mode === 'css' || mode === 'javascript')) {
193194
showHint(_cm, this.props.autocompleteHinter, this.props.fontSize);
194195
}
195-
if (e.key === 'Escape') {
196-
e.preventDefault();
197-
this._cm.getInputField().blur();
198-
}
199196
});
200197

201198
this._cm.getWrapperElement().style[

client/modules/IDE/components/FileNode.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ const FileNode = ({
292292
ref={fileOptionsRef}
293293
tabIndex="0"
294294
onClick={toggleFileOptions}
295+
onBlur={() => setTimeout(hideFileOptions, 200)}
295296
>
296297
<DownArrowIcon focusable="false" aria-hidden="true" />
297298
</button>

client/modules/IDE/components/Header/__snapshots__/Nav.unit.test.jsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
211211
-ms-flex-direction: column;
212212
flex-direction: column;
213213
gap: 0.16666666666666666rem;
214-
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px, rgba(60,64,67,0.15) 0px 1px 3px 1px;
214+
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px,rgba(60,64,67,0.15) 0px 1px 3px 1px;
215215
min-width: 10rem;
216216
border-radius: 0.16666666666666666rem;
217217
}
@@ -324,7 +324,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
324324
>
325325
<test-file-stub
326326
aria-hidden="true"
327-
classname="sc-fujyAs cSTVlM"
327+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
328328
focusable="false"
329329
/>
330330
</button>
@@ -340,7 +340,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
340340
>
341341
<test-file-stub
342342
aria-hidden="true"
343-
classname="sc-iqAclL iOZiVo"
343+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
344344
focusable="false"
345345
/>
346346
</button>
@@ -912,7 +912,7 @@ exports[`Nav renders editor version for mobile 1`] = `
912912
-ms-flex-direction: column;
913913
flex-direction: column;
914914
gap: 0.16666666666666666rem;
915-
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px, rgba(60,64,67,0.15) 0px 1px 3px 1px;
915+
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px,rgba(60,64,67,0.15) 0px 1px 3px 1px;
916916
min-width: 10rem;
917917
border-radius: 0.16666666666666666rem;
918918
}
@@ -1025,7 +1025,7 @@ exports[`Nav renders editor version for mobile 1`] = `
10251025
>
10261026
<test-file-stub
10271027
aria-hidden="true"
1028-
classname="sc-fujyAs cSTVlM"
1028+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
10291029
focusable="false"
10301030
/>
10311031
</button>
@@ -1041,7 +1041,7 @@ exports[`Nav renders editor version for mobile 1`] = `
10411041
>
10421042
<test-file-stub
10431043
aria-hidden="true"
1044-
classname="sc-iqAclL iOZiVo"
1044+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
10451045
focusable="false"
10461046
/>
10471047
</button>

client/modules/IDE/components/Sidebar.jsx

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef } from 'react';
1+
import React, { useRef, useEffect } from 'react';
22
import classNames from 'classnames';
33
import { useTranslation } from 'react-i18next';
44
import { useDispatch, useSelector } from 'react-redux';
@@ -30,21 +30,37 @@ export default function SideBar() {
3030
);
3131
const isExpanded = useSelector((state) => state.ide.sidebarIsExpanded);
3232
const canEditProject = useSelector(selectCanEditSketch);
33+
const isAuthenticated = useSelector(getAuthenticated);
3334

3435
const sidebarOptionsRef = useRef(null);
3536

36-
const isAuthenticated = useSelector(getAuthenticated);
37+
useEffect(() => {
38+
function handleClickOutside(event) {
39+
if (
40+
projectOptionsVisible &&
41+
sidebarOptionsRef.current &&
42+
!sidebarOptionsRef.current.contains(event.target)
43+
) {
44+
setTimeout(() => dispatch(closeProjectOptions()), 300);
45+
}
46+
}
3747

38-
const onBlurComponent = () => {
39-
setTimeout(() => dispatch(closeProjectOptions()), 200);
40-
};
48+
if (projectOptionsVisible) {
49+
document.addEventListener('mousedown', handleClickOutside);
50+
} else {
51+
document.removeEventListener('mousedown', handleClickOutside);
52+
}
53+
54+
return () => {
55+
document.removeEventListener('mousedown', handleClickOutside);
56+
};
57+
}, [projectOptionsVisible, dispatch]);
4158

4259
const toggleProjectOptions = (e) => {
4360
e.preventDefault();
4461
if (projectOptionsVisible) {
4562
dispatch(closeProjectOptions());
4663
} else {
47-
sidebarOptionsRef.current?.focus();
4864
dispatch(openProjectOptions());
4965
}
5066
};
@@ -65,9 +81,7 @@ export default function SideBar() {
6581
dispatch(collapseSidebar());
6682
dispatch(closeProjectOptions());
6783
}}
68-
>
69-
{' '}
70-
</button>
84+
/>
7185
)}
7286
<section className={sidebarClass}>
7387
<header
@@ -77,57 +91,54 @@ export default function SideBar() {
7791
<h3 className="sidebar__title">
7892
<span>{t('Sidebar.Title')}</span>
7993
</h3>
80-
<div className="sidebar__icons">
94+
<div className="sidebar__icons" ref={sidebarOptionsRef}>
8195
<button
8296
aria-label={t('Sidebar.ToggleARIA')}
8397
className="sidebar__add"
8498
tabIndex="0"
85-
ref={sidebarOptionsRef}
8699
onClick={toggleProjectOptions}
87-
onBlur={onBlurComponent}
88100
>
89101
<PlusIcon focusable="false" aria-hidden="true" />
90102
</button>
91-
<ul className="sidebar__project-options">
92-
<li>
93-
<button
94-
aria-label={t('Sidebar.AddFolderARIA')}
95-
onClick={() => {
96-
dispatch(newFolder(rootFile.id));
97-
setTimeout(() => dispatch(closeProjectOptions()), 0);
98-
}}
99-
onBlur={onBlurComponent}
100-
>
101-
{t('Sidebar.AddFolder')}
102-
</button>
103-
</li>
104-
<li>
105-
<button
106-
aria-label={t('Sidebar.AddFileARIA')}
107-
onClick={() => {
108-
dispatch(newFile(rootFile.id));
109-
setTimeout(() => dispatch(closeProjectOptions()), 0);
110-
}}
111-
onBlur={onBlurComponent}
112-
>
113-
{t('Sidebar.AddFile')}
114-
</button>
115-
</li>
116-
{isAuthenticated && (
103+
{projectOptionsVisible && (
104+
<ul className="sidebar__project-options">
105+
<li>
106+
<button
107+
aria-label={t('Sidebar.AddFolderARIA')}
108+
onClick={() => {
109+
dispatch(newFolder(rootFile.id));
110+
setTimeout(() => dispatch(closeProjectOptions()), 300);
111+
}}
112+
>
113+
{t('Sidebar.AddFolder')}
114+
</button>
115+
</li>
117116
<li>
118117
<button
119-
aria-label={t('Sidebar.UploadFileARIA')}
118+
aria-label={t('Sidebar.AddFileARIA')}
120119
onClick={() => {
121-
dispatch(openUploadFileModal(rootFile.id));
122-
setTimeout(() => dispatch(closeProjectOptions()), 0);
120+
dispatch(newFile(rootFile.id));
121+
setTimeout(() => dispatch(closeProjectOptions()), 300);
123122
}}
124-
onBlur={onBlurComponent}
125123
>
126-
{t('Sidebar.UploadFile')}
124+
{t('Sidebar.AddFile')}
127125
</button>
128126
</li>
129-
)}
130-
</ul>
127+
{isAuthenticated && (
128+
<li>
129+
<button
130+
aria-label={t('Sidebar.UploadFileARIA')}
131+
onClick={() => {
132+
dispatch(openUploadFileModal(rootFile.id));
133+
setTimeout(() => dispatch(closeProjectOptions()), 300);
134+
}}
135+
>
136+
{t('Sidebar.UploadFile')}
137+
</button>
138+
</li>
139+
)}
140+
</ul>
141+
)}
131142
</div>
132143
</header>
133144
<ConnectedFileNode id={rootFile.id} canEdit={canEditProject} />

client/modules/IDE/hooks/custom-hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export const useModalBehavior = (hideOverlay) => {
4747
};
4848

4949
// Usage: useEffectWithComparison((props, prevProps) => { ... }, { prop1, prop2 })
50-
// This hook basically applies useEffect but keeping track of the last value of relevant props
51-
// So you can passa a 2-param function to capture new and old values and do whatever with them.
50+
// This hook basically applies useEffect but keeps track of the last value of relevant props
51+
// So you can pass a 2-param function to capture new and old values and do whatever with them.
5252
export const useEffectWithComparison = (fn, props) => {
5353
const [prevProps, update] = useState({});
5454

client/modules/User/components/AccountForm.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ function AccountForm() {
9797
{t('AccountForm.EmailSent')}
9898
</span>
9999
) : (
100-
<Button onClick={handleInitiateVerification}>
100+
<Button
101+
onClick={handleInitiateVerification}
102+
className="form__resend-button"
103+
>
101104
{t('AccountForm.Resend')}
102105
</Button>
103106
)}

client/modules/User/components/SignupForm.jsx

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,43 @@ import Button from '../../../common/Button';
99
import apiClient from '../../../utils/apiClient';
1010
import useSyncFormTranslations from '../../../common/useSyncFormTranslations';
1111

12+
const timeoutRef = { current: null };
13+
1214
function asyncValidate(fieldToValidate, value) {
1315
if (!value || value.trim().length === 0) {
14-
return '';
16+
return Promise.resolve('');
1517
}
16-
const queryParams = {};
17-
queryParams[fieldToValidate] = value;
18-
queryParams.check_type = fieldToValidate;
19-
return apiClient
20-
.get('/signup/duplicate_check', { params: queryParams })
21-
.then((response) => {
22-
if (response.data.exists) {
23-
return response.data.message;
24-
}
25-
return '';
26-
});
18+
19+
const queryParams = {
20+
[fieldToValidate]: value,
21+
check_type: fieldToValidate
22+
};
23+
24+
return new Promise((resolve) => {
25+
if (timeoutRef.current) {
26+
timeoutRef.current();
27+
}
28+
29+
const timerId = setTimeout(() => {
30+
apiClient
31+
.get('/signup/duplicate_check', { params: queryParams })
32+
.then((response) => {
33+
if (response.data.exists) {
34+
resolve(response.data.message);
35+
} else {
36+
resolve('');
37+
}
38+
})
39+
.catch(() => {
40+
resolve('An error occurred while validating');
41+
});
42+
}, 300);
43+
44+
timeoutRef.current = () => {
45+
clearTimeout(timerId);
46+
resolve('');
47+
};
48+
});
2749
}
2850

2951
function validateUsername(username) {
@@ -36,27 +58,30 @@ function validateEmail(email) {
3658

3759
function SignupForm() {
3860
const { t, i18n } = useTranslation();
39-
4061
const dispatch = useDispatch();
41-
function onSubmit(formProps) {
42-
return dispatch(validateAndSignUpUser(formProps));
43-
}
62+
const formRef = useRef(null);
4463
const [showPassword, setShowPassword] = useState(false);
4564
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
46-
const formRef = useRef(null);
47-
const handleVisibility = () => {
48-
setShowPassword(!showPassword);
49-
};
50-
const handleConfirmVisibility = () => {
51-
setShowConfirmPassword(!showConfirmPassword);
52-
};
65+
5366
useSyncFormTranslations(formRef, i18n.language);
5467

68+
const handleVisibility = () => setShowPassword(!showPassword);
69+
const handleConfirmVisibility = () =>
70+
setShowConfirmPassword(!showConfirmPassword);
71+
72+
function onSubmit(formProps) {
73+
console.log("it's happening");
74+
return dispatch(validateAndSignUpUser(formProps));
75+
}
76+
5577
return (
5678
<Form
5779
fields={['username', 'email', 'password', 'confirmPassword']}
5880
validate={validateSignup}
59-
onSubmit={onSubmit}
81+
onSubmit={(values) => {
82+
console.log('Form onSubmit triggered', values);
83+
return onSubmit(values);
84+
}}
6085
>
6186
{({ handleSubmit, pristine, submitting, invalid, form }) => {
6287
formRef.current = form;

0 commit comments

Comments
 (0)