Skip to content

Commit a181243

Browse files
authored
[UX] Update compatibility dialog to be non-modal (#1160)
* allow non-modal dialog, set to true for compat layer dialog * run yarn * update z-indices
1 parent 3a7ff9e commit a181243

File tree

7 files changed

+22
-9
lines changed

7 files changed

+22
-9
lines changed

src/frontend/components/UI/Dialog/components/Dialog.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ interface DialogProps {
1313
children: ReactNode
1414
showCloseButton: boolean
1515
onClose: () => void
16+
// modal or non-modal behavior https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
17+
isModal?: boolean
1618
}
1719

1820
export const Dialog: React.FC<DialogProps> = ({
1921
children,
2022
className,
2123
showCloseButton = false,
22-
onClose
24+
onClose,
25+
isModal = true
2326
}) => {
2427
const dialogRef = useRef<HTMLDialogElement | null>(null)
2528
const onCloseRef = useRef(onClose)
@@ -32,10 +35,14 @@ export const Dialog: React.FC<DialogProps> = ({
3235
onCloseRef.current()
3336
}
3437
dialog.addEventListener('cancel', cancel)
35-
dialog['showModal']()
38+
if (isModal) {
39+
dialog.showModal()
40+
} else {
41+
dialog.show()
42+
}
3643
return () => {
3744
dialog.removeEventListener('cancel', cancel)
38-
dialog['close']()
45+
dialog.close()
3946
}
4047
}
4148
return
@@ -63,7 +70,7 @@ export const Dialog: React.FC<DialogProps> = ({
6370
<dialog
6471
className={`Dialog__element ${className}`}
6572
ref={dialogRef}
66-
onClick={onDialogClick}
73+
onClick={isModal ? onDialogClick : undefined}
6774
>
6875
{showCloseButton && (
6976
<div className="Dialog__Close">

src/frontend/components/UI/Dialog/index.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.Dialog__element {
2-
top: 0;
3-
z-index: 8;
2+
top: 50%;
3+
left: 50%;
4+
transform: translate(-50%, -50%);
5+
z-index: 1000;
46
display: flex;
57
flex-direction: column;
68
padding: calc(var(--space-xl) * 1.67);
@@ -10,7 +12,6 @@
1012
background: var(--color-neutral-800);
1113
color: var(--text-default);
1214
opacity: 0;
13-
transform: translateY(50px);
1415
transition: opacity 500ms, transform 500ms;
1516
max-width: min(700px, 85vw);
1617

@@ -23,7 +24,6 @@
2324

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

src/frontend/components/UI/DialogHandler/components/MessageBoxModal/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface MessageBoxModalProps {
2020
showCheckbox?: boolean
2121
checkboxLabel?: string
2222
checkboxValue?: boolean
23+
isModal?: boolean
2324
}
2425

2526
const MessageBoxModal: React.FC<MessageBoxModalProps> = function (props) {
@@ -71,6 +72,7 @@ const MessageBoxModal: React.FC<MessageBoxModalProps> = function (props) {
7172
onClose={props.onClose}
7273
showCloseButton
7374
className={classNames({ errorDialog: props.type === 'ERROR' })}
75+
isModal={props.isModal}
7476
>
7577
<DialogHeader onClose={props.onClose}>{props.title}</DialogHeader>
7678
<DialogContent className="body dialogContent">

src/frontend/components/UI/DialogHandler/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default function DialogHandler() {
4242
title={dialogModalOptions.title ? dialogModalOptions.title : ''}
4343
message={dialogModalOptions.message ? dialogModalOptions.message : ''}
4444
buttons={dialogModalOptions.buttons ? dialogModalOptions.buttons : []}
45+
isModal={dialogModalOptions.isModal}
4546
onClose={() => handleClose()}
4647
/>
4748
)}

src/frontend/components/UI/Sidebar/components/SidebarLinks/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const tooltipProps: Partial<TooltipProps> = {
1818
position: 'right',
1919
withArrow: true,
2020
className: 'Tooltip menu',
21-
arrowSize: 10
21+
arrowSize: 10,
22+
zIndex: 1001
2223
}
2324

2425
export default observer(function SidebarLinks() {

src/frontend/helpers/library.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const launch = async ({
164164
return res()
165165
}
166166
showDialogModal({
167+
isModal: false,
167168
message: t(
168169
'gamepage:box.compability.message',
169170
'This Windows game will run using a compatibility layer. You might encounter some issues or the game might not work at all.'

src/frontend/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type DialogModalOptions = {
7373
buttons?: Array<ButtonOptions>
7474
type?: DialogType
7575
onClose?: () => void
76+
isModal?: boolean
7677
}
7778

7879
export interface ExternalLinkDialogOptions {

0 commit comments

Comments
 (0)