🔀 merging from mobile-sketch-view

This commit is contained in:
ghalestrilo 2020-06-30 16:37:43 -03:00
commit d43fae592d
9 changed files with 81 additions and 57 deletions

View file

@ -10,6 +10,8 @@ import Plus from '../images/plus-icon.svg';
import Close from '../images/close.svg'; import Close from '../images/close.svg';
import Exit from '../images/exit.svg'; import Exit from '../images/exit.svg';
import DropdownArrow from '../images/down-filled-triangle.svg'; import DropdownArrow from '../images/down-filled-triangle.svg';
import Preferences from '../images/preferences.svg';
import Play from '../images/triangle-arrow-right.svg';
// HOC that adds the right web accessibility props // HOC that adds the right web accessibility props
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html // https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
@ -70,3 +72,5 @@ export const PlusIcon = withLabel(Plus);
export const CloseIcon = withLabel(Close); export const CloseIcon = withLabel(Close);
export const ExitIcon = withLabel(Exit); export const ExitIcon = withLabel(Exit);
export const DropdownArrowIcon = withLabel(DropdownArrow); export const DropdownArrowIcon = withLabel(DropdownArrow);
export const PreferencesIcon = withLabel(Preferences);
export const PlayIcon = withLabel(Play);

View file

@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { prop, remSize } from '../../theme'; import { prop, remSize } from '../../theme';
const background = prop('Button.default.background'); const background = prop('Panel.default.background');
const textColor = prop('primaryTextColor'); const textColor = prop('primaryTextColor');
const Footer = styled.div` const Footer = styled.div`

View file

@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { prop, remSize } from '../../theme'; import { prop, remSize } from '../../theme';
const background = prop('Button.default.background'); const background = prop('Panel.default.background');
const textColor = prop('primaryTextColor'); const textColor = prop('primaryTextColor');
const Header = styled.div` const Header = styled.div`
@ -11,8 +11,8 @@ const Header = styled.div`
background: ${background}; background: ${background};
color: ${textColor}; color: ${textColor};
padding: ${remSize(12)}; padding: ${remSize(12)};
padding-left: ${remSize(32)}; padding-left: ${remSize(16)};
padding-right: ${remSize(32)}; padding-right: ${remSize(16)};
z-index: 1; z-index: 1;
display: flex; display: flex;
@ -20,6 +20,11 @@ const Header = styled.div`
flex-direction: row; flex-direction: row;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
// TODO:
svg {
height: 2rem;
}
`; `;
export default Header; export default Header;

View file

@ -1,17 +1,24 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components'; import styled from 'styled-components';
import { prop, remSize } from '../../theme'; import Button from '../../common/Button';
const textColor = prop('primaryTextColor'); const ButtonWrapper = styled(Button)`
const IconButton = styled.button`
width: 3rem; width: 3rem;
> svg { > svg {
width: 100%; width: 100%;
height: auto; height: 100%;
fill: ${textColor};
stroke: ${textColor};
} }
`; `;
const IconButton = props => (<ButtonWrapper
iconBefore={props.children}
kind={Button.kinds.inline}
{...{ ...props, children: null }}
/>);
IconButton.propTypes = {
children: PropTypes.element.isRequired
};
export default IconButton; export default IconButton;

View file

