Skip to content

Commit 11be56d

Browse files
committed
Add external link icon. (#136)
1 parent c515425 commit 11be56d

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

default/templates/base.tpl

+27-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,33 @@
2323
</ema:metadata>
2424
<tailwindCssShim />
2525

26-
<!-- Heist error element -->
27-
<style>
26+
<style type="text/css">
27+
/* Heist error element */
2828
strong.error {
2929
color: lightcoral;
3030
font-size: 90%;
3131
font-family: monospace;
3232
}
33+
34+
/* External link icon (see https://stackoverflow.com/a/66093928/5603549)*/
35+
a.emanote-external:not(.emanote-contains-image)::after
36+
{
37+
background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='rgb(156, 163, 175)' %3E%3Cpath d='M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z' /%3E%3Cpath d='M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z' /%3E%3C/svg%3E") 0 0 no-repeat;
38+
background-size: 100% 100%;
39+
display: inline-block;
40+
height: 1em;
41+
width: 1em;
42+
content: '';
43+
}
44+
a.emanote-external:not(.emanote-contains-image):hover::after
45+
{
46+
background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='rgba(75, 85, 99)' %3E%3Cpath d='M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z' /%3E%3Cpath d='M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z' /%3E%3C/svg%3E") 0 0 no-repeat;
47+
background-size: 100% 100%;
48+
display: inline-block;
49+
height: 1em;
50+
width: 1em;
51+
content: '';
52+
}
3353
</style>
3454
<apply template="/templates/hooks/more-head" />
3555

@@ -44,6 +64,10 @@
4464

4565
<body class="${bodyClass}">
4666
<body-main />
67+
68+
<script type="text/javascript">
69+
document.querySelectorAll('a.emanote-external').forEach(x => {if (x.querySelector('img')){ x.classList.add('emanote-contains-image');}} );
70+
</script>
4771
</body>
4872

49-
</html>
73+
</html>

0 commit comments

Comments
 (0)