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
1a2e36f2
Commit
1a2e36f2
authored
Feb 07, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Feb 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `prompts` to TSX
parent
90af4bb7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
prompts.tsx
src/shared/prompts.tsx
+12
-11
No files found.
src/shared/prompts.
js
→
src/shared/prompts.
tsx
View file @
1a2e36f2
...
...
@@ -2,27 +2,29 @@ import { render } from 'preact';
import
{
ConfirmModal
}
from
'@hypothesis/frontend-shared'
;
export
type
ConfirmModalProps
=
{
title
?:
string
;
message
:
string
;
confirmAction
?:
string
;
};
/**
* Show the user a prompt asking them to confirm an action.
*
* This is like an async version of `window.confirm` except that:
*
* - It can be used inside iframes (browsers are starting to prevent this
*
for
the native `window.confirm` dialog)
* - It can be used inside iframes (browsers are starting to prevent this
for
* the native `window.confirm` dialog)
* - The visual style of the dialog matches the Hypothesis design system
*
* @param {object} options - Options for the `ConfirmModal`
* @param {string} [options.title]
* @param {string} options.message
* @param {string} [options.confirmAction]
* @return {Promise<boolean>} - Promise that resolves with `true` if the user
* confirmed the action or `false` if they canceled it.
* @return - Promise that resolves with `true` if the user confirmed the action
* or `false` if they canceled it.
*/
export
async
function
confirm
({
title
=
'Confirm'
,
message
,
confirmAction
=
'Yes'
,
}
)
{
}
:
ConfirmModalProps
):
Promise
<
boolean
>
{
const
container
=
document
.
createElement
(
'div'
);
container
.
setAttribute
(
'data-testid'
,
'confirm-container'
);
...
...
@@ -34,8 +36,7 @@ export async function confirm({
document
.
body
.
appendChild
(
container
);
return
new
Promise
(
resolve
=>
{
/** @param {boolean} result */
const
close
=
result
=>
{
const
close
=
(
result
:
boolean
)
=>
{
render
(
null
,
container
);
container
.
remove
();
resolve
(
result
);
...
...
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