Skip to content

Useable Mobile Editor 🎉 #2387

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

Merged
merged 45 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
953b772
updated error
dewanshDT Aug 17, 2023
be50580
added UnsavedChangesIndicator
dewanshDT Aug 17, 2023
bc3b2c5
moved editor to a folder
dewanshDT Aug 17, 2023
ae19086
added mobile editor components
dewanshDT Aug 17, 2023
9181989
modified the editor to use mobile components
dewanshDT Aug 17, 2023
a847e3f
merge lindapaiste:refactor/ide-overlays
dewanshDT Aug 17, 2023
00724fd
converted the IDEView to functional component and added MediaQuery
dewanshDT Aug 17, 2023
822f247
unsaved changes old
dewanshDT Aug 17, 2023
c12f2d7
Merge branch 'dewanshmobile/FAB' of https://github.com/dewanshDT/p5.j…
dewanshDT Aug 17, 2023
ad3fbbb
made the IDEView use the floating action button
dewanshDT Aug 17, 2023
178c37c
useKeyDownHandlers null safe
dewanshDT Aug 17, 2023
1aff6da
css overflow changes
dewanshDT Aug 17, 2023
0a2c755
moved editor test
dewanshDT Aug 17, 2023
c7b26d7
Merge branch 'develop' into dewanshmobile/ide
dewanshDT Aug 17, 2023
f274edd
removed unused refs
dewanshDT Aug 17, 2023
3a25305
removed logs
dewanshDT Aug 17, 2023
6f2f428
Merge branch 'dewanshmobile/ide' of https://github.com/dewanshDT/p5.j…
dewanshDT Aug 17, 2023
9f97e4e
overlay to state
dewanshDT Aug 17, 2023
c83c1cc
rename editor
dewanshDT Aug 19, 2023
47db20a
Merge branch 'develop' into dewanshmobile/ide
dewanshDT Aug 19, 2023
5c3b40b
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
dewanshDT Aug 25, 2023
f0521ce
size fix
dewanshDT Aug 28, 2023
828e182
console size
dewanshDT Aug 28, 2023
c1f41a4
optimized sidebar
dewanshDT Aug 28, 2023
29db062
autosave interval
dewanshDT Aug 28, 2023
7e03969
autosave
dewanshDT Aug 28, 2023
e70da37
file drawer styling
dewanshDT Aug 28, 2023
0f9e496
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
dewanshDT Aug 28, 2023
5861053
snapshots
dewanshDT Aug 28, 2023
52054dc
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
dewanshDT Aug 29, 2023
c508ee6
merge error resolved
dewanshDT Sep 2, 2023
e51df1e
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
dewanshDT Sep 2, 2023
f33574e
Merge branch 'develop' into dewanshmobile/ide
lindapaiste Sep 2, 2023
7b26a79
test fix
dewanshDT Sep 2, 2023
67043d9
location hook
dewanshDT Sep 2, 2023
8d36f7e
editor navigation and hook
dewanshDT Sep 2, 2023
f0490b8
sidebar dropdown fix
dewanshDT Sep 3, 2023
2428625
Merge branch 'dewanshmobile/ide' of https://github.com/dewanshDT/p5.j…
dewanshDT Sep 3, 2023
7b309ed
5 secs
dewanshDT Sep 3, 2023
2a2fa99
auto save logic
dewanshDT Sep 3, 2023
8745281
Merge branch 'develop' into dewanshmobile/ide
lindapaiste Sep 3, 2023
a3ad31a
Merge branch 'dewanshmobile/ide' of https://github.com/dewanshDT/p5.j…
dewanshDT Sep 3, 2023
62daa3c
* get params from react-router hook
lindapaiste Sep 3, 2023
640a293
Merge pull request #4 from lindapaiste/dewanshmobile/ide
dewanshDT Sep 3, 2023
3fed465
a dependency
dewanshDT Sep 3, 2023
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
6 changes: 6 additions & 0 deletions client/components/RootPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { prop } from '../theme';
const RootPage = styled.div`
min-height: 100%;
display: flex;
justify-content: start;
flex-direction: column;
color: ${prop('primaryTextColor')};
background-color: ${prop('backgroundColor')};
height: ${({ fixedHeight }) => fixedHeight || 'initial'};

@media (max-width: 770px) {
height: 100%;
overflow: hidden;
}
`;

