mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 09:33:58 -05:00
cc2d1a26e2
Styling and HTML structure of the documentation button GitOrigin-RevId: e643edbe05579c037ca1ec27fab765974e74d2c5
62 lines
1.9 KiB
TypeScript
62 lines
1.9 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')
|
|
}
|
|
|
|
if (!showDocumentationButton) return null
|
|
|
|
return (
|
|
<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>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default DocumentationButton
|