From 60597c221a300343a2e4492dc26b45bdfa6da2a2 Mon Sep 17 00:00:00 2001 From: myjeong19 Date: Wed, 30 Oct 2024 22:36:38 +0900 Subject: [PATCH 01/10] fix. image block --- .../src/lib/components/image/image-viewer.tsx | 55 +- .../react-notion-custom/src/lib/index.css | 571 +++++++++--------- 2 files changed, 308 insertions(+), 318 deletions(-) diff --git a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx index a55d54b..4a8f5ff 100644 --- a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx +++ b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx @@ -63,11 +63,14 @@ const ImageViewer: React.FC = ({ useEffect(() => { if (!isOpened) { + document.body.style.overflow = "visible"; return; } imageRef.current?.focus(); + document.body.style.overflow = "hidden"; + const handleKeyDown = (e: KeyboardEvent) => { const keyDownEvents: { [key: string]: () => void } = { Escape: () => setIsOpened(false), @@ -120,7 +123,7 @@ const ImageViewer: React.FC = ({ {isOpened && ( = ({ - {isCursorVisible && ( - - )} + {/* {isCursorVisible && ( */} + + {/* )} */} )} diff --git a/packages/react-notion-custom/src/lib/index.css b/packages/react-notion-custom/src/lib/index.css index 9fcec22..c1aa56f 100644 --- a/packages/react-notion-custom/src/lib/index.css +++ b/packages/react-notion-custom/src/lib/index.css @@ -722,298 +722,6 @@ border-top: 1px solid rgba(223, 223, 222, 1); } -/* image */ -.notion-image img { - width: 100%; - object-fit: contain; - pointer-events: auto; - cursor: default; -} - -.notion-image:not(:last-child) { - margin-bottom: 4px; -} - -.notion-image:not(:first-child) { - margin-top: 4px; -} - -.notion-image-content { - display: flex; - flex-direction: column; -} - -.notion-image img { - width: 100%; - object-fit: contain; - pointer-events: auto; - cursor: default; -} - -.notion-image:not(:last-child) { - margin-bottom: 4px; -} - -.notion-image:not(:first-child) { - margin-top: 4px; -} - -.notion-image-content { - display: flex; - flex-direction: column; -} - -.notion-image-viewer-tools button { - background-color: #160b04; - padding: 6px; - width: 32px; - height: 32px; - border: 0; - margin: 0; - user-select: none; -} - -.notion-image-viewer-tools button.disabled { - opacity: 0.5; - pointer-events: none; - cursor: default; -} - -.notion-image-viewer-tools button:hover { - background-color: rgba(44, 44, 44, 0.81); -} - -.notion-image-viewer-tools button:disabled { - background-color: rgba(0, 0, 0, 0.618); - opacity: 0.5; - pointer-events: none; - cursor: default; -} - -.notion-image-viewer-tools > nav { - display: flex; - margin-right: 12px; -} - -.notion-image-viewer-tools > nav > button:first-child { - width: 36px; - padding-left: 8px; - border-top-left-radius: 6px; - border-bottom-left-radius: 6px; -} - -.notion-image-viewer-tools > nav > button:last-child { - width: 36px; - padding-right: 8px; - border-top-right-radius: 6px; - border-bottom-right-radius: 6px; -} - -.notion-image-viewer-controls { - margin-right: 25px; -} - -.notion-image-viewer-tools > .notion-image-viewer-scaler > button:first-child { - width: 36px; - padding-left: 8px; - border-top-left-radius: 6px; - border-bottom-left-radius: 6px; -} - -.notion-image-viewer-tools .notion-image-viewer-scaler { - display: flex; - font-size: 14px; -} - -.notion-image-viewer-scaler-input { - background-color: rgba(0, 0, 0, 0.4); - display: flex; - align-items: center; - justify-content: center; - color: #888888; - width: 60px; -} - -.notion-image-viewer-scaler-input:hover { - background-color: rgba(0, 0, 0, 0.2); - display: flex; - align-items: center; -} - -.notion-image-viewer-scaler button { - width: 60; - padding: 5; -} - -.notion-image-viewer-scaler input { - background-color: transparent; - border: 0; - font-size: inherit; - color: inherit; - padding: 0px; - padding-top: 1px; - overflow: hidden; - line-height: 1; - text-align: center; -} - -.notion-image-viewer-scaler-input-button { - display: flex; - justify-content: center; - align-items: center; - width: 60px !important; - color: #888888; -} - -.notion-image-viewer-tools .notion-image-viewer-scaler input:focus { - color: white; - outline: 1px solid #008080; - width: 28px; -} - -/* Chrome, Safari, Edge, Opera */ -.notion input::-webkit-outer-spin-button, -input::-webkit-inner-spin-button { - -webkit-appearance: none; - appearance: none; - margin: 0; -} - -/* Firefox */ -.notion input[type="number"] { - -moz-appearance: textfield; - appearance: textfield; -} - -.notion-image-viewer-tools .notion-image-viewer-scaler > button:first-of-type { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.notion-image-viewer-tools .notion-image-viewer-scaler > button:last-of-type { - border-top-left-radius: 0; - border-bottom-left-radius: 0; -} - -.notion-image-viewer-tools button > img { - width: 100%; - height: 100%; -} - -.notion-image-viewer-tools button.notion-image-viewer-tools-download { - border-left: solid 1px gray; - border-right: solid 1px gray; - margin: 0px 1px; -} - -.notion-image-viewer-tools button.notion-image-viewer-tools-close { - width: 36px; - padding-right: 8px; - border-top-right-radius: 6px; - border-bottom-right-radius: 6px; -} - -.notion-image-viewer-tools button:not(:disabled) { - cursor: pointer; -} - -.notion-image-viewer-opener { - cursor: pointer; -} - -.notion-image-viewer-container { - display: flex; - position: fixed; - inset: 0; - overflow: hidden; - z-index: 999; - justify-content: center; - align-items: center; - padding-top: 32px; - padding-bottom: 32px; - flex-direction: column; -} - -@media screen and (min-width: 768px) { - .notion-image-viewer-container { - padding-left: 32px; - padding-right: 32px; - } -} - -.notion-image-viewer-overlay { - position: absolute; - inset: 0; - overflow: hidden; - background-color: black; - opacity: 0.8; - cursor: default; -} - -.notion-image-viewer-container-image { - max-width: fit-content; - max-height: 100%; - object-fit: contain; - position: relative; - z-index: 0; - transform-origin: 0.4s ease-in-out; -} - -.notion-image-viewer-tools { - display: flex; - position: absolute; - bottom: 32px; - left: 50%; - transform: translateX(-50%); - transition: 2s all ease-in-out; -} - -.notion-image-viewer-tooltip-container { - position: relative; - display: inline-block; -} - -.notion-image-viewer-tooltip { - display: flex; - align-items: center; - position: absolute; - top: -35px; - left: -35%; - transform: translateX(-50%); - background-color: rgb(38, 38, 38); - color: white; - padding: 8px; - border-radius: 4px; - font-size: 15px; - white-space: nowrap; - pointer-events: none; - z-index: 10; -} - -.notion-image-viewer-tooltip p:last-child { - margin-left: 5px; - color: #d3d3d3; - font-size: 13px; -} - -.notion .notion-image button { - background: none; - border: none; - padding: 0; - margin: 0; - width: auto; - height: auto; - overflow: visible; - text-align: left; - color: inherit; - font: inherit; - line-height: normal; - -webkit-font-smoothing: inherit; - -moz-osx-font-smoothing: inherit; - -webkit-appearance: none; - appearance: none; -} - .notion-video { margin: 4px 0px; } @@ -1317,3 +1025,282 @@ input::-webkit-inner-spin-button { line-height: 20px; caret-color: rgb(55, 53, 47); } + +/* image */ +.notion-image img { + width: 100%; + object-fit: contain; + pointer-events: auto; + cursor: default; +} + +.notion-image:not(:last-child) { + margin-bottom: 4px; +} + +.notion-image:not(:first-child) { + margin-top: 4px; +} + +.notion-image-content { + display: flex; + flex-direction: column; +} + +.notion-image img { + width: 100%; + object-fit: contain; + pointer-events: auto; + cursor: default; +} + +.notion-image:not(:last-child) { + margin-bottom: 4px; +} + +.notion-image:not(:first-child) { + margin-top: 4px; +} + +.notion-image-content { + display: flex; + flex-direction: column; +} + +.notion-image-viewer-tools button { + background-color: #060606c4; + padding: 6px; + width: 32px; + height: 32px; + border: 0; + margin: 0; + user-select: none; + cursor: pointer; +} + +.notion-image-viewer-tools button > img { + cursor: pointer; +} + +.notion-image-viewer-tools button:disabled { + pointer-events: none; + cursor: default; + background-color: #060606a1; +} + +.notion-image-viewer-tools button:hover { + background-color: #060606a1; +} + +.notion-image-viewer-tools > .notion-image-viewer-controls { + display: flex; + margin-right: 25px; +} + +.notion-image-viewer-tools + > .notion-image-viewer-controls + > .notion-image-viewer-tooltip-container:first-child + button, +.notion-image-viewer-tools > .notion-image-viewer-scaler button:first-child { + width: 36px; + padding-left: 8px; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.notion-image-viewer-tools + > .notion-image-viewer-controls + > .notion-image-viewer-tooltip-container:last-child + button, +.notion-image-viewer-tools > nav > button:last-child { + width: 36px; + padding-right: 8px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.notion-image-viewer-tools .notion-image-viewer-scaler { + display: flex; + font-size: 14px; +} + +.notion-image-viewer-scaler-input { + background-color: #060606c4; + display: flex; + align-items: center; + justify-content: center; + color: #888888; + width: 60px; + height: 32px; +} + +.notion-image-viewer-scaler-input:hover { + background-color: #060606a1; + display: flex; + align-items: center; +} + +.notion-image-viewer-scaler button { + width: 60; + padding: 5; +} + +.notion-image-viewer-scaler input { + background-color: transparent; + border: 0; + font-size: inherit; + color: inherit; + padding: 0px; + padding-top: 1px; + overflow: hidden; + line-height: 1; + text-align: center; +} + +.notion-image-viewer-scaler-input-button { + display: flex; + justify-content: center; + align-items: center; + width: 60px !important; + color: #888888; +} + +.notion-image-viewer-tools .notion-image-viewer-scaler input:focus { + color: white; + outline: 1px solid #2d75a0; + width: 28px; +} +/* Chrome, Safari, Edge, Opera */ +input::-webkit-outer-spin-button, +input::-webkit-inner-spin-button { + -webkit-appearance: none; + appearance: none; + margin: 0; +} +/* Firefox */ +input[type="number"] { + -moz-appearance: textfield; + appearance: textfield; +} + +.notion-image-viewer-tools .notion-image-viewer-scaler > button:first-of-type { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} +.notion-image-viewer-tools .notion-image-viewer-scaler > button:last-of-type { + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} +.notion-image-viewer-tools button > img { + width: 100%; + height: 100%; +} +.notion-image-viewer-tools button.notion-image-viewer-tools-download { + border-left: solid 1px white; + border-right: solid 1px white; + opacity: 0.9; +} +.notion-image-viewer-tools button.notion-image-viewer-tools-close { + width: 36px; + padding-right: 8px; + border-top-right-radius: 6px; + border-bottom-right-radius: 6px; +} + +.notion-image-viewer-opener { + cursor: pointer; +} + +.notion-image-viewer-container { + display: flex; + position: fixed; + inset: 0; + overflow: hidden; + z-index: 999; + justify-content: center; + align-items: center; + padding-top: 32px; + padding-bottom: 32px; + flex-direction: column; +} + +@media screen and (min-width: 768px) { + .notion-image-viewer-container { + padding-left: 32px; + padding-right: 32px; + } +} + +.notion-image-viewer-overlay { + position: fixed; + inset: 0; + background-color: black; + opacity: 0.9; + cursor: default; + overscroll-behavior: none; + overflow: hidden; +} + +.notion-image-viewer-container-image { + max-width: fit-content; + max-height: 100%; + object-fit: contain; + position: relative; + z-index: 0; + transform-origin: 0.4s ease-in-out; +} + +.notion-image-viewer-tools { + display: flex; + position: absolute; + bottom: 30px; + left: 50%; + transform: translateX(-50%); + transition: 2s all ease-in-out; +} + +.notion-image-viewer-tooltip-container { + position: relative; + display: inline-block; +} + +.notion-image-viewer-tooltip { + display: flex; + align-items: center; + position: absolute; + top: -35px; + left: -35%; + transform: translateX(-50%); + background-color: rgb(38, 38, 38); + color: white; + padding: 8px; + border-radius: 4px; + font-size: 12px; + white-space: nowrap; + pointer-events: none; + z-index: 10; +} + +.notion-image-viewer-tooltip p:last-child { + margin-left: 5px; + color: #d3d3d3; + font-size: 13px; +} + +button { + background: none; + border: none; + padding: 0; + margin: 0; + width: auto; + height: auto; + overflow: visible; + text-align: left; + color: inherit; + font: inherit; + line-height: normal; + -webkit-font-smoothing: inherit; + -moz-osx-font-smoothing: inherit; + -webkit-appearance: none; + appearance: none; +} From 21029f47acfbcbee576075400d28d581e9e9f5ad Mon Sep 17 00:00:00 2001 From: myjeong19 Date: Wed, 30 Oct 2024 22:47:13 +0900 Subject: [PATCH 02/10] cursor visible --- .../image-viewer/use-cursor-visibility.tsx | 12 ++--- .../src/lib/components/image/image-viewer.tsx | 49 +++++++++---------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/packages/react-notion-custom/src/lib/components/image/hooks/image-viewer/use-cursor-visibility.tsx b/packages/react-notion-custom/src/lib/components/image/hooks/image-viewer/use-cursor-visibility.tsx index 08527e8..0cbf398 100644 --- a/packages/react-notion-custom/src/lib/components/image/hooks/image-viewer/use-cursor-visibility.tsx +++ b/packages/react-notion-custom/src/lib/components/image/hooks/image-viewer/use-cursor-visibility.tsx @@ -1,6 +1,6 @@ import { useState, useRef, useCallback } from "react"; -export const useCursorVisibility = (isScaleFocus: boolean) => { +export const useCursorVisibility = () => { const [isCursorVisible, setIsisCursorVisible] = useState(true); const cursorTimeOutRef = useRef(); @@ -13,12 +13,10 @@ export const useCursorVisibility = (isScaleFocus: boolean) => { clearTimeout(cursorTimeOutRef.current); } - if (!isScaleFocus) { - cursorTimeOutRef.current = setTimeout(() => { - setIsisCursorVisible(false); - }, 2000); - } - }, [isScaleFocus]); + cursorTimeOutRef.current = setTimeout(() => { + setIsisCursorVisible(false); + }, 2000); + }, []); return { isCursorVisible, diff --git a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx index 4a8f5ff..7ddcc1a 100644 --- a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx +++ b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx @@ -51,8 +51,7 @@ const ImageViewer: React.FC = ({ handleScaleDown, } = useImageScale(); - const { isCursorVisible, handleMoveMouse } = - useCursorVisibility(isScaleFocus); + const { isCursorVisible, handleMoveMouse } = useCursorVisibility(); useEffect(() => { if (currentImageIndex || isOpened) { @@ -149,29 +148,29 @@ const ImageViewer: React.FC = ({ onClick={handleZoomInOut} /> - {/* {isCursorVisible && ( */} - - {/* )} */} + {(isCursorVisible || isScaleFocus) && ( + + )} )} From 01d5a0e87cc3b08fdec4e6139cdc3d2c216f6d2d Mon Sep 17 00:00:00 2001 From: myjeong19 Date: Thu, 31 Oct 2024 15:04:17 +0900 Subject: [PATCH 03/10] Fix. overlay cursor hide --- .../src/lib/components/image/image-viewer.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx index 7ddcc1a..3ea03ec 100644 --- a/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx +++ b/packages/react-notion-custom/src/lib/components/image/image-viewer.tsx @@ -133,6 +133,9 @@ const ImageViewer: React.FC = ({