export default RootPage;
13 changes: 2 additions & 11 deletions client/images/plus-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/index.integration.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('index.jsx integration', () => {
// spy on this function and wait for it to be called before making assertions
const spy = jest.spyOn(Actions, 'getUser');

window.process.env.PREVIEW_URL = 'http://localhost:8002';
beforeEach(async () => {
act(() => {
subject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { act } from 'react-dom/test-utils';
import Editor from './Editor';
import { reduxRender } from '../../../test-utils';
import { initialTestState } from '../../../testData/testReduxStore';
import Editor from '.';
import { reduxRender } from '../../../../test-utils';
import { initialTestState } from '../../../../testData/testReduxStore';

jest.mock('../../../i18n');
jest.mock('../../../../i18n');

describe('<Editor />', () => {
const mockStore = configureStore([thunk]);
Expand Down
79 changes: 79 additions & 0 deletions client/modules/IDE/components/Editor/MobileEditor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import styled from 'styled-components';
import { prop, remSize } from '../../../../theme';

export const EditorContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
padding-bottom: 5rem;
transform: ${(props) =>
props.expanded ? 'translateX(50%)' : 'translateX(0)'};

> header {
display: flex;
${prop('MobilePanel.secondary')}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we’ve got a value with no property? Here and on line 21.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no this is to set the background color, it automatically does that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can also change all the foreground key in the theme to color to set the color and background automaticall by just writing this one line ${prop('some object background and color property')}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, I see what you’re saying. You put the “color:” part in the theme object. So it’s like a mixin rather than a color variable.

> span {
display: flex;
justify-content: center;
align-items: center;
padding: ${remSize(10)};
font-weight: bold;
${prop('MobilePanel.default')}
}
}

> section {
display: flex;
flex-direction: column;
height: 100%;
width: 100vw;
overflow-y: auto;
}
`;

export const EditorHolder = styled.div`
min-height: 100%;
`;

export const PreviewWrapper = styled.div`
display: ${(props) => (props.show ? 'block' : 'none')};
position: relative;
height: 100vh;
min-width: 100%;

.preview-console {
z-index: 1;
}
`;

export const EditorSidebarWrapper = styled.div`
display: ${(props) => (props.show ? 'block' : 'none')};
height: 100%;
position: relative;
`;

export const FileDrawer = styled.div`
height: 100%;
width: 50vw;
display: flex;
flex-direction: column;
position: absolute;
/* z-index: 10; */
background: ${prop('backgroundColor')};

> button[data-backdrop='filedrawer'] {
position: absolute;
background-color: #0005;
height: 100%;
width: 100%;
z-index: 2;
transform: translateX(100%);
}

@media (min-width: 770px) {
width: 100%;
> button[data-backdrop='filedrawer'] {
display: none;
}
}
`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: convert to functional component

import PropTypes from 'prop-types';
import React from 'react';
import CodeMirror from 'codemirror';
Expand Down Expand Up @@ -40,32 +42,35 @@ import classNames from 'classnames';
import { debounce } from 'lodash';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import '../../../utils/htmlmixed';
import '../../../utils/p5-javascript';
import Timer from '../components/Timer';
import EditorAccessibility from '../components/EditorAccessibility';
import { selectActiveFile } from '../selectors/files';
import AssetPreview from './AssetPreview';
import { metaKey } from '../../../utils/metaKey';
import './show-hint';
import * as hinter from '../../../utils/p5-hinter';

import '../../../utils/codemirror-search';

import beepUrl from '../../../sounds/audioAlert.mp3';
import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg';
import RightArrowIcon from '../../../images/right-arrow.svg';
import LeftArrowIcon from '../../../images/left-arrow.svg';
import { getHTMLFile } from '../reducers/files';

import * as FileActions from '../actions/files';
import * as IDEActions from '../actions/ide';
import * as ProjectActions from '../actions/project';
import * as EditorAccessibilityActions from '../actions/editorAccessibility';
import * as PreferencesActions from '../actions/preferences';
import * as UserActions from '../../User/actions';
import * as ToastActions from '../actions/toast';
import * as ConsoleActions from '../actions/console';
import MediaQuery from 'react-responsive';
import '../../../../utils/htmlmixed';
import '../../../../utils/p5-javascript';
import { metaKey } from '../../../../utils/metaKey';
import '../show-hint';
import * as hinter from '../../../../utils/p5-hinter';
import '../../../../utils/codemirror-search';

import beepUrl from '../../../../sounds/audioAlert.mp3';
import RightArrowIcon from '../../../../images/right-arrow.svg';
import LeftArrowIcon from '../../../../images/left-arrow.svg';
import { getHTMLFile } from '../../reducers/files';
import { selectActiveFile } from '../../selectors/files';

import * as FileActions from '../../actions/files';
import * as IDEActions from '../../actions/ide';
import * as ProjectActions from '../../actions/project';
import * as EditorAccessibilityActions from '../../actions/editorAccessibility';
import * as PreferencesActions from '../../actions/preferences';
import * as UserActions from '../../../User/actions';
import * as ConsoleActions from '../../actions/console';

import AssetPreview from '../AssetPreview';
import Timer from '../Timer';
import EditorAccessibility from '../EditorAccessibility';
import UnsavedChangesIndicator from '../UnsavedChangesIndicator';
import { EditorContainer, EditorHolder } from './MobileEditor';
import { FolderIcon } from '../../../../common/icons';
import IconButton from '../../../../components/mobile/IconButton';

emmet(CodeMirror);

Expand Down Expand Up @@ -98,7 +103,7 @@ class Editor extends React.Component {

componentDidMount() {
this.beep = new Audio(beepUrl);
this.widgets = [];
// this.widgets = [];
this._cm = CodeMirror(this.codemirrorContainer, {
theme: `p5-${this.props.theme}`,
lineNumbers: this.props.lineNumbers,
Expand Down Expand Up @@ -306,6 +311,13 @@ class Editor extends React.Component {
this._cm.removeLineClass(i, 'background', 'line-runtime-error');
}
}

this.props.provideController({
tidyCode: this.tidyCode,
showFind: this.showFind,
showReplace: this.showReplace,
getContent: this.getContent
});
}

componentWillUnmount() {
Expand Down Expand Up @@ -496,52 +508,77 @@ class Editor extends React.Component {
});

return (
<section className={editorSectionClass}>
<header className="editor__header">
<button
aria-label={this.props.t('Editor.OpenSketchARIA')}
className="sidebar__contract"
onClick={() => {
this.props.collapseSidebar();
this.props.closeProjectOptions();
}}
>
<LeftArrowIcon focusable="false" aria-hidden="true" />
</button>
<button
aria-label={this.props.t('Editor.CloseSketchARIA')}
className="sidebar__expand"
onClick={this.props.expandSidebar}
>
<RightArrowIcon focusable="false" aria-hidden="true" />
</button>
<div className="editor__file-name">
<span>
{this.props.file.name}
<span className="editor__unsaved-changes">
{this.props.unsavedChanges ? (
<UnsavedChangesDotIcon
role="img"
aria-label={this.props.t('Editor.UnsavedChangesARIA')}
focusable="false"
<MediaQuery minWidth={770}>
{(matches) =>
matches ? (
<section className={editorSectionClass}>
<header className="editor__header">
<button
aria-label={this.props.t('Editor.OpenSketchARIA')}
className="sidebar__contract"
onClick={this.props.collapseSidebar}
>
<LeftArrowIcon focusable="false" aria-hidden="true" />
</button>
<button
aria-label={this.props.t('Editor.CloseSketchARIA')}
className="sidebar__expand"
onClick={this.props.expandSidebar}
>
<RightArrowIcon focusable="false" aria-hidden="true" />
</button>
<div className="editor__file-name">
<span>
{this.props.file.name}
<UnsavedChangesIndicator />
</span>
<Timer />
</div>
</header>
<article
ref={(element) => {
this.codemirrorContainer = element;
}}
className={editorHolderClass}
/>
{this.props.file.url ? (
<AssetPreview
url={this.props.file.url}
name={this.props.file.name}
/>
) : null}
<EditorAccessibility lintMessages={this.props.lintMessages} />
</section>
) : (
<EditorContainer expanded={this.props.isExpanded}>
<header>
<IconButton
onClick={this.props.expandSidebar}
icon={FolderIcon}
/>
<span>
{this.props.file.name}
<UnsavedChangesIndicator />
</span>
</header>
<section>
<EditorHolder
ref={(element) => {
this.codemirrorContainer = element;
}}
/>
{this.props.file.url ? (
<AssetPreview
url={this.props.file.url}
name={this.props.file.name}
/>
) : null}
</span>
</span>
<Timer />
</div>
</header>
<article
ref={(element) => {
this.codemirrorContainer = element;
}}
className={editorHolderClass}
/>
{this.props.file.url ? (
<AssetPreview url={this.props.file.url} name={this.props.file.name} />
) : null}
<EditorAccessibility lintMessages={this.props.lintMessages} />
</section>
<EditorAccessibility lintMessages={this.props.lintMessages} />
</section>
</EditorContainer>
)
}
</MediaQuery>
);
}
}
Expand Down Expand Up @@ -592,7 +629,6 @@ Editor.propTypes = {
).isRequired,
isExpanded: PropTypes.bool.isRequired,
collapseSidebar: PropTypes.func.isRequired,
closeProjectOptions: PropTypes.func.isRequired,
expandSidebar: PropTypes.func.isRequired,
clearConsole: PropTypes.func.isRequired,
hideRuntimeErrorWarning: PropTypes.func.isRequired,
Expand All @@ -613,7 +649,6 @@ function mapStateToProps(state) {
editorAccessibility: state.editorAccessibility,
user: state.user,
project: state.project,
toast: state.toast,
consoleEvents: state.console,

...state.preferences,
Expand All @@ -634,7 +669,6 @@ function mapDispatchToProps(dispatch) {
IDEActions,
PreferencesActions,
UserActions,
ToastActions,
ConsoleActions
),
dispatch
Expand Down
Loading