@ -23,7 +23,6 @@ import { hijackConsoleErrorsScript, startTag, getAllScriptOffsets }
from '../../../utils/consoleUtils'; from '../../../utils/consoleUtils';
// Kept inside class just for linter's
const shouldRenderSketch = (props, prevProps = undefined) => { const shouldRenderSketch = (props, prevProps = undefined) => {
const { isPlaying, previewIsRefreshing, fullView } = props; const { isPlaying, previewIsRefreshing, fullView } = props;
@ -337,7 +336,6 @@ class PreviewFrame extends React.Component {
if (this.props.endSketchRefresh) { if (this.props.endSketchRefresh) {
this.props.endSketchRefresh(); this.props.endSketchRefresh();
} }
// debugger; // eslint-disable-line
} else { } else {
doc.srcdoc = ''; doc.srcdoc = '';
srcDoc.set(doc, ' '); srcDoc.set(doc, ' ');

View file

@ -22,8 +22,7 @@ import { getHTMLFile } from '../reducers/files';
import Editor from '../components/Editor'; import Editor from '../components/Editor';
import { ExitIcon } from '../../../common/icons'; import { ExitIcon } from '../../../common/icons';
import PreferencesIcon from '../../../images/preferences.svg'; import { PreferencesIcon, PlayIcon } from '../../../common/icons';
import PlayIcon from '../../../images/triangle-arrow-right.svg';
import IconButton from '../../../components/mobile/IconButton'; import IconButton from '../../../components/mobile/IconButton';
import Header from '../../../components/mobile/Header'; import Header from '../../../components/mobile/Header';
@ -31,47 +30,48 @@ import Screen from '../../../components/mobile/MobileScreen';
import Footer from '../../../components/mobile/Footer'; import Footer from '../../../components/mobile/Footer';
import IDEWrapper from '../../../components/mobile/IDEWrapper'; import IDEWrapper from '../../../components/mobile/IDEWrapper';
const IconLinkWrapper = styled(Link)` const IconContainer = styled.div`
width: 3rem; marginLeft: 2rem;
margin-right: 1.25rem; display: flex;
margin-left: none; `;
const TitleContainer = styled.div`
`; `;
const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id); const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id);
const MobileIDEView = (props) => { const MobileIDEView = (props) => {
const { const {
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage, selectedFile, updateFileContent, files, closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges, startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console, showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
selectedFile, updateFileContent, files,
closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges,
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
} = props; } = props;
const [tmController, setTmController] = useState(null); const [tmController, setTmController] = useState(null); // eslint-disable-line
const [overlay, setOverlay] = useState(null); // eslint-disable-line
const [overlay, setOverlay] = useState(null);
return ( return (
<Screen fullscreen> <Screen fullscreen>
<Header> <Header>
<IconLinkWrapper to="/" aria-label="Return to original editor"> <IconButton to="/mobile" aria-label="Return to original editor">
<ExitIcon /> <ExitIcon viewBox="0 0 16 16" />
</IconLinkWrapper> </IconButton>
<div> <div style={{ marginLeft: '1rem' }}>
<h2>{project.name}</h2> <h2>{project.name}</h2>
<h3>{selectedFile.name}</h3> <h3>{selectedFile.name}</h3>
</div> </div>
<div style={{ marginLeft: '2rem' }}> <IconContainer>
<Link to="/mobile/preferences"> <IconButton to="/mobile/preferences" onClick={() => setOverlay('preferences')}>
<IconButton onClick={() => setOverlay('preferences')}>
<PreferencesIcon focusable="false" aria-hidden="true" /> <PreferencesIcon focusable="false" aria-hidden="true" />
</IconButton> </IconButton>
</Link> <IconButton to="/mobile/preview" onClick={() => { startSketch(); }}>
<Link to="/mobile/preview" onClick={() => startSketch()}>
<IconButton>
<PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" /> <PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" />
</IconButton> </IconButton>
</Link> </IconContainer>
</div>
</Header> </Header>
<IDEWrapper> <IDEWrapper>

View file

@ -1,11 +1,11 @@
/* eslint-disable */ import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Link } from 'react-router'; import { Link } from 'react-router';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import styled from 'styled-components'; import styled from 'styled-components';
import Header from '../../components/mobile/Header'; import Header from '../../components/mobile/Header';
import IconButton from '../../components/mobile/IconButton';
import PreviewFrame from '../IDE/components/PreviewFrame'; import PreviewFrame from '../IDE/components/PreviewFrame';
import Screen from '../../components/mobile/MobileScreen'; import Screen from '../../components/mobile/MobileScreen';
import * as ProjectActions from '../IDE/actions/project'; import * as ProjectActions from '../IDE/actions/project';
@ -26,12 +26,6 @@ const Content = styled.div`
margin-top: ${remSize(68)}; margin-top: ${remSize(68)};
`; `;
const IconLinkWrapper = styled(Link)`
width: 2rem;
margin-right: 1.25rem;
margin-left: none;
`;
const MobileSketchView = (props) => { const MobileSketchView = (props) => {
// TODO: useSelector requires react-redux ^7.1.0 // TODO: useSelector requires react-redux ^7.1.0
// const htmlFile = useSelector(state => getHTMLFile(state.files)); // const htmlFile = useSelector(state => getHTMLFile(state.files));
@ -53,18 +47,13 @@ const MobileSketchView = (props) => {
const { preferences, ide } = props; const { preferences, ide } = props;
useEffect(() => {
// console.log(params);
// getProject(params.project_id, params.username);
});
return ( return (
<Screen fullscreen> <Screen fullscreen>
<Header> <Header>
<IconLinkWrapper to="/mobile" aria-label="Return to original editor"> <IconButton to="/mobile" aria-label="Return to original editor">
<ExitIcon viewBox="0 0 16 16" /> <ExitIcon viewBox="0 0 16 16" />
</IconLinkWrapper> </IconButton>
<div> <div style={{ marginLeft: '1rem' }}>
<h2>{projectName}</h2> <h2>{projectName}</h2>
<h3><br /></h3> <h3><br /></h3>
</div> </div>

View file

@ -23,7 +23,7 @@ const checkAuth = (store) => {
store.dispatch(getUser()); store.dispatch(getUser());
}; };
// This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called // TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
const onRouteChange = (store) => { const onRouteChange = (store) => {
const path = window.location.pathname; const path = window.location.pathname;
if (path.includes('/mobile')) return; if (path.includes('/mobile')) return;

View file

@ -88,6 +88,13 @@ export default {
Icon: { Icon: {
default: grays.middleGray, default: grays.middleGray,
hover: grays.darker hover: grays.darker
},
Panel: {
default: {
foreground: colors.black,
background: grays.light,
border: grays.middleLight,
},
} }
}, },
[Theme.dark]: { [Theme.dark]: {
@ -120,6 +127,13 @@ export default {
Icon: { Icon: {
default: grays.middleLight, default: grays.middleLight,
hover: grays.lightest hover: grays.lightest
},
Panel: {
default: {
foreground: grays.light,
background: grays.dark,
border: grays.middleDark,
},
} }
}, },
[Theme.contrast]: { [Theme.contrast]: {
@ -152,6 +166,13 @@ export default {
Icon: { Icon: {
default: grays.mediumLight, default: grays.mediumLight,
hover: colors.yellow hover: colors.yellow
},
Panel: {
default: {
foreground: grays.light,
background: grays.dark,
border: grays.middleDark,
},
} }
}, },
}; };