Skip to content

Commit 100a6a0

Browse files
committed
✨ add save button to bottom bar
1 parent e996d49 commit 100a6a0

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed

client/common/icons.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Preferences from '../images/preferences.svg';
1414
import Play from '../images/triangle-arrow-right.svg';
1515
import More from '../images/more.svg';
1616
import Code from '../images/code.svg';
17+
import Save from '../images/save.svg';
1718
import Terminal from '../images/terminal.svg';
1819

1920

@@ -81,3 +82,4 @@ export const PlayIcon = withLabel(Play);
8182
export const MoreIcon = withLabel(More);
8283
export const TerminalIcon = withLabel(Terminal);
8384
export const CodeIcon = withLabel(Code);
85+
export const SaveIcon = withLabel(Save);
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import styled from 'styled-components';
3-
import { bindActionCreators } from 'redux';
4-
import { useDispatch, useSelector } from 'react-redux';
54
import { remSize } from '../../theme';
65
import IconButton from './IconButton';
7-
import { TerminalIcon } from '../../common/icons';
8-
import * as IDEActions from '../../modules/IDE/actions/ide';
96

10-
const BottomBarContent = styled.h2`
7+
const BottomBarContent = styled.div`
8+
display: grid;
9+
grid-template-columns: repeat(8,1fr);
1110
padding: ${remSize(8)};
1211
1312
svg {
1413
max-height: ${remSize(32)};
1514
}
1615
`;
1716

18-
export default () => {
19-
const { expandConsole, collapseConsole } = bindActionCreators(IDEActions, useDispatch());
20-
const { consoleIsExpanded } = useSelector(state => state.ide);
17+
const ActionStrip = ({ actions }) => (
18+
<BottomBarContent>
19+
{actions.map(({ icon, aria, action }) =>
20+
(<IconButton
21+
icon={icon}
22+
aria-label={aria}
23+
key={`bottom-bar-${aria}`}
24+
onClick={() => action()}
25+
/>))}
26+
</BottomBarContent>);
2127

22-
const actions = [{ icon: TerminalIcon, aria: 'Say Something', action: consoleIsExpanded ? collapseConsole : expandConsole }];
23-
24-
return (
25-
<BottomBarContent>
26-
{actions.map(({ icon, aria, action }) =>
27-
(<IconButton
28-
icon={icon}
29-
aria-label={aria}
30-
key={`bottom-bar-${aria}`}
31-
onClick={() => action()}
32-
/>))}
33-
</BottomBarContent>
34-
);
28+
ActionStrip.propTypes = {
29+
actions: PropTypes.arrayOf(PropTypes.shape({
30+
icon: PropTypes.element.isRequired,
31+
aria: PropTypes.string.isRequired,
32+
action: PropTypes.func.isRequired
33+
})).isRequired
3534
};
35+
36+
export default ActionStrip;

client/images/save.svg

Lines changed: 1 addition & 0 deletions
Loading

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ import { remSize } from '../../../theme';
2929
// import OverlayManager from '../../../components/OverlayManager';
3030
import ActionStrip from '../../../components/mobile/ActionStrip';
3131
import useAsModal from '../../../components/useAsModal';
32-
import { PreferencesIcon } from '../../../common/icons';
32+
import { PreferencesIcon, TerminalIcon, SaveIcon } from '../../../common/icons';
3333
import Dropdown from '../../../components/Dropdown';
3434

35+
3536
import { useEffectWithComparison, useEventListener } from '../../../utils/custom-hooks';
3637

3738
import * as device from '../../../utils/device';
@@ -147,10 +148,6 @@ const autosave = (autosaveInterval, setAutosaveInterval) => (props, prevProps) =
147148

148149
const doAutosave = () => autosaveProject(true);
149150

150-
console.log(user);
151-
152-
console.log(isUserOwner(props), project);
153-
154151
if (isUserOwner(props) && project.id) {
155152
if (preferences.autosave && ide.unsavedChanges && !ide.justOpenedProject) {
156153
if (file.name === oldFile.name && file.content !== oldFile.content) {
@@ -172,8 +169,8 @@ const autosave = (autosaveInterval, setAutosaveInterval) => (props, prevProps) =
172169

173170
const MobileIDEView = (props) => {
174171
const {
175-
ide, preferences, project, selectedFile, user, params, unsavedChanges, collapseConsole,
176-
stopSketch, startSketch, getProject, clearPersistedState, autosaveProject
172+
ide, preferences, project, selectedFile, user, params, unsavedChanges, expandConsole, collapseConsole,
173+
stopSketch, startSketch, getProject, clearPersistedState, autosaveProject, saveProject
177174
} = props;
178175

179176

@@ -216,6 +213,10 @@ const MobileIDEView = (props) => {
216213

217214
useEventListener('keydown', handleGlobalKeydown(props, cmController), false, [props]);
218215

216+
const projectActions =
217+
[{ icon: TerminalIcon, aria: 'Toggle console open/closed', action: consoleIsExpanded ? collapseConsole : expandConsole },
218+
{ icon: SaveIcon, aria: 'Save project', action: () => saveProject(cmController.getContent(), false, true) }
219+
];
219220

220221
return (
221222
<Screen fullscreen>
@@ -246,7 +247,7 @@ const MobileIDEView = (props) => {
246247
<Console />
247248
</Expander>
248249
)}
249-
<ActionStrip />
250+
<ActionStrip actions={projectActions} />
250251
</Footer>
251252
</Screen>
252253
);

0 commit comments

Comments
 (0)