Skip to content

Commit b88a403

Browse files
committed
Merge branch 'feature/mobile-examples' of https://github.com/ghalestrilo/p5.js-web-editor into feature/mobile-files-tab
2 parents df5ac3f + a9061af commit b88a403

File tree

18 files changed

+228
-78
lines changed

18 files changed

+228
-78
lines changed

client/components/mobile/Tab.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import { Link } from 'react-router';
4+
import { prop, remSize } from '../../theme';
5+
6+
export default styled(Link)`
7+
box-sizing: border-box;
8+
9+
10+
background: transparent;
11+
/* border-top: ${remSize(4)} solid ${props => prop(props.selected ? 'colors.p5jsPink' : 'MobilePanel.default.background')}; */
12+
border-top: ${remSize(4)} solid ${props => (props.selected ? prop('TabHighlight') : 'transparent')};
13+
14+
color: ${prop('primaryTextColor')};
15+
16+
padding: ${remSize(8)} ${remSize(16)};
17+
width: 30%;
18+
`;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
import { prop, remSize } from '../../theme';
5+
6+
export default styled.div`
7+
display: flex;
8+
justify-content: space-between;
9+
10+
h3 { text-align: center; width: 100%; }
11+
border-top: 1px solid ${prop('Separator')};
12+
13+
background: ${props => prop('backgroundColor')};
14+
`;
15+

