diff --git a/app/entities/common/Overlay/Image/ImageZoomOverlayContainer.tsx b/app/entities/common/Overlay/Image/ImageZoomOverlayContainer.tsx index 41b0ae1..2a3d7bb 100644 --- a/app/entities/common/Overlay/Image/ImageZoomOverlayContainer.tsx +++ b/app/entities/common/Overlay/Image/ImageZoomOverlayContainer.tsx @@ -14,7 +14,7 @@ const ImageZoomOverlayContainer = ({ if (!selectedImage) return null; return ( -
+
); diff --git a/app/entities/common/Overlay/Overlay.tsx b/app/entities/common/Overlay/Overlay.tsx index e084823..45089ae 100644 --- a/app/entities/common/Overlay/Overlay.tsx +++ b/app/entities/common/Overlay/Overlay.tsx @@ -4,11 +4,13 @@ interface OverlayProps { overlayOpen: boolean; setOverlayOpen: (open: boolean) => void; children: ReactNode; + maxWidth?: 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | number; } const Overlay = ({ overlayOpen = false, setOverlayOpen, children, + maxWidth = '2xl', }: OverlayProps) => { const overlayRef = useRef(null); useEffect(() => { @@ -24,13 +26,17 @@ const Overlay = ({ }; }, []); + const isMaxWidthTypeNumber = typeof maxWidth === 'number'; + return ( overlayOpen && (
-
+
{children}
diff --git a/app/entities/post/detail/PostBody.tsx b/app/entities/post/detail/PostBody.tsx index 5a654ef..707a997 100644 --- a/app/entities/post/detail/PostBody.tsx +++ b/app/entities/post/detail/PostBody.tsx @@ -42,6 +42,42 @@ const PostBody = ({ content, tags, loading }: Props) => { } }; + const addDescriptionUnderImage = ( + node: any, + index?: number, + parent?: Element + ) => { + if (node.type === 'element' && node.tagName === 'img') { + const altText = node.properties.alt; + if (altText) { + const descriptionNode = { + type: 'element', + tagName: 'span', + properties: { + className: 'image-description', + }, + children: [ + { + type: 'text', + value: altText, + }, + ], + }; + + if ( + index !== undefined && + parent && + parent.children && + Array.isArray(parent.children) + ) { + parent.children.splice(index + 1, 0, descriptionNode); + } + } + } + + return null; + }; + const renderOpenGraph = (node: any, index?: number, parent?: Element) => { if (node.type === 'element' && node.tagName === 'p' && node.children) { const aTag = node.children.find( @@ -226,7 +262,11 @@ const PostBody = ({ content, tags, loading }: Props) => {
) : ( <> - + { parent as Element | undefined ); addImageClickHandler(node); + addDescriptionUnderImage( + node, + index, + parent as Element | undefined + ); }} /> diff --git a/app/globals.css b/app/globals.css index 930e76f..314afc3 100644 --- a/app/globals.css +++ b/app/globals.css @@ -82,13 +82,21 @@ article.post .post-body p:has(img) { } article.post .post-body img { - max-width: 100%; + max-width: 90%; height: auto; margin: 1em 0; border-radius: 1em; box-shadow: 0 0 4px rgba(0, 0, 0, 0.05); } +article.post .post-body div > div img { + max-width: 50%; +} + +article.post .post-body div > div.zoomBox img { + max-width: 100%; +} + article.post .post-body .zoomBox img { border-radius: 0; } @@ -175,6 +183,15 @@ article.post .post-body pre { box-shadow: 0 0 4px rgba(0, 0, 0, 0.05); } +article.post .image-description { + text-align: center; + font-size: 0.75em; + color: var(--text-weak); + margin-top: -0.5em; + margin-bottom: 1em; + display: block; +} + .shadow-top { box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1),