Skip to content

Commit 0392b97

Browse files
committed
Make support check error modal closable
1 parent 1bfeb65 commit 0392b97

2 files changed

Lines changed: 42 additions & 19 deletions

File tree

example/utils.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,36 @@ export function saveAsPng(scatterplot) {
2626
imageObject.src = scatterplot.get('canvas').toDataURL();
2727
}
2828

29-
export function showModal(text, isError) {
29+
export function closeModal() {
30+
const modal = document.querySelector('#modal');
31+
const modalText = document.querySelector('#modal-text');
32+
modal.style.display = 'none';
33+
modalText.textContent = '';
34+
}
35+
36+
export function showModal(text, isError, isClosable) {
3037
const modal = document.querySelector('#modal');
31-
const modalText = document.querySelector('#modal span');
3238
modal.style.display = 'flex';
39+
40+
const modalText = document.querySelector('#modal-text');
3341
modalText.style.color = isError ? '#cc79A7' : '#bbb';
3442
modalText.textContent = text;
35-
}
3643

37-
export function closeModal() {
38-
const modal = document.querySelector('#modal');
39-
const modalText = document.querySelector('#modal span');
40-
modal.style.display = 'none';
41-
modalText.textContent = '';
44+
const modalClose = document.querySelector('#modal-close');
45+
if (isClosable) {
46+
modalClose.style.display = 'block';
47+
modalClose.style.background = isError ? '#cc79A7' : '#bbb';
48+
modalClose.addEventListener('click', closeModal, { once: true });
49+
} else {
50+
modalClose.style.display = 'none';
51+
}
4252
}
4353

4454
export function checkSupport(scatterplot) {
45-
if (!scatterplot.isSupported) {
55+
if (scatterplot.isSupported) {
4656
showModal(
47-
'Unfortunately, your browser does not support all WebGL extensions required by regl-scatterplot',
57+
'Your browser does not support all necessary WebGL features. The scatter plot might not render properly.',
58+
true,
4859
true
4960
);
5061
}

public/index.html

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,12 @@
206206
font-size: 0.9em;
207207
}
208208

209-
.flex-c {
209+
.flex {
210210
display: flex;
211211
}
212+
.flex-col {
213+
flex-direction: column;
214+
}
212215
.flex-jc-sb {
213216
justify-content: space-between;
214217
}
@@ -460,6 +463,12 @@
460463
color: white;
461464
}
462465

466+
#modal-close {
467+
display: none;
468+
margin-top: 0.5rem;
469+
width: fit-content;
470+
}
471+
463472
#note {
464473
position: absolute;
465474
z-index: 2;
@@ -493,16 +502,19 @@
493502
</head>
494503

495504
<body>
496-
<div id="modal" class="flex-c flex-jc-c flex-a-c">
497-
<span class="no-select"></span>
505+
<div id="modal" class="flex flex-jc-c flex-a-c">
506+
<div class="flex flex-col flex-jc-c flex-a-c">
507+
<span id="modal-text" class="no-select"></span>
508+
<button id="modal-close">Okay</button>
509+
</div>
498510
</div>
499511
<header id="topbar" tabindex="0">
500-
<div id="title-wrapper" class="flex-c flex-jc-sb">
512+
<div id="title-wrapper" class="flex flex-jc-sb">
501513
<h1 id="title">Regl Scatterplot</h1>
502514
<span class="no-select">Menu</span>
503515
</div>
504-
<aside id="controls" class="flex-c flex-v">
505-
<label class="flex-c flex-v">
516+
<aside id="controls" class="flex flex-v">
517+
<label class="flex flex-v">
506518
<div class="flex-a-c no-select">
507519
<span class="label"
508520
><abbr title="Number of points">Num. PTS</abbr></span
@@ -518,7 +530,7 @@ <h1 id="title">Regl Scatterplot</h1>
518530
value="10000"
519531
/>
520532
</label>
521-
<label class="flex-c flex-v">
533+
<label class="flex flex-v">
522534
<div class="flex-a-c no-select">
523535
<span class="label"><abbr title="Point size">PT Size</abbr></span>
524536
<span id="point-size-value" class="value">5</span>
@@ -532,7 +544,7 @@ <h1 id="title">Regl Scatterplot</h1>
532544
value="5"
533545
/>
534546
</label>
535-
<label class="flex-c flex-v">
547+
<label class="flex flex-v">
536548
<div class="flex-a-c no-select">
537549
<span class="label">Opacity</span>
538550
<span id="opacity-value" class="value">1.0</span>
@@ -546,7 +558,7 @@ <h1 id="title">Regl Scatterplot</h1>
546558
value="1"
547559
/>
548560
</label>
549-
<label class="flex-c flex-a-c">
561+
<label class="flex flex-a-c">
550562
<input id="click-lasso-initiator" type="checkbox" />
551563
<span class="no-select">Click to Lasso Initiator</span>
552564
</label>

0 commit comments

Comments
 (0)