Update add comment tooltip to match new designs (#20913)

* Update add comment tooltip to match new designs

* Rename AddCommentTooltip to ReviewTooltipMenu

* Split off add-comment-button specific padding

GitOrigin-RevId: 12a69b13b52b007eb97ba7ad6f290e3a98d741cd
This commit is contained in:
David 2024-10-10 14:50:27 +02:00 committed by Copybot
parent 9ba6a6a042
commit b1d1432183
4 changed files with 39 additions and 20 deletions

View file

@ -14,7 +14,7 @@ import { getTooltip } from '@codemirror/view'
import useViewerPermissions from '@/shared/hooks/use-viewer-permissions' import useViewerPermissions from '@/shared/hooks/use-viewer-permissions'
import usePreviousValue from '@/shared/hooks/use-previous-value' import usePreviousValue from '@/shared/hooks/use-previous-value'
const AddCommentTooltip: FC = () => { const ReviewTooltipMenu: FC = () => {
const state = useCodeMirrorStateContext() const state = useCodeMirrorStateContext()
const view = useCodeMirrorViewContext() const view = useCodeMirrorViewContext()
const isViewer = useViewerPermissions() const isViewer = useViewerPermissions()
@ -40,12 +40,12 @@ const AddCommentTooltip: FC = () => {
} }
return ReactDOM.createPortal( return ReactDOM.createPortal(
<AddCommentTooltipContent setShow={setShow} />, <ReviewTooltipMenuContent setShow={setShow} />,
tooltipView.dom tooltipView.dom
) )
} }
const AddCommentTooltipContent: FC<{ const ReviewTooltipMenuContent: FC<{
setShow: Dispatch<SetStateAction<boolean>> setShow: Dispatch<SetStateAction<boolean>>
}> = ({ setShow }) => { }> = ({ setShow }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -66,11 +66,16 @@ const AddCommentTooltipContent: FC<{
} }
return ( return (
<button className="review-panel-add-comment-tooltip" onClick={handleClick}> <div className="review-tooltip-menu">
<button
className="review-tooltip-menu-button review-tooltip-add-comment-button"
onClick={handleClick}
>
<MaterialIcon type="chat" /> <MaterialIcon type="chat" />
{t('add_comment')} {t('add_comment')}
</button> </button>
</div>
) )
} }
export default AddCommentTooltip export default ReviewTooltipMenu

View file

@ -12,7 +12,7 @@ import importOverleafModules from '../../../../macros/import-overleaf-module.mac
import { FigureModal } from './figure-modal/figure-modal' import { FigureModal } from './figure-modal/figure-modal'
import { ReviewPanelProviders } from '@/features/review-panel-new/context/review-panel-providers' import { ReviewPanelProviders } from '@/features/review-panel-new/context/review-panel-providers'
import { ReviewPanelMigration } from '@/features/source-editor/components/review-panel/review-panel-migration' import { ReviewPanelMigration } from '@/features/source-editor/components/review-panel/review-panel-migration'
import AddCommentTooltip from '@/features/review-panel-new/components/add-comment-tooltip' import ReviewTooltipMenu from '@/features/review-panel-new/components/review-tooltip-menu'
import { useFeatureFlag } from '@/shared/context/split-test-context' import { useFeatureFlag } from '@/shared/context/split-test-context'
import { import {
CodeMirrorStateContext, CodeMirrorStateContext,
@ -78,7 +78,7 @@ function CodeMirrorEditor() {
)} )}
<CodeMirrorCommandTooltip /> <CodeMirrorCommandTooltip />
{newReviewPanel && <AddCommentTooltip />} {newReviewPanel && <ReviewTooltipMenu />}
<ReviewPanelMigration /> <ReviewPanelMigration />
{sourceEditorComponents.map( {sourceEditorComponents.map(

View file

@ -100,7 +100,7 @@ function buildTooltip(range: SelectionRange): Tooltip | null {
arrow: false, arrow: false,
create() { create() {
const dom = document.createElement('div') const dom = document.createElement('div')
dom.className = 'review-panel-add-comment-tooltip-container' dom.className = 'review-tooltip-menu-container'
return { dom, overlap: true, offset: { x: 0, y: 8 } } return { dom, overlap: true, offset: { x: 0, y: 8 } }
}, },
} }
@ -110,15 +110,16 @@ function buildTooltip(range: SelectionRange): Tooltip | null {
* Styles for the tooltip * Styles for the tooltip
*/ */
const addCommentTheme = EditorView.baseTheme({ const addCommentTheme = EditorView.baseTheme({
'.review-panel-add-comment-tooltip-container.cm-tooltip': { '.review-tooltip-menu-container.cm-tooltip': {
backgroundColor: 'transparent', backgroundColor: 'transparent',
border: 'none', border: 'none',
}, },
'&light': { '&light': {
'& .review-panel-add-comment-tooltip': { '& .review-tooltip-menu': {
backgroundColor: 'white', backgroundColor: 'white',
border: '1px solid #e7e9ee', },
'& .review-tooltip-menu-button': {
'&:hover': { '&:hover': {
backgroundColor: '#e7e9ee', backgroundColor: '#e7e9ee',
}, },
@ -126,9 +127,10 @@ const addCommentTheme = EditorView.baseTheme({
}, },
'&dark': { '&dark': {
'& .review-panel-add-comment-tooltip': { '& .review-tooltip-menu': {
backgroundColor: '#1b222c', backgroundColor: '#1b222c',
border: '1px solid #2f3a4c', },
'& .review-tooltip-menu-button': {
'&:hover': { '&:hover': {
backgroundColor: '#2f3a4c', backgroundColor: '#2f3a4c',
}, },

View file

@ -608,14 +608,26 @@
} }
} }
.review-panel-add-comment-tooltip { .review-tooltip-menu {
height: 24px; box-shadow: 0px 2px 4px 0px #1e253029;
border-radius: 12px; border: none;
padding: 2px 12px; border-radius: 4px;
padding: 4px;
}
.review-tooltip-menu-button {
background-color: inherit;
border: none;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 2px; gap: 2px;
padding: 2px;
} }
.review-tooltip-add-comment-button {
padding: 2px 8px;
}
.review-panel-tooltip { .review-panel-tooltip {
pointer-events: none; // this is to prevent mouseLeave event from firing when hovering over the tooltip pointer-events: none; // this is to prevent mouseLeave event from firing when hovering over the tooltip
} }