Skip to content

Mobile Preferences Screen Prototype #1472

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c8b3da9
:recycle: rename IDEViewMobile to MobileIDEView
ghalestrilo Jun 22, 2020
b27ee57
:construction: connect MobileSettings
ghalestrilo Jun 23, 2020
167bbe8
:sparkles: Navigation to Settings Screen
ghalestrilo Jun 23, 2020
ad3db32
:bug: fix settings text color
ghalestrilo Jun 23, 2020
181e832
:lipstick: fix options styling
ghalestrilo Jun 23, 2020
a9c17b5
:sparkles: create settings section header component
ghalestrilo Jun 23, 2020
1f69786
:sparkles: add accessible output settings
ghalestrilo Jun 23, 2020
3ba1b26
:sparkles: add accessibility settings
ghalestrilo Jun 23, 2020
d43fae5
:twisted_rightwards_arrows: merging from mobile-sketch-view
ghalestrilo Jun 30, 2020
b96b9d3
:ok_hand: use remSize on IconButton
ghalestrilo Jun 30, 2020
30c47d6
:ok_hand: rename <Selector /> to <PreferencePicker />
ghalestrilo Jun 30, 2020
1c1ea98
:ok_hand: unimplement canvas stretching behavior
ghalestrilo Jun 30, 2020
24a72da
:lipstick: improve <Header /> component structure and layout
ghalestrilo Jun 30, 2020
e8b2515
:lipstick: change screen header title to Preferences
ghalestrilo Jun 30, 2020
c88bf44
:twisted_rightwards_arrows: merging from mobile-sketch-view
ghalestrilo Jul 1, 2020
3ce0a51
:ok_hand: increase option label size
ghalestrilo Jul 1, 2020
82ec520
:ok_hand: fixed warnings
ghalestrilo Jul 1, 2020
58d8fc1
:ok_hand: fixed warnings on MobileSketchView and MobilePreferences
ghalestrilo Jul 1, 2020
7d6ba6f
Merge branch 'develop' into feature/mobile-settings-screen
catarak Jul 1, 2020
88ebe9e
Re-add Redux DevTools to App.jsx
catarak Jul 1, 2020
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
56 changes: 53 additions & 3 deletions client/components/mobile/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { prop, remSize } from '../../theme';

const background = prop('MobilePanel.default.background');
const textColor = prop('primaryTextColor');

const Header = styled.div`

const HeaderDiv = styled.div`
position: fixed;
width: 100%;
background: ${background};
background: ${props => (props.transparent ? 'transparent' : background)};
color: ${textColor};
padding: ${remSize(12)};
padding-left: ${remSize(16)};
Expand All @@ -23,8 +25,56 @@ const Header = styled.div`

// TODO:
svg {
height: 2rem;
max-height: ${remSize(32)};
padding: ${remSize(4)}
}
`;

const IconContainer = styled.div`
margin-left: ${props => (props.leftButton ? remSize(32) : remSize(4))};
display: flex;
`;


const TitleContainer = styled.div`
margin-left: ${remSize(4)};
margin-right: auto;

${props => props.padded && `h2{
padding-top: ${remSize(10)};
padding-bottom: ${remSize(10)};
}`}
`;

const Header = ({
title, subtitle, leftButton, children, transparent
}) => (
<HeaderDiv transparent={transparent}>
{leftButton}
<TitleContainer padded={subtitle === null}>
{title && <h2>{title}</h2>}
{subtitle && <h3>{subtitle}</h3>}
</TitleContainer>
<IconContainer>
{children}
</IconContainer>
</HeaderDiv>
);

Header.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string,
leftButton: PropTypes.element,
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
transparent: PropTypes.bool
};

Header.defaultProps = {
title: null,
subtitle: null,
leftButton: null,
children: [],
transparent: false
};

export default Header;
3 changes: 2 additions & 1 deletion client/components/mobile/IconButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Button from '../../common/Button';
import { remSize } from '../../theme';

