-
-
Notifications
You must be signed in to change notification settings - Fork 46
feat(example-app): (React) new GlassModal and Editor page upgrades (saving, histories, fullscreen, bug fixes) #278
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
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
d7a54d6
fix(example-app): enable ref forwarding in GlassCard React component
Ryan-Millard d1199d5
feat(example-app): (React) Editor page controls
Ryan-Millard 365797b
refactor(example-app): (React) make navbar hamburger reusable
Ryan-Millard b2c1018
feat(example-app): (React) improve UI and make reusable HamburgerMenu
Ryan-Millard ccd105a
feat(example-app): (React) add print feature
Ryan-Millard 150959e
refactor(example-app): (React) move printing to its own function
Ryan-Millard 410abe4
perf(example-app): (React) use pointerrawupdate for faster mouse drags
Ryan-Millard 097a64f
feat(example-app): (React) undo and redo with history tracking
Ryan-Millard 0b436bc
chore(example-app): (React) clean up styles
Ryan-Millard 722e688
feat(example-app): add confirmation dialog for resets
Ryan-Millard 9120639
feat(example-app): hide save buttons behind a modal and prompt for co…
Ryan-Millard d6dbf96
fix(example-app): (React) Modal displayed under other elements & adde…
Ryan-Millard 0006934
fix(example-app): (React) editor page keybindings now support Mac
Ryan-Millard fd580a6
feat(example-app): (React) improve Editor page styles
Ryan-Millard 6389ea8
refactor(example-app): (React) reuse download function and clean up CSS
Ryan-Millard 184e7ca
feat(example-app): (React) improve editor page reset confirmation mod…
Ryan-Millard ff4bd80
fix(example-app): (React) unrevoked Blob URL
Ryan-Millard a762bcb
fix(example-app): (React) fix history bug where resetting doesn't cle…
Ryan-Millard 27d6df7
fix(example-app): (React) Skip history writes when the tap doesn't ch…
Ryan-Millard e98b0fa
fix(example-app): (React) Don't swallow every Ctrl/Cmd shortcut, and …
Ryan-Millard b604158
ci(fix-checkouts): include recursive checkouts to include submodules…
Ryan-Millard 6b0343c
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard ec0bfb1
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard cb44b7e
fix(example-app): (React) use pointermove when pointerrawupdate is un…
Ryan-Millard 050bdde
fix(example-app): (React) revokeObjectURL on SVG in Editor page
Ryan-Millard 3d8ca26
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard 23faea3
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard 2e489c1
style(example-app): format all files
Ryan-Millard 01cbb1e
fix(react-js): resolve ESLint warnings in Editor components
Ryan-Millard 35c0ea1
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard 1aa1674
chore(file-resets): reset gpu.h and pr-auto-label.yml back to main's …
Ryan-Millard 801584e
feat(editor): add fullscreen and improve zoom behavior
Ryan-Millard 623e83f
style(example-app): (React) format all files
Ryan-Millard f56519f
refactor(example-app): (React) fix eslint warnings & tooltip positions
Ryan-Millard f736879
style(format): format all files
Ryan-Millard b6a40d3
Merge branch 'main' into feat/example-app/react/download-svg
Ryan-Millard 20855b7
fix(example-app): (React) used functionbefore defined
Ryan-Millard 843af6b
fix(useFullscreen): push/pop history on fullscreenchange instead of o…
Ryan-Millard 4931be6
feat(editor): add raster (PNG/JPG) and PDF export to EditorControls
Ryan-Millard 7b18ad8
style(format): format all files
Ryan-Millard 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
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
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
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
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
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
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,66 @@ | ||
| import { useEffect } from "react"; | ||
| import { createPortal } from "react-dom"; | ||
| import PropTypes from "prop-types"; | ||
| import GlassCard from "@components/GlassCard"; | ||
| import styles from "./GlassModal.module.css"; | ||
| import { X } from "lucide-react"; | ||
|
|
||
| export default function GlassModal({ | ||
| isOpen, | ||
| onClose, | ||
| children, | ||
| size = "lg", // sm | md | lg | any CSS width | ||
| showCloseButton = true, | ||
| closeOnBackdropClick = true, | ||
| className = "", | ||
| style = {}, | ||
| }) { | ||
| useEffect(() => { | ||
| const handleKey = (e) => { | ||
| if (e.key === "Escape") onClose?.(); | ||
| }; | ||
| if (isOpen) window.addEventListener("keydown", handleKey); | ||
| return () => window.removeEventListener("keydown", handleKey); | ||
| }, [isOpen, onClose]); | ||
|
|
||
| if (!isOpen) return null; | ||
|
|
||
| const handleBackdropClick = (e) => { | ||
| if (e.target === e.currentTarget && closeOnBackdropClick) { | ||
| onClose?.(); | ||
| } | ||
| }; | ||
|
|
||
| const width = size === "sm" ? "300px" : size === "md" ? "500px" : size === "lg" ? "800px" : size; | ||
|
|
||
| const modal = ( | ||
| <div className={styles.backdrop} onClick={handleBackdropClick} role="dialog"> | ||
| <GlassCard | ||
| as="div" | ||
| className={`${styles.modal} ${className}`} | ||
| style={{ | ||
| flex: "0 0 auto", | ||
| width: width, | ||
| ...style, | ||
| }} | ||
| > | ||
| {showCloseButton && ( | ||
| <a | ||
| href="#" | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| onClose(); | ||
| }} | ||
| className={`${styles.closeButton}`} | ||
| aria-label="Close modal" | ||
| > | ||
| <X size={20} /> | ||
| </a> | ||
| )} | ||
| {children} | ||
| </GlassCard> | ||
| </div> | ||
| ); | ||
|
|
||
| return createPortal(modal, document.body); | ||
| } |
54 changes: 54 additions & 0 deletions
54
example-apps/react-js/src/components/GlassModal.module.css
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,54 @@ | ||
| .backdrop { | ||
| position: fixed; | ||
| inset: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 1000; | ||
| animation: fadeIn 0.2s ease forwards; | ||
| } | ||
|
|
||
| .modal { | ||
| position: relative; | ||
| border-radius: 1rem; | ||
| background: var(--color-bg); | ||
| padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-lg); | ||
| box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25); | ||
| animation: scaleIn 0.2s ease forwards; | ||
| max-height: 90vh; | ||
| max-width: 95vw; | ||
| overflow-y: auto; | ||
| z-index: 1001; | ||
| } | ||
|
|
||
| .closeButton { | ||
| position: absolute; | ||
| top: 0.5rem; | ||
| right: 0.5rem; | ||
| border: none; | ||
| cursor: pointer; | ||
| padding: var(--spacing-xs); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| @keyframes fadeIn { | ||
| from { | ||
| opacity: 0; | ||
| } | ||
| to { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| @keyframes scaleIn { | ||
| from { | ||
| transform: scale(0.95); | ||
| opacity: 0; | ||
| } | ||
| to { | ||
| transform: scale(1); | ||
| opacity: 1; | ||
| } | ||
| } | ||
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
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
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
Oops, something went wrong.
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.