Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version switcher #3334

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
15e426c
Initial version detection
davepagurek Feb 7, 2025
5acd3ea
Half working version switcher
davepagurek Feb 7, 2025
e0342fb
Show version in picker
davepagurek Feb 7, 2025
cf963b7
Switch to controlled preferences tabs; create version button
davepagurek Feb 20, 2025
5042faa
Add info for custom versions
davepagurek Feb 20, 2025
066bdf6
Add placeholders for other settings
davepagurek Feb 20, 2025
89f0d5e
Start to add code to do addon toggles
davepagurek Feb 20, 2025
6bd28e9
Fix return values
davepagurek Feb 20, 2025
1eac470
Add doctype
davepagurek Feb 27, 2025
de95b13
Make toggles actually do something!
davepagurek Feb 27, 2025
7b4ae4e
Add button to revert p5.sound version after a change
davepagurek Feb 27, 2025
b209f84
Move useP5Version into a provider to persist state
davepagurek Feb 27, 2025
22dee37
Add starburst on change to 2.0
davepagurek Mar 11, 2025
d85b7d5
Make toggling on restore instead of a button
davepagurek Mar 12, 2025
d6ff5ac
Add max height to version picker menu
davepagurek Mar 12, 2025
aeb8782
Make p5.sound regex more permissive
davepagurek Mar 12, 2025
2de2cae
Merge branch 'develop' into version-switcher
davepagurek Mar 13, 2025
c1f9dce
Add admonition and copy to clipboard button
davepagurek Mar 15, 2025
2279d3a
Use latest p5/p5.sound in textarea
davepagurek Mar 15, 2025
cae11eb
Style dropdown button
davepagurek Mar 15, 2025
38b340e
Merge branch 'develop' into version-switcher
davepagurek Mar 15, 2025
70fde43
Update versioning note + admonition
davepagurek Mar 17, 2025
53a517b
Merge branch 'develop' into version-switcher
davepagurek Mar 17, 2025
a3c2931
Merge branch 'develop' into version-switcher
davepagurek Mar 22, 2025
261fd12
Update admonition colors for contrast
davepagurek Mar 22, 2025
cb255e2
Add better hover state for version picker
davepagurek Mar 22, 2025
9139d02
Add pencil icon next to p5 version
davepagurek Mar 22, 2025
22871b5
Use fieldset and legend tags
davepagurek Mar 22, 2025
3f9c28b
Use fieldsets, fix aria labels
davepagurek Mar 22, 2025
9d2444f
Use gear icon
davepagurek Mar 22, 2025
3349904
Use new wording for addons
davepagurek Mar 25, 2025
2b2fb95
Add notification dot with label
davepagurek Mar 25, 2025
0d9430a
Update aria format
davepagurek Mar 25, 2025
d7088fb
Move version indicator to the toolbar
davepagurek Mar 28, 2025
45af524
Merge branch 'develop' into version-switcher
davepagurek Apr 4, 2025
3ac6c95
Use new compatibility addon URL, support new p5.sound for 2.0, preemp…
davepagurek Apr 4, 2025
55ab78e
Move indicator to the left, switch back to gear icon
davepagurek Apr 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/common/icons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ 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';
import Copy from '../images/copy.svg';

// HOC that adds the right web accessibility props
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
Expand Down Expand Up @@ -102,3 +103,4 @@ export const CircleFolderIcon = withLabel(CircleFolder);
export const CircleInfoIcon = withLabel(CircleInfo);
export const AddIcon = withLabel(Add);
export const FilterIcon = withLabel(Filter);
export const CopyIcon = withLabel(Copy);
19 changes: 15 additions & 4 deletions client/components/Dropdown/DropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import { DropdownWrapper } from '../Dropdown';

const DropdownMenu = forwardRef(
(
{ children, anchor, 'aria-label': ariaLabel, align, className, classes },
{
children,
anchor,
'aria-label': ariaLabel,
align,
className,
classes,
maxHeight
},
ref
) => {
// Note: need to use a ref instead of a state to avoid stale closures.
Expand All @@ -32,7 +40,7 @@ const DropdownMenu = forwardRef(
focusedRef.current = false;
setTimeout(() => {
if (!focusedRef.current) {
close();
// close();
}
}, 200);
};
Expand All @@ -59,6 +67,7 @@ const DropdownMenu = forwardRef(
}}
onBlur={handleBlur}
onFocus={handleFocus}
style={maxHeight && { maxHeight, overflowY: 'auto' }}
>
{children}
</DropdownWrapper>
Expand All @@ -84,14 +93,16 @@ DropdownMenu.propTypes = {
classes: PropTypes.shape({
button: PropTypes.string,
list: PropTypes.string
})
}),
maxHeight: PropTypes.string
};

