-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: replace native OS close dialog with custom in-app dialog #521
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
Open
makaradam
wants to merge
5
commits into
siddharthvaddem:main
Choose a base branch
from
makaradam:feature/save-dialog-redesign
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b3469c4
feat: replace native OS close dialog with custom in-app dialog
makaradam 36076aa
fix: address code review feedback on custom close dialog
makaradam b2cc722
fix: use getAssetPath for logo so it resolves correctly in packaged app
makaradam e7e4932
fix: use relative path for logo so it resolves in packaged app
makaradam e2bdfee
fix: scope IPC close-confirm responses to the originating window
makaradam 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { Save, Trash2 } from "lucide-react"; | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| } from "@/components/ui/dialog"; | ||
| import { useScopedT } from "@/contexts/I18nContext"; | ||
|
|
||
| interface UnsavedChangesDialogProps { | ||
| isOpen: boolean; | ||
| onSaveAndClose: () => void; | ||
| onDiscardAndClose: () => void; | ||
| onCancel: () => void; | ||
| } | ||
|
|
||
| export function UnsavedChangesDialog({ | ||
| isOpen, | ||
| onSaveAndClose, | ||
| onDiscardAndClose, | ||
| onCancel, | ||
| }: UnsavedChangesDialogProps) { | ||
| const td = useScopedT("dialogs"); | ||
| const tc = useScopedT("common"); | ||
|
|
||
| return ( | ||
| <Dialog open={isOpen} onOpenChange={(open) => !open && onCancel()}> | ||
| <DialogContent className="bg-[#09090b] border-white/10 rounded-2xl max-w-sm p-6 gap-0"> | ||
| <DialogHeader className="mb-5"> | ||
| <div className="flex items-center gap-3"> | ||
| <img | ||
| src="./openscreen.png" | ||
| alt="" | ||
| aria-hidden="true" | ||
| className="w-9 h-9 rounded-xl flex-shrink-0" | ||
| /> | ||
| <DialogTitle className="text-base font-semibold text-slate-200 leading-tight"> | ||
| {td("unsavedChanges.title")} | ||
| </DialogTitle> | ||
| </div> | ||
| </DialogHeader> | ||
|
|
||
| <p className="text-sm text-slate-300 mb-1">{td("unsavedChanges.message")}</p> | ||
| <DialogDescription className="text-sm text-slate-500 mb-6"> | ||
| {td("unsavedChanges.detail")} | ||
| </DialogDescription> | ||
|
|
||
| <div className="flex flex-col gap-2"> | ||
| <button | ||
| type="button" | ||
| onClick={onSaveAndClose} | ||
| className="flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-lg bg-[#34B27B] hover:bg-[#2d9e6c] active:bg-[#27885c] text-white font-medium text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-[#34B27B] focus-visible:ring-offset-2 focus-visible:ring-offset-[#09090b]" | ||
| > | ||
| <Save className="w-4 h-4" /> | ||
| {td("unsavedChanges.saveAndClose")} | ||
| </button> | ||
| <button | ||
| type="button" | ||
| onClick={onDiscardAndClose} | ||
| className="flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-lg bg-white/5 hover:bg-red-500/15 border border-white/10 hover:border-red-500/30 text-slate-300 hover:text-red-400 font-medium text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-white/30 focus-visible:ring-offset-2 focus-visible:ring-offset-[#09090b]" | ||
| > | ||
| <Trash2 className="w-4 h-4" /> | ||
| {td("unsavedChanges.discardAndClose")} | ||
| </button> | ||
| <button | ||
| type="button" | ||
| onClick={onCancel} | ||
| className="flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-lg hover:bg-white/5 text-slate-500 hover:text-slate-300 font-medium text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-white/20 focus-visible:ring-offset-2 focus-visible:ring-offset-[#09090b]" | ||
| > | ||
| {tc("actions.cancel")} | ||
| </button> | ||
| </div> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| } |
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.
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.