2020-07-21 17:14:58 +02:00
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components';
|
2020-08-11 23:03:09 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2020-07-21 17:14:58 +02:00
|
|
|
import { bindActionCreators } from 'redux';
|
2020-07-21 23:09:48 +02:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2020-08-11 23:03:09 +02:00
|
|
|
import { remSize, prop } from '../../theme';
|
2020-07-21 17:14:58 +02:00
|
|
|
import IconButton from './IconButton';
|
2020-08-11 23:03:09 +02:00
|
|
|
import { TerminalIcon, FolderIcon } from '../../common/icons';
|
2020-07-21 17:14:58 +02:00
|
|
|
import * as IDEActions from '../../modules/IDE/actions/ide';
|
|
|
|
|
2020-08-11 23:03:09 +02:00
|
|
|
const BottomBarContent = styled.div`
|
2020-07-21 17:21:46 +02:00
|
|
|
padding: ${remSize(8)};
|
2020-08-11 23:03:09 +02:00
|
|
|
display: flex;
|
|
|
|
|
2020-07-21 17:14:58 +02:00
|
|
|
svg {
|
|
|
|
max-height: ${remSize(32)};
|
2020-08-11 23:03:09 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
path { fill: ${prop('primaryTextColor')} !important }
|
|
|
|
|
|
|
|
.inverted {
|
|
|
|
path { fill: ${prop('backgroundColor')} !important }
|
|
|
|
rect { fill: ${prop('primaryTextColor')} !important }
|
2020-07-21 17:14:58 +02:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-11 23:03:09 +02:00
|
|
|
// Maybe this component shouldn't be connected, and instead just receive the `actions` prop
|
|
|
|
const ActionStrip = ({ toggleExplorer }) => {
|
2020-07-21 23:09:48 +02:00
|
|
|
const { expandConsole, collapseConsole } = bindActionCreators(IDEActions, useDispatch());
|
|
|
|
const { consoleIsExpanded } = useSelector(state => state.ide);
|
2020-07-21 17:14:58 +02:00
|
|
|
|
2020-08-11 23:03:09 +02:00
|
|
|
const actions = [
|
|
|
|
{
|
|
|
|
icon: TerminalIcon, inverted: true, aria: 'Open terminal console', action: consoleIsExpanded ? collapseConsole : expandConsole
|
|
|
|
},
|
|
|
|
{ icon: FolderIcon, aria: 'Open files explorer', action: toggleExplorer }
|
|
|
|
];
|
2020-07-21 17:14:58 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<BottomBarContent>
|
2020-08-11 23:03:09 +02:00
|
|
|
{actions.map(({
|
|
|
|
icon, aria, action, inverted
|
|
|
|
}) =>
|
|
|
|
(
|
|
|
|
<IconButton
|
|
|
|
inverted={inverted}
|
|
|
|
className={inverted && 'inverted'}
|
|
|
|
icon={icon}
|
|
|
|
aria-label={aria}
|
|
|
|
key={`bottom-bar-${aria}`}
|
|
|
|
onClick={() => action()}
|
|
|
|
/>))}
|
2020-07-21 17:14:58 +02:00
|
|
|
</BottomBarContent>
|
|
|
|
);
|
|
|
|
};
|
2020-08-11 23:03:09 +02:00
|
|
|
|
|
|
|
ActionStrip.propTypes = {
|
|
|
|
toggleExplorer: PropTypes.func
|
|
|
|
};
|
|
|
|
|
|
|
|
ActionStrip.defaultProps = {
|
|
|
|
toggleExplorer: () => {}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ActionStrip;
|