-
Notifications
You must be signed in to change notification settings - Fork 184
FF designer quickstart images #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+164
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d8c1c36
FF Designer quickstart images update + click image to open in fullscreen
pinkeshmars b18bce4
Remove image caption + prevent scrolling while overlay is open
pinkeshmars e1bbfa4
Merge branch 'main' into update/ff-designer-quickstart-images
pinkeshmars b4879bb
Merge branch 'main' into update/ff-designer-quickstart-images
PoojaB26 2aff0f5
Merge branch 'main' into update/ff-designer-quickstart-images
PoojaB26 c8986a7
Apply suggestions from code review
PoojaB26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-71.3 KB
(79%)
docs/ff-designer/getting-started/imgs/fitness-tracking-app.avif
Binary file not shown.
Binary file modified
BIN
+345 KB
(190%)
docs/ff-designer/getting-started/imgs/food-delivery-app.avif
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| 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); | ||
| const lastActiveElementRef = React.useRef<HTMLElement | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!isOpen) { | ||
| return undefined; | ||
| } | ||
|
|
||
| lastActiveElementRef.current = document.activeElement as HTMLElement | null; | ||
|
|
||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| if (event.key === 'Escape') { | ||
| setIsOpen(false); | ||
| } | ||
| }; | ||
|
|
||
| document.body.classList.add(styles.fullscreenOpen); | ||
| window.addEventListener('keydown', handleKeyDown); | ||
|
|
||
| // Ensure keyboard focus enters the modal. | ||
| requestAnimationFrame(() => { | ||
| document | ||
| .querySelector<HTMLButtonElement>(`.${styles.closeButton}`) | ||
| ?.focus(); | ||
| }); | ||
|
|
||
| return () => { | ||
| document.body.classList.remove(styles.fullscreenOpen); | ||
| window.removeEventListener('keydown', handleKeyDown); | ||
| lastActiveElementRef.current?.focus(); | ||
| lastActiveElementRef.current = null; | ||
| }; | ||
| }, [isOpen]); | ||
|
|
||
| if (!alt?.trim() && !props.title?.trim()) { | ||
| return ( | ||
| <img | ||
| decoding="async" | ||
| loading="lazy" | ||
| {...props} | ||
| className={transformImgClassName(className)} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <button | ||
| type="button" | ||
| className={styles.trigger} | ||
| aria-label={alt ? `Open image: ${alt}` : 'Open image fullscreen'} | ||
| onClick={() => setIsOpen(true)}> | ||
| <img | ||
| decoding="async" | ||
| loading="lazy" | ||
| {...props} | ||
| alt={alt ?? ''} | ||
| className={transformImgClassName(className)} | ||
| /> | ||
|
PoojaB26 marked this conversation as resolved.
|
||
| </button> | ||
|
|
||
| {isOpen && ( | ||
| <div | ||
| className={styles.overlay} | ||
| role="dialog" | ||
| aria-modal="true" | ||
| aria-label={alt ? `Fullscreen image: ${alt}` : 'Fullscreen image'} | ||
| onClick={() => setIsOpen(false)}> | ||
| <button | ||
| type="button" | ||
| className={styles.closeButton} | ||
| aria-label="Close fullscreen image" | ||
| onClick={() => setIsOpen(false)}> | ||
| × | ||
| </button> | ||
| <img | ||
| src={src} | ||
| alt={alt ?? ''} | ||
| className={styles.fullscreenImage} | ||
| onClick={(event) => event.stopPropagation()} | ||
|
PoojaB26 marked this conversation as resolved.
|
||
| /> | ||
| /> | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.