Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
5fcf2eea
Commit
5fcf2eea
authored
Feb 12, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Feb 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new ModalDialog for use profile modal
parent
78386e60
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
40 deletions
+48
-40
ModalDialog.tsx
src/annotator/components/ModalDialog.tsx
+13
-9
NotebookModal.tsx
src/annotator/components/NotebookModal.tsx
+5
-1
ProfileModal.tsx
src/annotator/components/ProfileModal.tsx
+25
-25
ModalDialog-test.js
src/annotator/components/test/ModalDialog-test.js
+4
-4
NotebookModal-test.js
src/annotator/components/test/NotebookModal-test.js
+1
-1
No files found.
src/annotator/components/ModalDialog.tsx
View file @
5fcf2eea
...
@@ -6,9 +6,15 @@ type DialogProps = {
...
@@ -6,9 +6,15 @@ type DialogProps = {
closed
:
boolean
;
closed
:
boolean
;
children
:
ComponentChildren
;
children
:
ComponentChildren
;
onClose
:
()
=>
void
;
onClose
:
()
=>
void
;
'data-testid'
?:
string
;
};
};
const
NativeDialog
=
({
closed
,
children
,
onClose
}:
DialogProps
)
=>
{
function
NativeDialog
({
closed
,
onClose
,
children
,
'data-testid'
:
testId
,
}:
DialogProps
)
{
const
dialogRef
=
useRef
<
HTMLDialogElement
|
null
>
(
null
);
const
dialogRef
=
useRef
<
HTMLDialogElement
|
null
>
(
null
);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -32,32 +38,30 @@ const NativeDialog = ({ closed, children, onClose }: DialogProps) => {
...
@@ -32,32 +38,30 @@ const NativeDialog = ({ closed, children, onClose }: DialogProps) => {
<
dialog
<
dialog
ref=
{
dialogRef
}
ref=
{
dialogRef
}
className=
"relative w-full h-full backdrop:bg-black/50"
className=
"relative w-full h-full backdrop:bg-black/50"
data
-
testid=
"notebook-outer"
data
-
testid=
{
testId
}
>
>
{
children
}
{
children
}
</
dialog
>
</
dialog
>
);
);
}
;
}
/**
/**
* Temporary fallback used in browsers not supporting `dialog` element.
* Temporary fallback used in browsers not supporting `dialog` element.
* It can be removed once all browsers we support can use it.
* It can be removed once all browsers we support can use it.
*/
*/
const
FallbackDialog
=
({
closed
,
children
}:
DialogProps
)
=>
{
function
FallbackDialog
({
closed
,
children
,
...
rest
}:
DialogProps
)
{
return
(
return
(
<
div
<
div
{
...
rest
}
className=
{
classnames
(
className=
{
classnames
(
'fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50'
,
'fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50'
,
{
hidden
:
closed
},
{
hidden
:
closed
},
)
}
)
}
data
-
testid=
"notebook-outer"
>
>
<
div
className=
"relative w-full h-full"
data
-
testid=
"notebook-inner"
>
<
div
className=
"relative w-full h-full"
>
{
children
}
</
div
>
{
children
}
</
div
>
</
div
>
</
div
>
);
);
}
;
}
/** Checks if the browser supports native modal dialogs */
/** Checks if the browser supports native modal dialogs */
function
isModalDialogSupported
(
document
:
Document
)
{
function
isModalDialogSupported
(
document
:
Document
)
{
...
...
src/annotator/components/NotebookModal.tsx
View file @
5fcf2eea
...
@@ -108,7 +108,11 @@ export default function NotebookModal({
...
@@ -108,7 +108,11 @@ export default function NotebookModal({
}
}
return
(
return
(
<
ModalDialog
closed=
{
isHidden
}
onClose=
{
onClose
}
>
<
ModalDialog
closed=
{
isHidden
}
onClose=
{
onClose
}
data
-
testid=
"notebook-outer"
>
<
div
className=
"absolute right-0 m-3"
>
<
div
className=
"absolute right-0 m-3"
>
<
IconButton
<
IconButton
title=
"Close the Notebook"
title=
"Close the Notebook"
...
...
src/annotator/components/ProfileModal.tsx
View file @
5fcf2eea
...
@@ -3,6 +3,7 @@ import classnames from 'classnames';
...
@@ -3,6 +3,7 @@ import classnames from 'classnames';
import
{
useEffect
,
useRef
,
useState
}
from
'preact/hooks'
;
import
{
useEffect
,
useRef
,
useState
}
from
'preact/hooks'
;
import
type
{
Emitter
,
EventBus
}
from
'../util/emitter'
;
import
type
{
Emitter
,
EventBus
}
from
'../util/emitter'
;
import
ModalDialog
from
'./ModalDialog'
;
export
type
ProfileConfig
=
{
profileAppUrl
:
string
}
&
Record
<
string
,
unknown
>
;
export
type
ProfileConfig
=
{
profileAppUrl
:
string
}
&
Record
<
string
,
unknown
>
;
...
@@ -37,14 +38,14 @@ export default function ProfileModal({ eventBus, config }: ProfileModalProps) {
...
@@ -37,14 +38,14 @@ export default function ProfileModal({ eventBus, config }: ProfileModalProps) {
}
}
return
(
return
(
<
div
<
ModalDialog
className=
"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50"
closed=
{
isHidden
}
onClose=
{
onClose
}
data
-
testid=
"profile-outer"
data
-
testid=
"profile-outer"
>
>
<
div
className=
"relative w-full h-full"
data
-
testid=
"profile-inner"
>
<
div
className=
"absolute right-0 m-3"
>
<
div
className=
"absolute right-0 m-3"
>
<
IconButton
<
IconButton
title=
"Close the Profile
"
title=
"Close profile dialog
"
onClick=
{
onClose
}
onClick=
{
onClose
}
variant=
"dark"
variant=
"dark"
classes=
{
classnames
(
classes=
{
classnames
(
...
@@ -63,7 +64,6 @@ export default function ProfileModal({ eventBus, config }: ProfileModalProps) {
...
@@ -63,7 +64,6 @@ export default function ProfileModal({ eventBus, config }: ProfileModalProps) {
className=
"h-full w-full border-0"
className=
"h-full w-full border-0"
src=
{
config
.
profileAppUrl
}
src=
{
config
.
profileAppUrl
}
/>
/>
</
div
>
</
ModalDialog
>
</
div
>
);
);
}
}
src/annotator/components/test/ModalDialog-test.js
View file @
5fcf2eea
...
@@ -6,13 +6,13 @@ describe('ModalDialog', () => {
...
@@ -6,13 +6,13 @@ describe('ModalDialog', () => {
let
components
;
let
components
;
const
createComponent
=
props
=>
{
const
createComponent
=
props
=>
{
const
attachTo
=
document
.
createElement
(
'div'
);
const
container
=
document
.
createElement
(
'div'
);
document
.
body
.
appendChild
(
attachTo
);
document
.
body
.
appendChild
(
container
);
const
component
=
mount
(
<
ModalDialog
open
{...
props
}
/>,
{
const
component
=
mount
(
<
ModalDialog
open
{...
props
}
/>,
{
attachTo
,
attachTo
:
container
,
});
});
components
.
push
([
component
,
attachTo
]);
components
.
push
([
component
,
container
]);
return
component
;
return
component
;
};
};
...
...
src/annotator/components/test/NotebookModal-test.js
View file @
5fcf2eea
...
@@ -12,7 +12,7 @@ describe('NotebookModal', () => {
...
@@ -12,7 +12,7 @@ describe('NotebookModal', () => {
let
eventBus
;
let
eventBus
;
let
emitter
;
let
emitter
;
const
outerSelector
=
'[data-testid="notebook-outer"]'
;
const
outerSelector
=
'
dialog
[data-testid="notebook-outer"]'
;
const
createComponent
=
config
=>
{
const
createComponent
=
config
=>
{
const
attachTo
=
document
.
createElement
(
'div'
);
const
attachTo
=
document
.
createElement
(
'div'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment