mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-24 11:24:08 +03:00
fix: tooltip arrow (#3769)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
parent
651e815b42
commit
866408015e
@ -60,7 +60,11 @@ export const HelpIsland = ({
|
|||||||
style={{ height: spread ? `${showList.length * 40 + 4}px` : 0 }}
|
style={{ height: spread ? `${showList.length * 40 + 4}px` : 0 }}
|
||||||
>
|
>
|
||||||
{showList.includes('whatNew') && (
|
{showList.includes('whatNew') && (
|
||||||
<Tooltip content={t["Discover what's new!"]()} placement="left-end">
|
<Tooltip
|
||||||
|
content={t["Discover what's new!"]()}
|
||||||
|
placement="left-end"
|
||||||
|
showArrow={true}
|
||||||
|
>
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
data-testid="right-bottom-change-log-icon"
|
data-testid="right-bottom-change-log-icon"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -72,7 +76,11 @@ export const HelpIsland = ({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{showList.includes('contact') && (
|
{showList.includes('contact') && (
|
||||||
<Tooltip content={t['Contact Us']()} placement="left-end">
|
<Tooltip
|
||||||
|
content={t['Contact Us']()}
|
||||||
|
placement="left-end"
|
||||||
|
showArrow={true}
|
||||||
|
>
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
data-testid="right-bottom-contact-us-icon"
|
data-testid="right-bottom-contact-us-icon"
|
||||||
onClick={openAbout}
|
onClick={openAbout}
|
||||||
@ -82,7 +90,11 @@ export const HelpIsland = ({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{showList.includes('shortcuts') && (
|
{showList.includes('shortcuts') && (
|
||||||
<Tooltip content={t['Keyboard Shortcuts']()} placement="left-end">
|
<Tooltip
|
||||||
|
content={t['Keyboard Shortcuts']()}
|
||||||
|
placement="left-end"
|
||||||
|
showArrow={true}
|
||||||
|
>
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
data-testid="shortcuts-icon"
|
data-testid="shortcuts-icon"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -98,6 +110,7 @@ export const HelpIsland = ({
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
content={t['com.affine.helpIsland.gettingStarted']()}
|
content={t['com.affine.helpIsland.gettingStarted']()}
|
||||||
placement="left-end"
|
placement="left-end"
|
||||||
|
showArrow={true}
|
||||||
>
|
>
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
data-testid="easy-guide"
|
data-testid="easy-guide"
|
||||||
@ -112,7 +125,11 @@ export const HelpIsland = ({
|
|||||||
)}
|
)}
|
||||||
</StyledAnimateWrapper>
|
</StyledAnimateWrapper>
|
||||||
|
|
||||||
<Tooltip content={t['Help and Feedback']()} placement="left-end">
|
<Tooltip
|
||||||
|
content={t['Help and Feedback']()}
|
||||||
|
placement={'left-end'}
|
||||||
|
showArrow={true}
|
||||||
|
>
|
||||||
<MuiFade in={!spread} data-testid="faq-icon">
|
<MuiFade in={!spread} data-testid="faq-icon">
|
||||||
<StyledTriggerWrapper>
|
<StyledTriggerWrapper>
|
||||||
<HelpIcon />
|
<HelpIcon />
|
||||||
|
@ -103,6 +103,9 @@ export const toolStyle = style({
|
|||||||
right: '30px',
|
right: '30px',
|
||||||
bottom: '30px',
|
bottom: '30px',
|
||||||
zIndex: 'var(--affine-z-index-popover)',
|
zIndex: 'var(--affine-z-index-popover)',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '12px',
|
||||||
'@media': {
|
'@media': {
|
||||||
[breakpoints.down('md', true)]: {
|
[breakpoints.down('md', true)]: {
|
||||||
right: 'calc((100vw - 640px) * 3 / 19 + 14px)',
|
right: 'calc((100vw - 640px) * 3 / 19 + 14px)',
|
||||||
|
@ -13,7 +13,6 @@ import {
|
|||||||
|
|
||||||
import { styled } from '../../styles';
|
import { styled } from '../../styles';
|
||||||
import type { PopperProps, VirtualElement } from './interface';
|
import type { PopperProps, VirtualElement } from './interface';
|
||||||
import { PopperArrow } from './popover-arrow';
|
|
||||||
export const Popper = ({
|
export const Popper = ({
|
||||||
children,
|
children,
|
||||||
content,
|
content,
|
||||||
@ -41,7 +40,8 @@ export const Popper = ({
|
|||||||
}: PopperProps) => {
|
}: PopperProps) => {
|
||||||
const [anchorEl, setAnchorEl] = useState<VirtualElement>();
|
const [anchorEl, setAnchorEl] = useState<VirtualElement>();
|
||||||
const [visible, setVisible] = useState(defaultVisible);
|
const [visible, setVisible] = useState(defaultVisible);
|
||||||
const [arrowRef, setArrowRef] = useState<HTMLElement>();
|
//const [arrowRef, setArrowRef] = useState<HTMLElement>();
|
||||||
|
const arrowRef = null;
|
||||||
const pointerLeaveTimer = useRef<number>();
|
const pointerLeaveTimer = useRef<number>();
|
||||||
const pointerEnterTimer = useRef<number>();
|
const pointerEnterTimer = useRef<number>();
|
||||||
|
|
||||||
@ -170,12 +170,111 @@ export const Popper = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{showArrow && (
|
{showArrow ? (
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
<>
|
||||||
// @ts-ignore
|
{placement.indexOf('bottom') === 0 ? (
|
||||||
<PopperArrow placement={placement} ref={setArrowRef} />
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="11"
|
||||||
|
height="6"
|
||||||
|
viewBox="0 0 11 6"
|
||||||
|
fill="none"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M6.38889 0.45C5.94444 -0.15 5.05555 -0.150001 4.61111 0.449999L0.499999 6L10.5 6L6.38889 0.45Z"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
) : placement.indexOf('top') === 0 ? (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="11"
|
||||||
|
height="6"
|
||||||
|
viewBox="0 0 11 6"
|
||||||
|
fill="none"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
) : placement.indexOf('left') === 0 ? (
|
||||||
|
<>
|
||||||
|
{content}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="6"
|
||||||
|
height="10"
|
||||||
|
viewBox="0 0 6 10"
|
||||||
|
fill="none"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M5.55 5.88889C6.15 5.44444 6.15 4.55555 5.55 4.11111L-4.76837e-07 0L-4.76837e-07 10L5.55 5.88889Z"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</>
|
||||||
|
) : placement.indexOf('right') === 0 ? (
|
||||||
|
<>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="6"
|
||||||
|
height="10"
|
||||||
|
viewBox="0 0 6 10"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M0.45 4.11111C-0.15 4.55556 -0.15 5.44445 0.45 5.88889L6 10V0L0.45 4.11111Z"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
{content}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="11"
|
||||||
|
height="6"
|
||||||
|
viewBox="0 0 11 6"
|
||||||
|
fill="none"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
|
||||||
|
style={{ fill: 'var(--affine-tooltip)' }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>{content}</>
|
||||||
)}
|
)}
|
||||||
{content}
|
|
||||||
</div>
|
</div>
|
||||||
</Grow>
|
</Grow>
|
||||||
)}
|
)}
|
||||||
|
@ -7,15 +7,16 @@ import StyledPopperContainer from '../shared/container';
|
|||||||
|
|
||||||
const StyledTooltip = styled(StyledPopperContainer)(() => {
|
const StyledTooltip = styled(StyledPopperContainer)(() => {
|
||||||
return {
|
return {
|
||||||
maxWidth: '320px',
|
display: 'inline-flex',
|
||||||
boxShadow: 'var(--affine-float-button-shadow)',
|
height: '38px',
|
||||||
padding: '4px 12px',
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexShrink: 0,
|
||||||
backgroundColor: 'var(--affine-tooltip)',
|
backgroundColor: 'var(--affine-tooltip)',
|
||||||
|
borderRadius: '4px',
|
||||||
color: 'var(--affine-white)',
|
color: 'var(--affine-white)',
|
||||||
fontSize: 'var(--affine-font-sm)',
|
padding: '5px 12px',
|
||||||
borderRadius: '8px',
|
|
||||||
marginBottom: '12px',
|
|
||||||
overflowWrap: 'break-word',
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ const ImagePreviewModalImpl = (
|
|||||||
) : null}
|
) : null}
|
||||||
<div className={imagePreviewActionBarStyle}>
|
<div className={imagePreviewActionBarStyle}>
|
||||||
<div>
|
<div>
|
||||||
<Tooltip content={'Previous'} disablePortal={false}>
|
<Tooltip content={'Previous'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="previous-image-button"
|
data-testid="previous-image-button"
|
||||||
icon={<ArrowLeftSmallIcon />}
|
icon={<ArrowLeftSmallIcon />}
|
||||||
@ -348,7 +348,7 @@ const ImagePreviewModalImpl = (
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Next'} disablePortal={false}>
|
<Tooltip content={'Next'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="next-image-button"
|
data-testid="next-image-button"
|
||||||
icon={<ArrowRightSmallIcon />}
|
icon={<ArrowRightSmallIcon />}
|
||||||
@ -362,11 +362,7 @@ const ImagePreviewModalImpl = (
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div className={groupStyle}></div>
|
<div className={groupStyle}></div>
|
||||||
<Tooltip
|
<Tooltip content={'Fit to Screen'} placement={'top'} showArrow={true}>
|
||||||
content={'Fit to Screen'}
|
|
||||||
disablePortal={true}
|
|
||||||
showArrow={false}
|
|
||||||
>
|
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="fit-to-screen-button"
|
data-testid="fit-to-screen-button"
|
||||||
icon={<ViewBarIcon />}
|
icon={<ViewBarIcon />}
|
||||||
@ -375,7 +371,7 @@ const ImagePreviewModalImpl = (
|
|||||||
onClick={() => resetZoom()}
|
onClick={() => resetZoom()}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Zoom out'} disablePortal={false}>
|
<Tooltip content={'Zoom out'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="zoom-out-button"
|
data-testid="zoom-out-button"
|
||||||
icon={<MinusIcon />}
|
icon={<MinusIcon />}
|
||||||
@ -384,7 +380,7 @@ const ImagePreviewModalImpl = (
|
|||||||
onClick={zoomOut}
|
onClick={zoomOut}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Reset Scale'} disablePortal={false}>
|
<Tooltip content={'Reset Scale'} placement={'top'} showArrow={true}>
|
||||||
<Button
|
<Button
|
||||||
data-testid="reset-scale-button"
|
data-testid="reset-scale-button"
|
||||||
type="plain"
|
type="plain"
|
||||||
@ -395,7 +391,7 @@ const ImagePreviewModalImpl = (
|
|||||||
{`${(currentScale * 100).toFixed(0)}%`}
|
{`${(currentScale * 100).toFixed(0)}%`}
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Zoom in'} disablePortal={false}>
|
<Tooltip content={'Zoom in'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="zoom-in-button"
|
data-testid="zoom-in-button"
|
||||||
icon={<PlusIcon />}
|
icon={<PlusIcon />}
|
||||||
@ -405,7 +401,7 @@ const ImagePreviewModalImpl = (
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div className={groupStyle}></div>
|
<div className={groupStyle}></div>
|
||||||
<Tooltip content={'Download'} disablePortal={false}>
|
<Tooltip content={'Download'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="download-button"
|
data-testid="download-button"
|
||||||
icon={<DownloadIcon />}
|
icon={<DownloadIcon />}
|
||||||
@ -419,7 +415,11 @@ const ImagePreviewModalImpl = (
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content={'Copy to clipboard'} disablePortal={false}>
|
<Tooltip
|
||||||
|
content={'Copy to clipboard'}
|
||||||
|
placement={'top'}
|
||||||
|
showArrow={true}
|
||||||
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="copy-to-clipboard-button"
|
data-testid="copy-to-clipboard-button"
|
||||||
icon={<CopyIcon />}
|
icon={<CopyIcon />}
|
||||||
@ -444,7 +444,7 @@ const ImagePreviewModalImpl = (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dataUrl = URL.createObjectURL(blob);
|
const dataUrl = URL.createObjectURL(blob);
|
||||||
navigator.clipboard
|
global.navigator.clipboard
|
||||||
.write([new ClipboardItem({ 'image/png': blob })])
|
.write([new ClipboardItem({ 'image/png': blob })])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('Image copied to clipboard');
|
console.log('Image copied to clipboard');
|
||||||
@ -460,7 +460,7 @@ const ImagePreviewModalImpl = (
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div className={groupStyle}></div>
|
<div className={groupStyle}></div>
|
||||||
<Tooltip content={'Delete'} disablePortal={false}>
|
<Tooltip content={'Delete'} placement={'top'} showArrow={true}>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-testid="delete-button"
|
data-testid="delete-button"
|
||||||
icon={<DeleteIcon />}
|
icon={<DeleteIcon />}
|
||||||
|
@ -3,7 +3,7 @@ import { toast as basicToast } from '@affine/component';
|
|||||||
|
|
||||||
export const toast = (message: string, options?: ToastOptions) => {
|
export const toast = (message: string, options?: ToastOptions) => {
|
||||||
const mainContainer = document.querySelector(
|
const mainContainer = document.querySelector(
|
||||||
'[data-testid="image-preview-modal"]'
|
'[plugin-id="@affine/image-preview-plugin"]'
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
return basicToast(message, {
|
return basicToast(message, {
|
||||||
portal: mainContainer || document.body,
|
portal: mainContainer || document.body,
|
||||||
|
Loading…
Reference in New Issue
Block a user