Skip to content

Commit e66d19f

Browse files
author
Tim Bannister
committed
Improve message shown for Mermaid when JS not enabled
1 parent 4c14f7f commit e66d19f

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

assets/scss/_custom.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,10 @@ figure {
752752
max-width: clamp(0vw, 95vw, 100%);
753753
max-height: calc(80vh - 8rem);
754754
}
755+
756+
figure + noscript > *{
757+
max-width: calc(max(100%, 100vw));
758+
}
755759
}
756760

757761
@media only screen and (min-width: 768px) {
@@ -774,6 +778,9 @@ figure {
774778
max-height: calc(100vh - 10rem);
775779
}
776780
}
781+
figure + noscript > * {
782+
max-width: 80%;
783+
}
777784
}
778785

779786
// Indent definition lists
@@ -806,3 +813,13 @@ dl {
806813
margin-bottom: 1em;
807814
}
808815
}
816+
817+
.no-js .mermaid {
818+
display: none;
819+
}
820+
821+
div.alert > em.javascript-required {
822+
display: inline-block;
823+
min-height: 1.5em;
824+
margin: calc(max(4em, ( 8vh + 4em ) / 2)) 0 0.25em 0;
825+
}

data/i18n/en/en.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ other = ","
8787
[input_placeholder_email_address]
8888
other = "email address"
8989

90+
[javascript_required]
91+
other = "JavaScript must be [enabled](https://www.enable-javascript.com/) to view this content"
92+
9093
[latest_release]
9194
other = "Latest Release:"
9295

layouts/partials/scripts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<script src="/js/bootstrap-4.3.1.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
44

55
{{ if .Site.Params.mermaid.enable }}
6-
<script src="/js//mermaid.min.js" crossorigin="anonymous"></script>
6+
<script src="/js/mermaid.min.js" crossorigin="anonymous"></script>
77

88
{{ end }}
99

layouts/shortcodes/mermaid.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
<figure>
12
<div class="mermaid">
23
{{.Inner}}
34
</div>
5+
</figure>
46
<!-- Hide content and error if JS is disabled. -->
57
<noscript>
6-
<style type="text/css">
7-
.mermaid { display:none; }
8-
</style>
9-
<h4>[JavaScript must be <a href="https://www.enable-javascript.com/">enabled</a> to view content]</h4>
8+
<div class="alert alert-secondary callout" role="alert">
9+
<em class="javascript-required">{{ T "javascript_required" | markdownify }}</em>
10+
</div>
1011
</noscript>

0 commit comments

Comments
 (0)