Skip to content

Commit 81ad78b

Browse files
committed
✨ add floating button to open files tab
1 parent 34be0e7 commit 81ad78b

File tree

7 files changed

+77
-12
lines changed

7 files changed

+77
-12
lines changed

client/common/icons.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import More from '../images/more.svg';
1616
import Code from '../images/code.svg';
1717
import Terminal from '../images/terminal.svg';
1818

19+
import CircleTerminal from '../images/circle-terminal.svg';
20+
import CircleFolder from '../images/circle-folder.svg';
21+
import CircleInfo from '../images/circle-info.svg';
22+
1923

2024
// HOC that adds the right web accessibility props
2125
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
@@ -81,3 +85,7 @@ export const PlayIcon = withLabel(Play);
8185
export const MoreIcon = withLabel(More);
8286
export const TerminalIcon = withLabel(Terminal);
8387
export const CodeIcon = withLabel(Code);
88+
89+
export const CircleTerminalIcon = withLabel(CircleTerminal);
90+
export const CircleFolderIcon = withLabel(CircleFolder);
91+
export const CircleInfoIcon = withLabel(CircleInfo);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
import { remSize } from '../../theme';
5+
import Button from '../../common/Button';
6+
import IconButton from './IconButton';
7+
8+
const FloatingContainer = styled.div`
9+
position: absolute;
10+
right: ${remSize(16)};
11+
top: ${remSize(80)};
12+
13+
text-align: right;
14+
z-index: 3;
15+
`;
16+
17+
const FloatingNav = ({ items }) => (
18+
<FloatingContainer>
19+
{ items.map(({ icon, onPress }) =>
20+
(
21+
<IconButton
22+
onClick={onPress}
23+
icon={icon}
24+
/>
25+
))}
26+
</FloatingContainer>
27+
);
28+
29+
FloatingNav.propTypes = {
30+
items: PropTypes.arrayOf(PropTypes.shape({
31+
icon: PropTypes.element,
32+
onPress: PropTypes.func
33+
}))
34+
};
35+
36+
FloatingNav.defaultProps = {
37+
items: []
38+
};
39+
40+
export default FloatingNav;

client/images/circle-folder.svg

Lines changed: 5 additions & 0 deletions
Loading

client/images/circle-info.svg

Lines changed: 4 additions & 0 deletions
Loading

client/images/circle-terminal.svg

Lines changed: 6 additions & 0 deletions
Loading

client/modules/App/App.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class App extends React.Component {
3434
render() {
3535
return (
3636
<div className="app">
37-
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
37+
<div style={{ display: 'none' }}>
38+
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
39+
</div>
3840
{this.props.children}
3941
</div>
4042
);

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getHTMLFile } from '../reducers/files';
2020

2121
// Local Imports
2222
import Editor from '../components/Editor';
23-
import { PlayIcon, MoreIcon } from '../../../common/icons';
23+
import { PlayIcon, MoreIcon, CircleFolderIcon } from '../../../common/icons';
2424

2525
import IconButton from '../../../components/mobile/IconButton';
2626
import Header from '../../../components/mobile/Header';
@@ -30,12 +30,12 @@ import IDEWrapper from '../../../components/mobile/IDEWrapper';
3030
import MobileExplorer from '../../../components/mobile/Explorer';
3131
import Console from '../components/Console';
3232
import { remSize } from '../../../theme';
33-
// import OverlayManager from '../../../components/OverlayManager';
33+
3434
import ActionStrip from '../../../components/mobile/ActionStrip';
3535
import useAsModal from '../../../components/useAsModal';
3636
import { PreferencesIcon } from '../../../common/icons';
3737
import Dropdown from '../../../components/Dropdown';
38-
import Sidebar from '../../../components/mobile/Sidebar';
38+
import FloatingNav from '../../../components/mobile/FloatingNav';
3939

4040

4141
const getRootFile = files => files && files.filter(file => file.name === 'root')[0];
@@ -65,7 +65,7 @@ const NavItem = styled.li`
6565
position: relative;
6666
`;
6767

68-
const getNatOptions = (username = undefined) =>
68+
const getNavOptions = (username = undefined) =>
6969
(username
7070
? [
7171
{ icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences', },
@@ -112,14 +112,18 @@ const MobileIDEView = (props) => {
112112

113113
// Screen Modals
114114
const [toggleNavDropdown, NavDropDown] = useAsModal(<Dropdown
115-
items={getNatOptions(username)}
115+
items={getNavOptions(username)}
116116
align="right"
117117
/>);
118118

119+
119120
const [toggleExplorer, Explorer] = useAsModal(<MobileExplorer id={getRootFileID(files)} canEdit={false} />, true);
120121

121122
// toggle sidebar starting opened
122-
useEffect(toggleExplorer, []);
123+
// useEffect(toggleExplorer, []);
124+
125+
const floatingNavOptions =
126+
[{ icon: CircleFolderIcon, onPress: toggleExplorer }];
123127

124128
return (
125129
<Screen fullscreen>
@@ -129,11 +133,6 @@ const MobileIDEView = (props) => {
129133
subtitle={selectedFile.name}
130134
>
131135
<NavItem>
132-
<IconButton
133-
onClick={toggleExplorer}
134-
icon={MoreIcon}
135-
aria-label="Options"
136-
/>
137136
<IconButton
138137
onClick={toggleNavDropdown}
139138
icon={MoreIcon}
@@ -180,6 +179,7 @@ const MobileIDEView = (props) => {
180179
provideController={setTmController}
181180
setUnsavedChanges={setUnsavedChanges}
182181
/>
182+
<FloatingNav items={floatingNavOptions} />
183183
</IDEWrapper>
184184

185185
<Footer>

0 commit comments

Comments
 (0)