const ButtonWrapper = styled(Button)`
width: 3rem;
width: ${remSize(48)};
> svg {
width: 100%;
height: 100%;
Expand Down
12 changes: 9 additions & 3 deletions client/components/mobile/MobileScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';

const Screen = ({ children }) => (
<div className="fullscreen-preview">
const Screen = ({ children, fullscreen }) => (
<div className={fullscreen && 'fullscreen-preview'}>
{children}
</div>
);

Screen.defaultProps = {
fullscreen: false
};

Screen.propTypes = {
children: PropTypes.node.isRequired
children: PropTypes.node.isRequired,
fullscreen: PropTypes.bool
};

export default Screen;
67 changes: 67 additions & 0 deletions client/components/mobile/PreferencePicker.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { prop, remSize } from '../../theme';


const PreferenceTitle = styled.h4.attrs(props => ({ ...props, className: 'preference__title' }))`
color: ${prop('primaryTextColor')};
`;

const Preference = styled.div.attrs(props => ({ ...props, className: 'preference' }))`
flex-wrap: nowrap !important;
align-items: baseline !important;
justify-items: space-between;
`;

const OptionLabel = styled.label.attrs({ className: 'preference__option' })`
font-size: ${remSize(14)} !important;
`;

const PreferencePicker = ({
title, value, onSelect, options,
}) => (
<Preference>
<PreferenceTitle>{title}</PreferenceTitle>
<div className="preference__options">
{options.map(option => (
<React.Fragment key={`${option.name}-${option.id}`} >
<input
type="radio"
onChange={() => onSelect(option.value)}
aria-label={option.ariaLabel}
name={option.name}
key={`${option.name}-${option.id}-input`}
id={option.id}
className="preference__radio-button"
value={option.value}
checked={value === option.value}
/>
<OptionLabel
key={`${option.name}-${option.id}-label`}
htmlFor={option.id}
>
{option.label}
</OptionLabel>
</React.Fragment>))}
</div>
</Preference>
);

PreferencePicker.defaultProps = {
options: []
};

PreferencePicker.propTypes = {
title: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]).isRequired,
options: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
name: PropTypes.string,
label: PropTypes.string,
ariaLabel: PropTypes.string,
})),
onSelect: PropTypes.func.isRequired,
};

export default PreferencePicker;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { useState } from 'react';
Expand All @@ -27,16 +25,10 @@ import Header from '../../../components/mobile/Header';
import Screen from '../../../components/mobile/MobileScreen';
import Footer from '../../../components/mobile/Footer';
import IDEWrapper from '../../../components/mobile/IDEWrapper';
import { remSize } from '../../../theme';

const IconContainer = styled.div`
margin-left: ${remSize(32)};
display: flex;
`;

const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id);

const IDEViewMobile = (props) => {
const MobileIDEView = (props) => {
const {
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
selectedFile, updateFileContent, files,
Expand All @@ -49,22 +41,21 @@ const IDEViewMobile = (props) => {
const [overlay, setOverlay] = useState(null); // eslint-disable-line

return (
<Screen>
<Header>
<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to original editor" />
<div style={{ marginLeft: '1rem' }}>
<h2>{project.name}</h2>
<h3>{selectedFile.name}</h3>
</div>

<IconContainer>
<IconButton
onClick={() => setOverlay('preferences')}
icon={PreferencesIcon}
aria-label="Open preferences menu"
/>
<IconButton to="/mobile/preview" onClick={() => { startSketch(); }} icon={PlayIcon} aria-label="Run sketch" />
</IconContainer>
<Screen fullscreen>
<Header
title={project.name}
subtitle={selectedFile.name}
leftButton={
<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to original editor" />
}
>
<IconButton
to="/mobile/preferences"
onClick={() => setOverlay('preferences')}
icon={PreferencesIcon}
aria-label="Open preferences menu"
/>
<IconButton to="/mobile/preview" onClick={() => { startSketch(); }} icon={PlayIcon} aria-label="Run sketch" />
</Header>

<IDEWrapper>
Expand Down Expand Up @@ -109,7 +100,7 @@ const IDEViewMobile = (props) => {
};


IDEViewMobile.propTypes = {
MobileIDEView.propTypes = {

preferences: PropTypes.shape({
fontSize: PropTypes.number.isRequired,
Expand Down Expand Up @@ -256,4 +247,4 @@ function mapDispatchToProps(dispatch) {
}


export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEViewMobile));
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MobileIDEView));
Loading