Skip to content

Commit 54ae17f

Browse files
committed
🔀 pull from feature/mobile-files-tab
2 parents c0b9ae4 + ac737a7 commit 54ae17f

File tree

17 files changed

+238
-34
lines changed

17 files changed

+238
-34
lines changed

client/common/icons.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import Code from '../images/code.svg';
1717
import Save from '../images/save.svg';
1818
import Terminal from '../images/terminal.svg';
1919

20+
import Folder from '../images/folder-padded.svg';
21+
22+
import CircleTerminal from '../images/circle-terminal.svg';
23+
import CircleFolder from '../images/circle-folder.svg';
24+
import CircleInfo from '../images/circle-info.svg';
25+
2026

2127
// HOC that adds the right web accessibility props
2228
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
@@ -83,3 +89,9 @@ export const MoreIcon = withLabel(More);
8389
export const TerminalIcon = withLabel(Terminal);
8490
export const CodeIcon = withLabel(Code);
8591
export const SaveIcon = withLabel(Save);
92+
93+
export const FolderIcon = withLabel(Folder);
94+
95+
export const CircleTerminalIcon = withLabel(CircleTerminal);
96+
export const CircleFolderIcon = withLabel(CircleFolder);
97+
export const CircleInfoIcon = withLabel(CircleInfo);

