Skip to content

Commit

Permalink
Make mermaid diagram scrollable width-wise
Browse files Browse the repository at this point in the history
  • Loading branch information
acavalla committed Nov 28, 2023
1 parent fb3d08d commit 7d22efc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/mermaid_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class MermaidController < ApplicationController

Check failure on line 4 in app/controllers/mermaid_controller.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning. (https://rubystyle.guide#empty-lines-around-bodies)
end
7 changes: 5 additions & 2 deletions app/views/mermaid/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1> Driving in Great Britain on a non-GB licence</h1>
<pre class="mermaid">
<pre class="mermaid flowchart">
%%{
init: {
'theme': 'base',
Expand Down Expand Up @@ -126,8 +126,11 @@
.container{
width: 100% !important;
}
.mermaid {
background-color: white;
}
</style>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true});
mermaid.initialize({ startOnLoad: true, flowchart: { useMaxWidth: false }});
</script>
30 changes: 30 additions & 0 deletions app/views/mermaid/indexnew.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<h1> Driving in Great Britain on a non-GB licence</h1>
<pre class="mermaid">
%%{
init: {
'theme': 'base',
'themeVariables': {
'primaryColor': '#fff',
'primaryTextColor': '#0B0C0C',
'primaryBorderColor': '#0B0C0C',
'secondaryColor': '#006100',
'tertiaryColor': '#fff'
}
}
}%%
graph TD
A[Start] --- B[Q1 Are you:]
B --> C[a resident of Great Britain?]
B --> D[a visitor of Great Britain?]
B --> E[a foreign student studying in Great Britain?]
E --> F
F[Q2 What kind of driving licence do you have?]


style A fill:#006100,color:#ffffff
</pre>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true});
</script>

0 comments on commit 7d22efc

Please sign in to comment.