mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 14:19:39 -05:00
f065a7a909
GitOrigin-RevId: fbb23b32c47edbe5a22badc627318accbd09e82a
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
|
|
import { useSelectableEntity } from '../contexts/file-tree-selectable'
|
|
|
|
import FileTreeItemInner from './file-tree-item/file-tree-item-inner'
|
|
import { useTranslation } from 'react-i18next'
|
|
import Icon from '../../../shared/components/icon'
|
|
import iconTypeFromName from '../util/icon-type-from-name'
|
|
import classnames from 'classnames'
|
|
|
|
function FileTreeDoc({ name, id, isLinkedFile }) {
|
|
const { isSelected, props: selectableEntityProps } = useSelectableEntity(id)
|
|
|
|
return (
|
|
<li
|
|
role="treeitem"
|
|
{...selectableEntityProps}
|
|
aria-label={name}
|
|
tabIndex="0"
|
|
>
|
|
<FileTreeItemInner
|
|
id={id}
|
|
name={name}
|
|
isSelected={isSelected}
|
|
icons={<FileTreeIcon isLinkedFile={isLinkedFile} name={name} />}
|
|
/>
|
|
</li>
|
|
)
|
|
}
|
|
|
|
FileTreeDoc.propTypes = {
|
|
name: PropTypes.string.isRequired,
|
|
id: PropTypes.string.isRequired,
|
|
isLinkedFile: PropTypes.bool,
|
|
}
|
|
|
|
export const FileTreeIcon = ({ isLinkedFile, name }) => {
|
|
const { t } = useTranslation()
|
|
|
|
const className = classnames('spaced', { 'linked-file-icon': isLinkedFile })
|
|
|
|
return (
|
|
<>
|
|
|
|
<Icon type={iconTypeFromName(name)} fw className={className} />
|
|
{isLinkedFile && (
|
|
<Icon
|
|
type="external-link-square"
|
|
modifier="rotate-180"
|
|
className="linked-file-highlight"
|
|
accessibilityLabel={t('linked_file')}
|
|
/>
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
FileTreeIcon.propTypes = {
|
|
name: PropTypes.string.isRequired,
|
|
isLinkedFile: PropTypes.bool,
|
|
}
|
|
|
|
export default FileTreeDoc
|