client/components/Dropdown.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const DropdownWrapper = styled.ul`
2525
display: flex;
2626
flex-direction: column;
2727
height: auto;
28-
z-index: 9999;
28+
z-index: 2;
2929
border-radius: ${remSize(6)};
3030
3131
& li:first-child { border-radius: ${remSize(5)} ${remSize(5)} 0 0; }

client/components/mobile/ActionStrip.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
4-
import { remSize } from '../../theme';
4+
import { remSize, prop } from '../../theme';
55
import IconButton from './IconButton';
66

77
const BottomBarContent = styled.div`
8+
padding: ${remSize(8)};
89
display: grid;
910
grid-template-columns: repeat(8,1fr);
10-
padding: ${remSize(8)};
11-
11+
1212
svg {
1313
max-height: ${remSize(32)};
1414
}
15+
16+
path { fill: ${prop('primaryTextColor')} !important }
17+
18+
.inverted {
19+
path { fill: ${prop('backgroundColor')} !important }
20+
rect { fill: ${prop('primaryTextColor')} !important }
21+
}
1522
`;
1623

1724
const ActionStrip = ({ actions }) => (
1825
<BottomBarContent>
19-
{actions.map(({ icon, aria, action }) =>
26+
{actions.map(({
27+
icon, aria, action, inverted
28+
}) =>
2029
(<IconButton
30+
inverted={inverted}
31+
className={inverted && 'inverted'}
2132
icon={icon}
2233
aria-label={aria}
2334
key={`bottom-bar-${aria}`}
@@ -29,7 +40,8 @@ ActionStrip.propTypes = {
2940
actions: PropTypes.arrayOf(PropTypes.shape({
3041
icon: PropTypes.element.isRequired,
3142
aria: PropTypes.string.isRequired,
32-
action: PropTypes.func.isRequired
43+
action: PropTypes.func.isRequired,
44+
inverted: PropTypes.bool
3345
})).isRequired
3446
};
3547

client/components/mobile/Explorer.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import PropTypes from 'prop-types';
4+
import Sidebar from './Sidebar';
5+
import ConnectedFileNode from '../../modules/IDE/components/FileNode';
6+
7+
8+
const Explorer = ({ id, canEdit, onPressClose }) => (
9+
<Sidebar title="Files" onPressClose={onPressClose}>
10+
<ConnectedFileNode id={id} canEdit={canEdit} onClickFile={() => onPressClose()} />
11+
</Sidebar>
12+
);
13+
14+
Explorer.propTypes = {
15+
id: PropTypes.number.isRequired,
16+
onPressClose: PropTypes.func,
17+
canEdit: PropTypes.bool
18+
};
19+
Explorer.defaultProps = {
20+
canEdit: false,
21+
onPressClose: () => {}
22+
};
23+
24+
export default Explorer;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
import { remSize, prop } from '../../theme';
5+
import Button from '../../common/Button';
6+
import IconButton from './IconButton';
7+
8+
const FloatingContainer = styled.div`
9+
position: fixed;
10+
right: ${remSize(16)};
11+
top: ${remSize(80)};
12+
13+
text-align: right;
14+
z-index: 3;
15+
16+
svg { width: ${remSize(32)}; };
17+
svg > path { fill: ${prop('Button.default.background')} !important };
18+
`;
19+
20+
const FloatingNav = ({ items }) => (
21+
<FloatingContainer>
22+
{ items.map(({ icon, onPress }) =>
23+
(
24+
<IconButton
25+
onClick={onPress}
26+
icon={icon}
27+
/>
28+
))}
29+
</FloatingContainer>
30+
);
31+
32+
FloatingNav.propTypes = {
33+
items: PropTypes.arrayOf(PropTypes.shape({
34+
icon: PropTypes.element,
35+
onPress: PropTypes.func
36+
}))
37+
};
38+
39+
FloatingNav.defaultProps = {
40+
items: []
41+
};
42+
43+
export default FloatingNav;

client/components/mobile/Header.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const textColor = ({ transparent, inverted }) => prop((transparent === false &&
1414

1515

1616
const HeaderDiv = styled.div`
17-
position: fixed;
17+
${props => props.fixed && 'position: fixed;'}
1818
width: 100%;
1919
background: ${props => background(props)};
2020
color: ${textColor};
@@ -63,9 +63,9 @@ const TitleContainer = styled.div`
6363

6464
const Header = ({
6565
title, subtitle, leftButton, children,
66-
transparent, inverted, slim
66+
transparent, inverted, slim, fixed
6767
}) => (
68-
<HeaderDiv transparent={transparent} slim={slim} inverted={inverted}>
68+
<HeaderDiv transparent={transparent} slim={slim} inverted={inverted} fixed={fixed}>
6969
{leftButton}
7070
<TitleContainer padded={subtitle === null}>
7171
{title && <h2>{title}</h2>}
@@ -86,6 +86,7 @@ Header.propTypes = {
8686
transparent: PropTypes.bool,
8787
inverted: PropTypes.bool,
8888
slim: PropTypes.bool,
89+
fixed: PropTypes.bool,
8990
};
9091

9192
Header.defaultProps = {
@@ -95,7 +96,8 @@ Header.defaultProps = {
9596
children: [],
9697
transparent: false,
9798
inverted: false,
98-
slim: false
99+
slim: false,
100+
fixed: true
99101
};
100102

101103
export default Header;

client/components/mobile/IDEWrapper.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import React from 'react';
22
import styled from 'styled-components';
33
import { remSize } from '../../theme';
44

5+
// Applies padding to top and bottom so editor content is always visible
6+
57
export default styled.div`
68
z-index: 0;
79
margin-top: ${remSize(16)};
10+
.CodeMirror-sizer > * { padding-bottom: ${remSize(320)}; };
811
`;

client/components/mobile/Sidebar.jsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Link } from 'react-router';
4+
import styled from 'styled-components';
5+
import { remSize, prop, common } from '../../theme';
6+
import Header from './Header';
7+
import IconButton from './IconButton';
8+
import { ExitIcon } from '../../common/icons';
9+
10+
11+
const SidebarWrapper = styled.div`
12+
height: 100%;
13+
width: ${remSize(180)};
14+
15+
position: fixed;
16+
z-index: 2;
17+
left: 0;
18+
19+
background: white;
20+
box-shadow: 0 6px 6px 0 rgba(0,0,0,0.10);
21+
`;
22+
23+
const Sidebar = ({ title, onPressClose, children }) => (
24+
<SidebarWrapper>
25+
{title &&
26+
<Header slim title={title} fixed={false}>
27+
<IconButton onClick={onPressClose} icon={ExitIcon} aria-label="Return to ide view" />
28+
</Header>}
29+
{children}
30+
</SidebarWrapper>
31+
);
32+
33+
Sidebar.propTypes = {
34+
title: PropTypes.string,
35+
onPressClose: PropTypes.func,
36+
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
37+
};
38+
39+
Sidebar.defaultProps = {
40+
title: null,
41+
children: [],
42+
onPressClose: () => {}
43+
};
44+
45+
46+
export default Sidebar;

client/components/useAsModal.jsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
import React from 'react';
2+
import styled from 'styled-components';
23
import { useModalBehavior } from '../utils/custom-hooks';
34

4-
export default (component) => {
5-
const [visible, trigger, setRef] = useModalBehavior();
5+
const BackgroundOverlay = styled.div`
6+
position: fixed;
7+
z-index: 2;
8+
width: 100% !important;
9+
height: 100% !important;
10+
11+
background: black;
12+
opacity: 0.3;
13+
`;
614

7-
const wrapper = () => <div ref={setRef}> {visible && component} </div>; // eslint-disable-line
15+
export default (Element, hasOverlay = false) => {
16+
const [visible, toggle, setRef] = useModalBehavior();
817

9-
return [trigger, wrapper];
18+
const wrapper = () => (visible &&
19+
<div>
20+
{hasOverlay && <BackgroundOverlay />}
21+
<div ref={setRef}>
22+
{ (typeof (Element) === 'function')
23+
? Element(toggle)
24+
: Element}
25+
</div>
26+
</div>);
27+
28+
return [toggle, wrapper];
1029
};

client/images/circle-folder.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)