2023-02-14 05:20:52 -05:00
|
|
|
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() {
|
2023-08-10 08:47:11 -04:00
|
|
|
sendMB('file-tree-documentation-click')
|
2023-02-14 05:20:52 -05:00
|
|
|
|
|
|
|
setShowDocumentationButton(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleDocumentationLinkClick() {
|
|
|
|
sendMB('file-tree-documentation-click')
|
|
|
|
}
|
2023-02-24 06:15:41 -05:00
|
|
|
|
|
|
|
if (!showDocumentationButton) return null
|
|
|
|
|
2023-02-14 05:20:52 -05:00
|
|
|
return (
|
2023-02-24 06:15:41 -05:00
|
|
|
<div className="documentation-btn-container">
|
|
|
|
<a
|
|
|
|
href="/learn"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
className="documentation-link"
|
|
|
|
onClick={handleDocumentationLinkClick}
|
|
|
|
>
|
|
|
|
<Icon type="question-circle" className="outline-caret-icon" />
|
|
|
|
<h4 className="outline-header-name">{documentationButtonText}</h4>
|
|
|
|
</a>
|
|
|
|
<Button bsStyle="link" className="documentation-close">
|
|
|
|
<Icon
|
|
|
|
type="times"
|
|
|
|
onClick={handleCloseClick}
|
|
|
|
className="outline-caret-icon "
|
|
|
|
/>
|
|
|
|
</Button>
|
2023-02-14 05:20:52 -05:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DocumentationButton
|