Skip to content

Commit 8a0b09d

Browse files
committed
👌 use common/Button component for IconButton on screens
1 parent 7d24c07 commit 8a0b09d

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

client/components/mobile/Header.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ const Header = styled.div`
1111
background: ${background};
1212
color: ${textColor};
1313
padding: ${remSize(12)};
14-
padding-left: ${remSize(32)};
15-
padding-right: ${remSize(32)};
14+
padding-left: ${remSize(16)};
15+
padding-right: ${remSize(16)};
1616
z-index: 1;
1717
1818
display: flex;
1919
flex: 1;
2020
flex-direction: row;
2121
justify-content: flex-start;
2222
align-items: center;
23+
24+
// TODO:
25+
svg {
26+
height: 2rem;
27+
}
2328
`;
2429

2530
export default Header;

client/components/mobile/IconButton.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ const ButtonWrapper = styled(Button)`
77
width: 3rem;
88
> svg {
99
width: 100%;
10-
height: auto;
10+
height: 100%;
1111
}
1212
`;
1313

14-
const IconButton = ({ children }) => (<ButtonWrapper
15-
aria-label="Add to collection"
16-
iconBefore={children}
14+
const IconButton = props => (<ButtonWrapper
15+
iconBefore={props.children}
1716
kind={Button.kinds.inline}
17+
{...{ ...props, children: null }}
1818
/>);
1919

2020
IconButton.propTypes = {

client/modules/IDE/pages/IDEViewMobile.jsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ import Screen from '../../../components/mobile/MobileScreen';
3030
import Footer from '../../../components/mobile/Footer';
3131
import IDEWrapper from '../../../components/mobile/IDEWrapper';
3232

33-
const IconLinkWrapper = styled(Link)`
34-
width: 3rem;
35-
margin-right: 1.25rem;
36-
margin-left: none;
33+
const IconContainer = styled.div`
34+
marginLeft: 2rem;
35+
display: flex;
36+
`;
37+
38+
const TitleContainer = styled.div`
39+
3740
`;
3841

3942
const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id);
@@ -53,30 +56,22 @@ const IDEViewMobile = (props) => {
5356
return (
5457
<Screen>
5558
<Header>
56-
<IconLinkWrapper to="/" aria-label="Return to original editor">
57-
<ExitIcon />
58-
</IconLinkWrapper>
59-
<div>
59+
<IconButton to="/mobile" aria-label="Return to original editor">
60+
<ExitIcon viewBox="0 0 16 16" />
61+
</IconButton>
62+
<div style={{ marginLeft: '1rem' }}>
6063
<h2>{project.name}</h2>
6164
<h3>{selectedFile.name}</h3>
6265
</div>
6366

64-
<div style={{ marginLeft: '2rem', display: 'flex' }}>
67+
<IconContainer>
6568
<IconButton onClick={() => setOverlay('preferences')}>
6669
<PreferencesIcon focusable="false" aria-hidden="true" />
6770
</IconButton>
68-
<Link
69-
to="/mobile/preview"
70-
onClick={() => {
71-
// alert('starting sketch');
72-
startSketch();
73-
}}
74-
>
75-
<IconButton>
76-
<PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" />
77-
</IconButton>
78-
</Link>
79-
</div>
71+
<IconButton to="/mobile/preview" onClick={() => { startSketch(); }}>
72+
<PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" />
73+
</IconButton>
74+
</IconContainer>
8075
</Header>
8176

8277
<IDEWrapper>

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { bindActionCreators } from 'redux';
55
import { connect } from 'react-redux';
66
import styled from 'styled-components';
77
import Header from '../../components/mobile/Header';
8+
import IconButton from '../../components/mobile/IconButton';
89
import PreviewFrame from '../IDE/components/PreviewFrame';
910
import Screen from '../../components/mobile/MobileScreen';
1011
import * as ProjectActions from '../IDE/actions/project';
@@ -25,12 +26,6 @@ const Content = styled.div`
2526
margin-top: ${remSize(68)};
2627
`;
2728

28-
const IconLinkWrapper = styled(Link)`
29-
width: 2rem;
30-
margin-right: 1.25rem;
31-
margin-left: none;
32-
`;
33-
3429
const MobileSketchView = (props) => {
3530
// TODO: useSelector requires react-redux ^7.1.0
3631
// const htmlFile = useSelector(state => getHTMLFile(state.files));
@@ -55,9 +50,9 @@ const MobileSketchView = (props) => {
5550
return (
5651
<Screen>
5752
<Header>
58-
<IconLinkWrapper to="/mobile" aria-label="Return to original editor">
53+
<IconButton to="/mobile" aria-label="Return to original editor">
5954
<ExitIcon viewBox="0 0 16 16" />
60-
</IconLinkWrapper>
55+
</IconButton>
6156
<div>
6257
<h2>{projectName}</h2>
6358
<h3><br /></h3>

0 commit comments

Comments
 (0)