Skip to content

Commit cda5198

Browse files
committed
Improve tooltip functionality and styling
1 parent fa4e39a commit cda5198

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

src/components/OpenWithButton.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ const OpenWithButton = ({ pdes }) => {
1414
}
1515
const [showInstructions, setShowInstructions] = useState(false)
1616

17+
React.useEffect(() => {
18+
const handleClickOutside = (event) => {
19+
if (showInstructions && !event.target.closest(`.${css.root}`)) {
20+
setShowInstructions(false);
21+
}
22+
};
23+
24+
document.addEventListener('click', handleClickOutside);
25+
return () => document.removeEventListener('click', handleClickOutside);
26+
}, [showInstructions]);
27+
1728
return (
1829
<a
1930
href={sketchURL}
@@ -24,9 +35,9 @@ const OpenWithButton = ({ pdes }) => {
2435
<ProcessingIcon /> {'Open With Processing'}
2536
{showInstructions && (
2637
<div className={classnames(css.instructions)}>
27-
<p>If this did not open Processing, make sure you have it installed and opened at least once.</p>
28-
<p>Currently only versions of Processing later than 4.4 are supported</p>
29-
<a href="https://www.processing.org/download/" target="_black">Download Processing</a>
38+
<h1>Opening Processing<span className={css.ellipsis}></span></h1>
39+
<p>If nothing happens, <a href="https://www.processing.org/download/" target="_black" className={css.downloadLink}>Download Processing</a> version 4.4.1 or later and try again.</p>
40+
<p className={classnames(css.tooltipFootnote)}>Make sure Processing is installed and was opened at least once.</p>
3041
</div>
3142
)}
3243
</a>

src/components/OpenWithButton.module.css

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,66 @@
2626

2727
.instructions {
2828
bottom: 100%;
29-
margin-bottom: 10px;
30-
left: 50%;
29+
margin-bottom: 16px;
30+
left: auto;
31+
right: 0;
3132
position: absolute;
32-
transform: translateX(-50%);
33-
min-width: 16em;
33+
transform: none;
34+
min-width: 24em;
35+
max-width: 24em;
36+
width: fit-content;
3437
background-color: #555;
3538
color: #fff;
3639
text-align: left;
3740
border-radius: 6px;
38-
padding: 8px 10px 10px 25px;
41+
padding: 16px 10px 10px 25px;
3942
transition: opacity 0.3s;
43+
pointer-events: auto;
4044
a {
4145
color: var(--processing-blue-mid);
4246
}
47+
h1 {
48+
color: #fff;
49+
font-size: 2em;
50+
margin: 0 0 0.3em 0;
51+
font-weight: 500;
52+
}
4353
&::before {
4454
content: "";
4555
position: absolute;
4656
top: 100%;
47-
left: 50%;
57+
left: auto;
58+
right: 20px;
4859
margin-left: -10px;
4960
border-width: 10px;
5061
border-style: solid;
5162
border-color: #555 transparent transparent transparent;
5263
}
5364
}
65+
66+
.tooltipFootnote {
67+
color: var(--gray);
68+
font-size: 0.9em;
69+
}
70+
71+
.downloadLink {
72+
color: var(--processing-blue-light) !important;
73+
text-decoration: underline;
74+
}
75+
76+
.downloadLink:hover {
77+
color: white !important;
78+
}
79+
80+
@keyframes ellipsis {
81+
10% { content: " "; }
82+
25% { content: " . "; }
83+
50% { content: " .. "; }
84+
75% { content: " ..."; }
85+
}
86+
87+
.ellipsis::after {
88+
display: inline-block;
89+
animation: ellipsis 1.5s infinite;
90+
content: " ...";
91+
}

0 commit comments

Comments
 (0)