mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
de245c288a
Adding documentation button on the editor GitOrigin-RevId: e03fd7b931eb0fe7273e6e9d0185c81c384df916
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import { useState } from 'react'
|
|
import Icon from '../../../shared/components/icon'
|
|
import { useSplitTestContext } from '../../../shared/context/split-test-context'
|
|
import { sendMB } from '../../../infrastructure/event-tracking'
|
|
import PropTypes from 'prop-types'
|
|
import { Button } from 'react-bootstrap'
|
|
|
|
function DocumentationButton() {
|
|
const { splitTestVariants } = useSplitTestContext({
|
|
splitTestVariants: PropTypes.object,
|
|
})
|
|
const documentationButtonVariant =
|
|
splitTestVariants['documentation-on-editor']
|
|
|
|
let documentationButtonText = ''
|
|
|
|
if (documentationButtonVariant === 'latex-help')
|
|
documentationButtonText = 'LaTeX help'
|
|
else if (documentationButtonVariant === 'documentation')
|
|
documentationButtonText = 'Documentation'
|
|
else if (documentationButtonVariant === 'help-guides')
|
|
documentationButtonText = 'Help guides'
|
|
const [showDocumentationButton, setShowDocumentationButton] = useState(
|
|
!(documentationButtonVariant === 'default')
|
|
)
|
|
|
|
function handleCloseClick() {
|
|
sendMB('file-tree-documentation-dismiss ')
|
|
|
|
setShowDocumentationButton(false)
|
|
}
|
|
|
|
function handleDocumentationLinkClick() {
|
|
sendMB('file-tree-documentation-click')
|
|
}
|
|
return (
|
|
<div className="outline-pane">
|
|
{showDocumentationButton ? (
|
|
<header className="outline-footer">
|
|
<div className="outline-header-expand-collapse-btn documentation-btn">
|
|
<a
|
|
href="/learn"
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="documentation-link"
|
|
onClick={handleDocumentationLinkClick}
|
|
>
|
|
<Icon
|
|
type="question-circle"
|
|
className="outline-caret-icon"
|
|
style={{ color: 'white' }}
|
|
/>
|
|
<h4 className="outline-header-name">{documentationButtonText}</h4>
|
|
</a>
|
|
<Button bsStyle="link">
|
|
<Icon
|
|
style={{ color: 'white' }}
|
|
type="times"
|
|
onClick={handleCloseClick}
|
|
className="outline-caret-icon"
|
|
/>
|
|
</Button>
|
|
</div>
|
|
</header>
|
|
) : null}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default DocumentationButton
|