DropdownMenu.defaultProps = {
anchor: null,
align: 'right',
className: '',
classes: {}
classes: {},
maxHeight: undefined
};

export default DropdownMenu;
1 change: 1 addition & 0 deletions client/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const STOP_ACCESSIBLE_OUTPUT = 'STOP_ACCESSIBLE_OUTPUT';

export const OPEN_PREFERENCES = 'OPEN_PREFERENCES';
export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES';
export const SET_PREFERENCES_TAB = 'SET_PREFERENCES_TAB';
export const SET_FONT_SIZE = 'SET_FONT_SIZE';
export const SET_LINE_NUMBERS = 'SET_LINE_NUMBERS';

Expand Down
6 changes: 6 additions & 0 deletions client/images/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/images/pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions client/modules/IDE/actions/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ function updatePreferences(formParams, dispatch) {
});
}

export function setPreferencesTab(value) {
return {
type: ActionTypes.SET_PREFERENCES_TAB,
value
};
}

export function setFontSize(value) {
return (dispatch, getState) => {
// eslint-disable-line
Expand Down
22 changes: 22 additions & 0 deletions client/modules/IDE/components/Admonition.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';

export default function Admonition({ children, title }) {
return (
<div className="admonition">
<p className="admonition__title">
<strong>{title}</strong>
</p>
{children}
</div>
);
}

Admonition.propTypes = {
title: PropTypes.string.isRequired,
children: PropTypes.node
};

Admonition.defaultProps = {
children: undefined
};
20 changes: 18 additions & 2 deletions client/modules/IDE/components/Editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Editor extends React.Component {
this.showFind = this.showFind.bind(this);
this.showReplace = this.showReplace.bind(this);
this.getContent = this.getContent.bind(this);
this.updateFileContent = this.updateFileContent.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -220,7 +221,8 @@ class Editor extends React.Component {
tidyCode: this.tidyCode,
showFind: this.showFind,
showReplace: this.showReplace,
getContent: this.getContent
getContent: this.getContent,
updateFileContent: this.updateFileContent
});
}

Expand Down Expand Up @@ -254,6 +256,9 @@ class Editor extends React.Component {
if (!prevProps.unsavedChanges) {
setTimeout(() => this.props.setUnsavedChanges(false), 400);
}
} else if (this.getContent().content !== this.props.file.content) {
// TODO: make this not break regular edits!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davepagurek This was pending the CM6 upgrade which will need ~2-3 weeks (after p5.js 2.0 release in any case). So we can move forward without waiting to resolve this TODO but need to keep it in mind when the upgrade is happening, @raclim will coordinate!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I made this not break on the current version of CM so I think this TODO comment may be good to remove. I'll double-check this week!

// this._cm.setValue(this.props.file.content);
}
if (this.props.fontSize !== prevProps.fontSize) {
this._cm.getWrapperElement().style[
Expand Down Expand Up @@ -329,7 +334,8 @@ class Editor extends React.Component {
tidyCode: this.tidyCode,
showFind: this.showFind,
showReplace: this.showReplace,
getContent: this.getContent
getContent: this.getContent,
updateFileContent: this.updateFileContent
});
}

Expand Down Expand Up @@ -366,6 +372,16 @@ class Editor extends React.Component {
return updatedFile;
}

updateFileContent(id, src) {
const file = this._docs[id];
if (file) {
this._docs[id] = CodeMirror.Doc(src, this._docs[id].modeOption);
if (id === this.props.file.id) {
this._cm.swapDoc(this._docs[id]);
}
}
}

handleKeyUp = () => {
const lineNumber = parseInt(this._cm.getCursor().line + 1, 10);
this.setState({ currentLine: lineNumber });
Expand Down
3 changes: 3 additions & 0 deletions client/modules/IDE/components/Header/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import PlayIcon from '../../../../images/play.svg';
import StopIcon from '../../../../images/stop.svg';
import PreferencesIcon from '../../../../images/preferences.svg';
import ProjectName from './ProjectName';
import VersionIndicator from '../VersionIndicator';

const Toolbar = (props) => {
const { isPlaying, infiniteLoop, preferencesIsVisible } = useSelector(
Expand Down Expand Up @@ -113,6 +114,8 @@ const Toolbar = (props) => {
return null;
})()}
</div>
<VersionIndicator />
<div style={{ flex: 1 }} />
<button
className={preferencesButtonClass}
onClick={() => dispatch(openPreferences())}
Expand Down
Loading