Skip to content

Commit 66186f1

Browse files
authored
Merge branch 'develop' into piyush/refactor-collections-reducers-actions-redux-toolkit
2 parents 2c887c5 + 99b9463 commit 66186f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+649
-644
lines changed

client/common/useKeyDownHandlers.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export default function useKeyDownHandlers(keyHandlers) {
3333
const isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
3434
const isCtrl = isMac ? e.metaKey : e.ctrlKey;
3535
if (e.shiftKey && isCtrl) {
36-
handlers.current[`ctrl-shift-${e.key.toLowerCase()}`]?.(e);
36+
handlers.current[
37+
`ctrl-shift-${
38+
/^\d+$/.test(e.code.at(-1)) ? e.code.at(-1) : e.key.toLowerCase()
39+
}`
40+
]?.(e);
3741
} else if (isCtrl) {
3842
handlers.current[`ctrl-${e.key.toLowerCase()}`]?.(e);
3943
}

client/components/AddRemoveButton.jsx

-32
This file was deleted.

client/components/NavBasic.jsx

-52
This file was deleted.

client/components/OverlayManager.jsx

-26
This file was deleted.

client/components/PreviewNav.jsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ const PreviewNav = ({ owner, project }) => {
1212
<nav className="nav preview-nav">
1313
<div className="nav__items-left">
1414
<div className="nav__item-logo">
15-
<LogoIcon
16-
role="img"
17-
aria-label={t('Common.p5logoARIA')}
18-
focusable="false"
19-
className="svg__logo"
20-
/>
15+
<Link to={`/${owner.username}/sketches`}>
16+
<LogoIcon
17+
role="img"
18+
aria-label={t('Common.p5logoARIA')}
19+
focusable="false"
20+
className="svg__logo"
21+
/>
22+
</Link>
2123
</div>
2224
<Link
2325
className="nav__item"

client/components/SkipLink.jsx

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useState } from 'react';
2+
import classNames from 'classnames';
3+
import PropTypes from 'prop-types';
4+
import { useTranslation } from 'react-i18next';
5+
6+
const SkipLink = ({ targetId, text }) => {
7+
const [focus, setFocus] = useState(false);
8+
const { t } = useTranslation();
9+
const handleFocus = () => {
10+
setFocus(true);
11+
};
12+
13+
const handleBlur = () => {
14+
setFocus(false);
15+
};
16+
const linkClasses = classNames('skip_link', { focus });
17+
18+
return (
19+
<a
20+
href={`#${targetId}`}
21+
className={linkClasses}
22+
onFocus={handleFocus}
23+
onBlur={handleBlur}
24+
>
25+
{t(`SkipLink.${text}`)}
26+
</a>
27+
);
28+
};
29+
30+
SkipLink.propTypes = {
31+
targetId: PropTypes.string.isRequired,
32+
text: PropTypes.string.isRequired
33+
};
34+
35+
export default SkipLink;
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
import React from 'react';
2-
import { connect } from 'react-redux';
3-
import browserHistory from '../browserHistory';
1+
import { useEffect } from 'react';
2+
import { useSelector } from 'react-redux';
3+
import { useHistory } from 'react-router-dom';
4+
import PropTypes from 'prop-types';
45

5-
const RedirectToUser = ({ username, url = '/:username/sketches' }) => {
6-
React.useEffect(() => {
7-
if (username == null) {
8-
return;
6+
const RedirectToUser = ({ url = '/:username/sketches' }) => {
7+
const history = useHistory();
8+
const username = useSelector((state) =>
9+
state.user ? state.user.username : null
10+
);
11+
useEffect(() => {
12+
if (username) {
13+
history.replace(url.replace(':username', username));
914
}
10-
11-
browserHistory.replace(url.replace(':username', username));
12-
}, [username]);
15+
}, [history, url, username]);
1316

1417
return null;
1518
};
1619

17-
function mapStateToProps(state) {
18-
return {
19-
username: state.user ? state.user.username : null
20-
};
21-
}
22-
23-
const ConnectedRedirectToUser = connect(mapStateToProps)(RedirectToUser);
24-
25-
const createRedirectWithUsername = (url) => (props) => (
26-
<ConnectedRedirectToUser {...props} url={url} />
27-
);
20+
RedirectToUser.propTypes = {
21+
url: PropTypes.string.isRequired
22+
};
2823

29-
export default createRedirectWithUsername;
24+
export default RedirectToUser;

client/constants.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// multiple files
33
export const UPDATE_FILE_CONTENT = 'UPDATE_FILE_CONTENT';
44
export const TOGGLE_SKETCH = 'TOGGLE_SKETCH';
5-
65
export const START_SKETCH = 'START_SKETCH';
76
export const STOP_SKETCH = 'STOP_SKETCH';
87

@@ -47,8 +46,6 @@ export const SET_BLOB_URL = 'SET_BLOB_URL';
4746
export const EXPAND_SIDEBAR = 'EXPAND_SIDEBAR';
4847
export const COLLAPSE_SIDEBAR = 'COLLAPSE_SIDEBAR';
4948

50-
export const CONSOLE_EVENT = 'CONSOLE_EVENT';
51-
export const CLEAR_CONSOLE = 'CLEAR_CONSOLE';
5249
export const EXPAND_CONSOLE = 'EXPAND_CONSOLE';
5350
export const COLLAPSE_CONSOLE = 'COLLAPSE_CONSOLE';
5451

@@ -135,3 +132,6 @@ export const START_SAVING_PROJECT = 'START_SAVING_PROJECT';
135132
export const END_SAVING_PROJECT = 'END_SAVING_PROJECT';
136133

137134
export const SET_COOKIE_CONSENT = 'SET_COOKIE_CONSENT';
135+
136+
export const CONSOLE_EVENT = 'CONSOLE_EVENT';
137+
export const CLEAR_CONSOLE = 'CLEAR_CONSOLE';

client/i18n-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import i18n from 'i18next';
22
import { initReactI18next } from 'react-i18next';
3-
43
import translations from '../translations/locales/en-US/translations.json';
54

65
i18n.use(initReactI18next).init({

client/index.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Routing from './routes';
99
import ThemeProvider from './modules/App/components/ThemeProvider';
1010
import Loader from './modules/App/components/loader';
1111
import './i18n';
12+
import SkipLink from './components/SkipLink';
1213

1314
require('./styles/main.scss');
1415

@@ -23,6 +24,7 @@ const App = () => (
2324
<Provider store={store}>
2425
<ThemeProvider>
2526
<Router history={browserHistory}>
27+
<SkipLink targetId="play-sketch" text="PlaySketch" />
2628
<Routing />
2729
</Router>
2830
</ThemeProvider>

client/modules/IDE/actions/console.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
import * as ActionTypes from '../../../constants';
2-
3-
export function clearConsole() {
4-
return {
5-
type: ActionTypes.CLEAR_CONSOLE
6-
};
7-
}
8-
9-
export function dispatchConsoleEvent(messages) {
10-
return {
11-
type: ActionTypes.CONSOLE_EVENT,
12-
event: messages
13-
};
14-
}
1+
export { dispatchConsoleEvent, clearConsole } from '../reducers/console';

client/modules/IDE/components/AssetSize.jsx

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
3-
import { connect } from 'react-redux';
2+
import { useSelector } from 'react-redux';
43
import prettyBytes from 'pretty-bytes';
54

65
import getConfig from '../../../utils/getConfig';
@@ -18,7 +17,11 @@ const formatPercent = (percent) => {
1817
};
1918

2019
/* Eventually, this copy should be Total / 250 MB Used */
21-
const AssetSize = ({ totalSize }) => {
20+
const AssetSize = () => {
21+
const totalSize = useSelector(
22+
(state) => state.user.totalSize || state.assets.totalSize
23+
);
24+
2225
if (totalSize === undefined) {
2326
return null;
2427
}
@@ -40,15 +43,4 @@ const AssetSize = ({ totalSize }) => {
4043
);
4144
};
4245

43-
AssetSize.propTypes = {
44-
totalSize: PropTypes.number.isRequired
45-
};
46-
47-
function mapStateToProps(state) {
48-
return {
49-
user: state.user,
50-
totalSize: state.user.totalSize || state.assets.totalSize
51-
};
52-
}
53-
54-
export default connect(mapStateToProps)(AssetSize);
46+
export default AssetSize;

0 commit comments

Comments
 (0)