Skip to content

Commit

Permalink
[UX] Update compatibility dialog to be non-modal (#1160)
Browse files Browse the repository at this point in the history
* allow non-modal dialog, set to true for compat layer dialog

* run yarn

* update z-indices
  • Loading branch information
BrettCleary authored Nov 26, 2024
1 parent 3a7ff9e commit a181243
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
15 changes: 11 additions & 4 deletions src/frontend/components/UI/Dialog/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ interface DialogProps {
children: ReactNode
showCloseButton: boolean
onClose: () => void
// modal or non-modal behavior https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
isModal?: boolean
}

export const Dialog: React.FC<DialogProps> = ({
children,
className,
showCloseButton = false,
onClose
onClose,
isModal = true
}) => {
const dialogRef = useRef<HTMLDialogElement | null>(null)
const onCloseRef = useRef(onClose)
Expand All @@ -32,10 +35,14 @@ export const Dialog: React.FC<DialogProps> = ({
onCloseRef.current()
}
dialog.addEventListener('cancel', cancel)
dialog['showModal']()
if (isModal) {
dialog.showModal()
} else {
dialog.show()
}
return () => {
dialog.removeEventListener('cancel', cancel)
dialog['close']()
dialog.close()
}
}
return
Expand Down Expand Up @@ -63,7 +70,7 @@ export const Dialog: React.FC<DialogProps> = ({
<dialog
className={`Dialog__element ${className}`}
ref={dialogRef}
onClick={onDialogClick}
onClick={isModal ? onDialogClick : undefined}
>
{showCloseButton && (
<div className="Dialog__Close">
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/components/UI/Dialog/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.Dialog__element {
top: 0;
z-index: 8;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
display: flex;
flex-direction: column;
padding: calc(var(--space-xl) * 1.67);
Expand All @@ -10,7 +12,6 @@
background: var(--color-neutral-800);
color: var(--text-default);
opacity: 0;
transform: translateY(50px);
transition: opacity 500ms, transform 500ms;
max-width: min(700px, 85vw);

Expand All @@ -23,7 +24,6 @@

.Dialog__element[open] {
opacity: 1;
transform: translateY(0);
box-shadow: 0px 0px 0px 100vmax var(--modal-backdrop);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface MessageBoxModalProps {
showCheckbox?: boolean
checkboxLabel?: string
checkboxValue?: boolean
isModal?: boolean
}

const MessageBoxModal: React.FC<MessageBoxModalProps> = function (props) {
Expand Down Expand Up @@ -71,6 +72,7 @@ const MessageBoxModal: React.FC<MessageBoxModalProps> = function (props) {
onClose={props.onClose}
showCloseButton
className={classNames({ errorDialog: props.type === 'ERROR' })}
isModal={props.isModal}
>
<DialogHeader onClose={props.onClose}>{props.title}</DialogHeader>
<DialogContent className="body dialogContent">
Expand Down
1 change: 1 addition & 0 deletions src/frontend/components/UI/DialogHandler/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function DialogHandler() {
title={dialogModalOptions.title ? dialogModalOptions.title : ''}
message={dialogModalOptions.message ? dialogModalOptions.message : ''}
buttons={dialogModalOptions.buttons ? dialogModalOptions.buttons : []}
isModal={dialogModalOptions.isModal}
onClose={() => handleClose()}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const tooltipProps: Partial<TooltipProps> = {
position: 'right',
withArrow: true,
className: 'Tooltip menu',
arrowSize: 10
arrowSize: 10,
zIndex: 1001
}

export default observer(function SidebarLinks() {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/helpers/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const launch = async ({
return res()
}
showDialogModal({
isModal: false,
message: t(
'gamepage:box.compability.message',
'This Windows game will run using a compatibility layer. You might encounter some issues or the game might not work at all.'
Expand Down
1 change: 1 addition & 0 deletions src/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export type DialogModalOptions = {
buttons?: Array<ButtonOptions>
type?: DialogType
onClose?: () => void
isModal?: boolean
}

export interface ExternalLinkDialogOptions {
Expand Down

0 comments on commit a181243

Please sign in to comment.