overleaf/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.js
Alf Eaton f065a7a909 Improve the Icon component (#6245)
GitOrigin-RevId: fbb23b32c47edbe5a22badc627318accbd09e82a
2022-01-20 09:03:58 +00:00

34 lines
923 B
JavaScript

import classnames from 'classnames'
import { Button } from 'react-bootstrap'
import PropTypes from 'prop-types'
import Icon from '../../../../shared/components/icon'
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
export default function FileTreeModalCreateFileMode({ mode, icon, label }) {
const { newFileCreateMode, startCreatingFile } = useFileTreeActionable()
const handleClick = () => {
startCreatingFile(mode)
}
return (
<li className={classnames({ active: newFileCreateMode === mode })}>
<Button
bsStyle="link"
block
onClick={handleClick}
className="modal-new-file-mode"
>
<Icon type={icon} fw />
&nbsp;
{label}
</Button>
</li>
)
}
FileTreeModalCreateFileMode.propTypes = {
mode: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
}