diff --git a/docs/ff-designer/getting-started/imgs/fitness-tracking-app.avif b/docs/ff-designer/getting-started/imgs/fitness-tracking-app.avif index 616334ab..27ec349f 100644 Binary files a/docs/ff-designer/getting-started/imgs/fitness-tracking-app.avif and b/docs/ff-designer/getting-started/imgs/fitness-tracking-app.avif differ diff --git a/docs/ff-designer/getting-started/imgs/food-delivery-app.avif b/docs/ff-designer/getting-started/imgs/food-delivery-app.avif index 69a522a7..4ee9f27f 100644 Binary files a/docs/ff-designer/getting-started/imgs/food-delivery-app.avif and b/docs/ff-designer/getting-started/imgs/food-delivery-app.avif differ diff --git a/src/theme/MDXComponents/Img/index.tsx b/src/theme/MDXComponents/Img/index.tsx new file mode 100644 index 00000000..4443cc11 --- /dev/null +++ b/src/theme/MDXComponents/Img/index.tsx @@ -0,0 +1,74 @@ +import React, {useEffect, useState} from 'react'; +import clsx from 'clsx'; +import type {Props} from '@theme/MDXComponents/Img'; + +import styles from './styles.module.css'; + +function transformImgClassName(className?: string): string { + return clsx(className, styles.img); +} + +export default function MDXImg(props: Props): JSX.Element { + const {alt, className, src} = props; + const [isOpen, setIsOpen] = useState(false); + + useEffect(() => { + if (!isOpen) { + return undefined; + } + + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + setIsOpen(false); + } + }; + + document.body.classList.add(styles.fullscreenOpen); + window.addEventListener('keydown', handleKeyDown); + + return () => { + document.body.classList.remove(styles.fullscreenOpen); + window.removeEventListener('keydown', handleKeyDown); + }; + }, [isOpen]); + + return ( + <> + + + {isOpen && ( +
setIsOpen(false)}> + + {alt} event.stopPropagation()} + /> +
+ )} + + ); +} diff --git a/src/theme/MDXComponents/Img/styles.module.css b/src/theme/MDXComponents/Img/styles.module.css new file mode 100644 index 00000000..c4fe2d4f --- /dev/null +++ b/src/theme/MDXComponents/Img/styles.module.css @@ -0,0 +1,65 @@ +.trigger { + display: inline-block; + max-width: 100%; + padding: 0; + border: 0; + background: transparent; + color: inherit; + cursor: zoom-in; + text-align: inherit; +} + +.img { + height: auto; +} + +.trigger .img { + display: block; + max-width: 100%; +} + +.fullscreenOpen { + overflow: hidden; +} + +.overlay { + position: fixed; + inset: 0; + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + padding: 32px 24px; + background: rgba(0, 0, 0, 0.88); + cursor: zoom-out; + overscroll-behavior: none; +} + +.fullscreenImage { + max-width: 100%; + max-height: 100%; + object-fit: contain; + box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); + cursor: default; +} + +.closeButton { + position: fixed; + top: 16px; + right: 16px; + width: 44px; + height: 44px; + border: 1px solid rgba(255, 255, 255, 0.32); + border-radius: 50%; + background: rgba(0, 0, 0, 0.48); + color: #fff; + cursor: pointer; + font-size: 32px; + line-height: 38px; +} + +.closeButton:hover, +.closeButton:focus-visible { + background: rgba(255, 255, 255, 0.18); +}