Skip to content

Commit

Permalink
personnalisation couleurs mermaid (refs #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
slafayIGN committed Apr 23, 2024
1 parent 2162572 commit f33959d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
4 changes: 1 addition & 3 deletions _includes/layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

{% if mermaid %}
<script src="/js/mermaid.min.js"></script>
<script>
mermaid.initialize({ startOnLoad: true});
</script>
<script src="/js/mermaid.initialize.js"></script>
{% endif %}

<title>{{ title or metadata.title }}</title>
Expand Down
32 changes: 29 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions public/js/mermaid.initialize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Apply dark mode to mermaid graphs when needed. Only activated on page load.
var mermaidDarkMode = false;
if(localStorage.getItem("scheme")){
if(localStorage.getItem("scheme") == "dark"){
mermaidDarkMode = true;
}
} else if(!window.matchMedia) {
//matchMedia method not supported, nothing to do
} else if(window.matchMedia("(prefers-color-scheme: dark)").matches) {
//OS theme setting detected as dark
mermaidDarkMode = true;
}

mermaid.initialize({
startOnLoad: true,
theme: 'base',
themeVariables: {
background: '#fff',
darkMode: mermaidDarkMode,
fontFamily: 'Marianne,arial,sans-serif',
fontSize: '16px',
textColor: mermaidDarkMode ? '#fff' : '#000',
arrowheadColor : mermaidDarkMode ? '#fff' : '#000',
lineColor : mermaidDarkMode ? '#fff' : '#000',
noteBkgColor: '#eee', // grey-950
primaryColor: '#6a6af4', // blue-france-main-525
primaryTextColor: '#fff',
primaryBorderColor: '#000091', // blue-france-sun-113
secondaryColor: mermaidDarkMode ? '#1b1b35' : '#cacafb', // blue-france-850 //
tertiaryColor: '#fff'
}
});

0 comments on commit f33959d

Please sign in to comment.