client/modules/IDE/components/CollectionList/CollectionListRow.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ class CollectionListRowBase extends React.Component {
214214
</span>
215215
</th>
216216
{(!mobile) && <td>{format(new Date(collection.createdAt), 'MMM D, YYYY')}</td>}
217-
<td>{formatDateCell(collection.updatedAt)}</td>
218-
<td>{(collection.items || []).length}</td>
217+
<td>{mobile && 'Updated: '}{formatDateCell(collection.updatedAt)}</td>
218+
<td>{mobile && '# sketches: '}{(collection.items || []).length}</td>
219219
<td className="sketch-list__dropdown-column">
220220
{this.renderActions()}
221221
</td>

client/modules/IDE/components/NewFileForm.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3+
import { withTranslation } from 'react-i18next';
34
import { domOnlyProps } from '../../../utils/reduxFormUtils';
45

56
import Button from '../../../common/Button';
@@ -35,14 +36,17 @@ class NewFileForm extends React.Component {
3536
className="new-file-form__name-input"
3637
id="name"
3738
type="text"
38-
placeholder="Name"
39+
placeholder={this.props.t('NewFileForm.Placeholder')}
3940
maxLength="128"
4041
{...domOnlyProps(name)}
4142
ref={(element) => {
4243
this.fileName = element;
4344
}}
4445
/>
45-
<Button type="submit">Add File</Button>
46+
<Button
47+
type="submit"
48+
>{this.props.t('NewFileForm.AddFileSubmit')}
49+
</Button>
4650
</div>
4751
{name.touched && name.error && (
4852
<span className="form-error">{name.error}</span>
@@ -59,6 +63,7 @@ NewFileForm.propTypes = {
5963
handleSubmit: PropTypes.func.isRequired,
6064
createFile: PropTypes.func.isRequired,
6165
focusOnModal: PropTypes.func.isRequired,
66+
t: PropTypes.func.isRequired
6267
};
6368

64-
export default NewFileForm;
69+
export default withTranslation()(NewFileForm);

client/modules/IDE/components/NewFileModal.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React from 'react';
33
import { connect } from 'react-redux';
44
import { bindActionCreators, compose } from 'redux';
55
import { reduxForm } from 'redux-form';
6+
import { withTranslation } from 'react-i18next';
7+
import i18n from 'i18next';
68
import NewFileForm from './NewFileForm';
79
import { closeNewFileModal } from '../actions/ide';
810
import { createFile } from '../actions/files';
@@ -33,11 +35,11 @@ class NewFileModal extends React.Component {
3335
<section className="modal" ref={(element) => { this.modal = element; }}>
3436
<div className="modal-content">
3537
<div className="modal__header">
36-
<h2 className="modal__title">Create File</h2>
38+
<h2 className="modal__title">{this.props.t('NewFileModal.Title')}</h2>
3739
<button
3840
className="modal__exit-button"
3941
onClick={this.props.closeNewFileModal}
40-
aria-label="Close New File Modal"
42+
aria-label={this.props.t('NewFileModal.CloseButtonARIA')}
4143
>
4244
<ExitIcon focusable="false" aria-hidden="true" />
4345
</button>
@@ -54,16 +56,17 @@ class NewFileModal extends React.Component {
5456

5557
NewFileModal.propTypes = {
5658
createFile: PropTypes.func.isRequired,
57-
closeNewFileModal: PropTypes.func.isRequired
59+
closeNewFileModal: PropTypes.func.isRequired,
60+
t: PropTypes.func.isRequired
5861
};
5962

6063
function validate(formProps) {
6164
const errors = {};
6265

6366
if (!formProps.name) {
64-
errors.name = 'Please enter a name';
67+
errors.name = i18n.t('NewFileModal.EnterName');
6568
} else if (!formProps.name.match(CREATE_FILE_REGEX)) {
66-
errors.name = 'Invalid file type. Valid extensions are .js, .css, .json, .txt, .csv, .tsv, .frag, and .vert.';
69+
errors.name = i18n.t('NewFileModal.InvalidType');
6770
}
6871

6972
return errors;
@@ -77,11 +80,11 @@ function mapDispatchToProps(dispatch) {
7780
return bindActionCreators({ createFile, closeNewFileModal }, dispatch);
7881
}
7982

80-
export default compose(
83+
export default withTranslation()(compose(
8184
connect(mapStateToProps, mapDispatchToProps),
8285
reduxForm({
8386
form: 'new-file',
8487
fields: ['name'],
8588
validate
8689
})
87-
)(NewFileModal);
90+
)(NewFileModal));

client/modules/IDE/components/NewFolderForm.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3+
import { withTranslation } from 'react-i18next';
34
import { domOnlyProps } from '../../../utils/reduxFormUtils';
45

56
import Button from '../../../common/Button';
67

8+
79
class NewFolderForm extends React.Component {
810
constructor(props) {
911
super(props);
@@ -35,13 +37,14 @@ class NewFolderForm extends React.Component {
3537
id="name"
3638
type="text"
3739
maxLength="128"
38-
placeholder="Name"
39-
ref={(element) => {
40-
this.fileName = element;
41-
}}
40+
placeholder={this.props.t('NewFolderForm.Placeholder')}
41+
ref={(element) => { this.fileName = element; }}
4242
{...domOnlyProps(name)}
4343
/>
44-
<Button type="submit">Add Folder</Button>
44+
<Button
45+
type="submit"
46+
>{this.props.t('NewFolderForm.AddFolderSubmit')}
47+
</Button>
4548
</div>
4649
{name.touched && name.error && (
4750
<span className="form-error">{name.error}</span>
@@ -60,9 +63,10 @@ NewFolderForm.propTypes = {
6063
closeModal: PropTypes.func.isRequired,
6164
submitting: PropTypes.bool,
6265
pristine: PropTypes.bool,
66+
t: PropTypes.func.isRequired
6367
};
6468
NewFolderForm.defaultProps = {
6569
submitting: false,
6670
pristine: true,
6771
};
68-
export default NewFolderForm;
72+
export default withTranslation()(NewFolderForm);

client/modules/IDE/components/NewFolderModal.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import { reduxForm } from 'redux-form';
4+
import { withTranslation } from 'react-i18next';
5+
import i18n from 'i18next';
46
import NewFolderForm from './NewFolderForm';
57

68
import ExitIcon from '../../../images/exit.svg';
@@ -15,11 +17,11 @@ class NewFolderModal extends React.Component {
1517
<section className="modal" ref={(element) => { this.newFolderModal = element; }} >
1618
<div className="modal-content-folder">
1719
<div className="modal__header">
18-
<h2 className="modal__title">Create Folder</h2>
20+
<h2 className="modal__title">{this.props.t('NewFolderModal.Title')}</h2>
1921
<button
2022
className="modal__exit-button"
2123
onClick={this.props.closeModal}
22-
aria-label="Close New Folder Modal"
24+
aria-label={this.props.t('NewFolderModal.CloseButtonARIA')}
2325
>
2426
<ExitIcon focusable="false" aria-hidden="true" />
2527
</button>
@@ -32,23 +34,24 @@ class NewFolderModal extends React.Component {
3234
}
3335

3436
NewFolderModal.propTypes = {
35-
closeModal: PropTypes.func.isRequired
37+
closeModal: PropTypes.func.isRequired,
38+
t: PropTypes.func.isRequired
3639
};
3740

3841
function validate(formProps) {
3942
const errors = {};
4043
if (!formProps.name) {
41-
errors.name = 'Please enter a name';
44+
errors.name = i18n.t('NewFolderModal.EnterName');
4245
} else if (formProps.name.trim().length === 0) {
43-
errors.name = 'Folder name cannot contain only spaces';
46+
errors.name = i18n.t('NewFolderModal.EmptyName');
4447
} else if (formProps.name.match(/\.+/i)) {
45-
errors.name = 'Folder name cannot contain an extension';
48+
errors.name = i18n.t('NewFolderModal.InvalidExtension');
4649
}
4750

4851
return errors;
4952
}
50-
export default reduxForm({
53+
export default withTranslation()(reduxForm({
5154
form: 'new-folder',
5255
fields: ['name'],
5356
validate
54-
})(NewFolderModal);
57+
})(NewFolderModal));

client/modules/IDE/components/SketchList.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ class SketchListRowBase extends React.Component {
293293
<th scope="row">
294294
{name}
295295
</th>
296-
<td>{formatDateCell(sketch.createdAt, mobile)}</td>
297-
<td>{formatDateCell(sketch.updatedAt, mobile)}</td>
296+
<td>{mobile && 'Created: '}{formatDateCell(sketch.createdAt, mobile)}</td>
297+
<td>{mobile && 'Updated: '}{formatDateCell(sketch.updatedAt, mobile)}</td>
298298
{this.renderDropdown()}
299299
</tr>
300300
</React.Fragment>);

0 commit comments

Comments
 (0)