-
-
Notifications
You must be signed in to change notification settings - Fork 480
[General] Improvements in install dialog #1129
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 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5b132f2
[General] Improvements in install dialog
dawidgarus 3105c76
[General] Improvements in install dialog
dawidgarus ec5399c
Merge branch 'main' of https://github.com/Heroic-Games-Launcher/Heroi…
dawidgarus 4ff110b
[General] Improvements in install dialog
dawidgarus f2b02fe
[General] Improvements in install dialog
dawidgarus 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
const DialogContent: React.FC = ({ children }) => { | ||
return <div className="Dialog__content">{children}</div> | ||
} | ||
|
||
export default DialogContent |
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,7 @@ | ||
import React from 'react' | ||
|
||
const DialogFooter: React.FC = ({ children }) => { | ||
return <div className="Dialog__footer">{children}</div> | ||
} | ||
|
||
export default DialogFooter |
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,22 @@ | ||
import { faXmark } from '@fortawesome/free-solid-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import React from 'react' | ||
|
||
export interface DialogHeaderProps { | ||
onClose: () => void | ||
} | ||
|
||
const DialogHeader: React.FC<DialogHeaderProps> = ({ children, onClose }) => { | ||
return ( | ||
<div className="Dialog__header"> | ||
<div className="Dialog__headerTitle">{children}</div> | ||
<div className="Dialog__headerClose"> | ||
<button className="Dialog__headerCloseButton" onClick={onClose}> | ||
<FontAwesomeIcon className="Dialog__headerCloseIcon" icon={faXmark} /> | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default DialogHeader |
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,91 @@ | ||
.Dialog { | ||
padding: 0; | ||
text-align: left; | ||
|
||
--dialog-margin-horizontal: 32px; | ||
--dialog-margin-vertical: 24px; | ||
--dialog-gap: 24px; | ||
} | ||
|
||
.Dialog__element { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anything against |
||
top: 0; | ||
z-index: 8; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0; | ||
height: fit-content; | ||
min-width: fit-content; | ||
overflow: auto; | ||
border: solid 1px var(--modal-border); | ||
border-radius: 10px; | ||
background: var(--modal-background); | ||
color: var(--text-default); | ||
opacity: 0; | ||
transform: translateY(50px); | ||
transition: opacity 500ms, transform 500ms; | ||
} | ||
|
||
.Dialog__element[open] { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
|
||
.Dialog__element::backdrop { | ||
/* var() doesn't work here */ | ||
background: rgba(13, 15, 28, 0.8); | ||
} | ||
|
||
.Dialog__header { | ||
display: flex; | ||
} | ||
|
||
.Dialog__headerTitle { | ||
flex: 100% 1 1; | ||
padding: var(--dialog-margin-vertical) 16px 0 var(--dialog-margin-horizontal); | ||
font-size: 24px; | ||
} | ||
|
||
.Dialog__headerClose { | ||
padding: var(--dialog-margin-vertical) var(--dialog-margin-horizontal) 0 0; | ||
} | ||
|
||
.Dialog__headerCloseButton { | ||
border: none; | ||
margin: -8px; | ||
padding: 8px; | ||
border-radius: 10px; | ||
background: none; | ||
color: var(--text-default); | ||
cursor: pointer; | ||
transition: 250ms color; | ||
} | ||
|
||
.Dialog__headerCloseButton:focus-visible { | ||
outline: none; | ||
box-shadow: var(--accent) 0 0 0 2px inset; | ||
} | ||
|
||
.Dialog__headerCloseButton:hover { | ||
color: var(--text-hover); | ||
} | ||
|
||
.Dialog__headerCloseButton:active { | ||
color: var(--accent); | ||
} | ||
|
||
.Dialog__headerCloseIcon { | ||
font-size: 20px; | ||
} | ||
|
||
.Dialog__content { | ||
padding: var(--dialog-gap) var(--dialog-margin-horizontal); | ||
} | ||
|
||
.Dialog__footer { | ||
display: grid; | ||
grid-gap: 16px; | ||
grid-auto-flow: column; | ||
margin: 0 0 0 auto; | ||
padding: 0 var(--dialog-margin-horizontal) var(--dialog-margin-vertical) | ||
var(--dialog-margin-horizontal); | ||
} |
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,52 @@ | ||
import React, { SyntheticEvent, useCallback, useEffect, useRef } from 'react' | ||
import './index.css' | ||
|
||
export interface DialogProps { | ||
className?: string | ||
onClose: () => void | ||
} | ||
|
||
const Dialog: React.FC<DialogProps> = ({ children, className, onClose }) => { | ||
const dialogRef = useRef<HTMLDialogElement | null>(null) | ||
const onCloseRef = useRef(onClose) | ||
onCloseRef.current = onClose | ||
|
||
useEffect(() => { | ||
const dialog = dialogRef.current | ||
if (dialog) { | ||
const cancel = () => { | ||
onCloseRef.current() | ||
} | ||
dialog.addEventListener('cancel', cancel) | ||
dialog['showModal']() | ||
return () => { | ||
dialog.removeEventListener('cancel', cancel) | ||
dialog['close']() | ||
} | ||
} | ||
return | ||
}, [dialogRef.current]) | ||
|
||
const onDialogClick = useCallback( | ||
(e: SyntheticEvent) => { | ||
if (e.target === dialogRef.current) { | ||
onClose() | ||
} | ||
}, | ||
[onClose] | ||
) | ||
|
||
return ( | ||
<div className="Dialog"> | ||
<dialog | ||
className={`Dialog__element ${className}`} | ||
ref={dialogRef} | ||
onClick={onDialogClick} | ||
> | ||
{children} | ||
</dialog> | ||
</div> | ||
) | ||
} | ||
|
||
export default 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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything against
camelCase
? ahahahwe use camel case on the other variables and CSS classnames would be good to be consistent :)