Files
mermaid/cypress/platform/refactor.html
2024-08-21 16:27:55 +02:00

308 lines
7.7 KiB
HTML

<html>
<head>
<script src="//unpkg.com/alpinejs" defer></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
rel="stylesheet"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
rel="stylesheet"
/>
<style>
body {
font-family: 'Arial';
}
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th,
td {
border: 1px solid black;
padding: 10px;
text-align: center;
vertical-align: middle;
}
.separator {
height: 20px;
background-color: #f0f0f0;
}
.vertical-header {
text-align: center;
}
.collapsible {
background-color: #f9f9f9;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
}
.active,
.collapsible:hover {
background-color: #ccc;
}
.collapsible:after {
content: '\002B';
color: #777;
font-weight: bold;
float: right;
margin-left: 2px;
}
.active:after {
content: '\2212';
}
.content {
padding: 0 5px;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
background-color: #f1f1f1;
}
.content .pre-scrollable {
max-height: 200px;
overflow-y: scroll;
}
</style>
</head>
<body>
<script>
const data = {
shapes: [
{
descr: 'Stadium shape',
code: `
flowchart LR
id1([This is the text in the box])
`,
},
{
descr: 'Sub-Routine shape',
code: `
flowchart LR
id1[[This is the text in the box]]
`,
},
{
descr: 'Cylindrical shape',
code: `
flowchart LR
id1[(Database)]
`,
},
{
descr: 'Circle shape',
code: `
flowchart LR
id1((Circle))
`,
},
{
descr: 'Double Circle shape',
code: `
flowchart LR
id1(((Circle)))
`,
},
{
descr: 'Asymmetric shape',
code: `
flowchart LR
id1>This is the text in the box]
`,
},
{
descr: 'Rhombus/Diamond/Question shape',
code: `
flowchart LR
id1{This is the text in the box}
`,
},
{
descr: 'Hexagon shape',
code: `
flowchart LR
id1{{This is the text in the box}}
`,
},
{
descr: 'Parallelogram shape',
code: `
flowchart TD
id1[/This is the text in the box/]
`,
},
{
descr: 'Parallelogram Alt shape',
code: `
flowchart TD
id1[\This is the text in the box\]
`,
},
{
descr: 'Trapezoid shape',
code: `
flowchart TD
A[/Christmas\\]
`,
},
{
descr: 'Trapezoid Alt shape',
code: `
flowchart TD
id1[\\This is the text in the box\\]
`,
},
{
descr: 'Rect with rounded corner',
code: `
flowchart LR
id1(This is the text in the box)
`,
},
{
descr: 'Rect with sharp corner',
code: `
flowchart LR
id1[This is the text in the box]
`,
},
],
looks: ['classic', 'handdrawn', 'neo'],
// looks: ['classic'],
layouts: ['elk', 'dagre'],
// layouts: ['elk'],
themes: ['default', 'neo'],
// themes: ['default'],
};
function generateMermaidCode(layout, look, theme, shape) {
return `---
config:
layout: ${layout}
look: ${look}
theme: ${theme}
---
${shape.code}
`;
}
</script>
<table x-data="data">
<tr>
<th></th>
<template x-for="layout in layouts">
<template x-for="look in looks">
<template x-for="theme in themes">
<th x-text="layout + '-' + look + '-' + theme "></th>
</template>
</template>
</template>
</tr>
<template x-for="shape in shapes">
<tr>
<th class="vertical-header">
<button class="collapsible" x-text="shape.descr">Sub-Routine shape</button>
<div class="content">
<div class="pre-scrollable">
<pre x-text="shape.code"></pre>
</div>
</div>
</th>
<template x-for="layout in layouts">
<template x-for="look in looks">
<template x-for="theme in themes">
<td>
<pre
id="diagram6"
class="mermaid"
x-text="generateMermaidCode(layout, look, theme, shape)"
></pre>
</td>
</template>
</template>
</template>
</tr>
</template>
</table>
<script type="module">
import mermaid from './mermaid.esm.mjs';
import layouts from './mermaid-layout-elk.esm.mjs';
mermaid.registerLayoutLoaders(layouts);
mermaid.parseError = function (err, hash) {};
mermaid.initialize({
handdrawn: false,
mergeEdges: true,
layout: 'dagre',
flowchart: { titleTopMargin: 10 },
// fontFamily: 'Caveat',
fontFamily: 'Kalam',
sequence: {
actorFontFamily: 'courier',
noteFontFamily: 'courier',
messageFontFamily: 'courier',
},
fontSize: 16,
logLevel: 0,
});
function callback() {
alert('It worked');
}
mermaid.parseError = function (err, hash) {
console.error('In parse error:');
console.error(err);
};
let coll = document.getElementsByClassName('collapsible');
for (const element of coll) {
element.addEventListener('click', function () {
this.classList.toggle('active');
let content = this.nextElementSibling;
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + 'px';
}
});
}
</script>
</body>
</html>