Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,9 @@ MigrationBackup/

# Client-Side Libraries
**/wwwroot/lib/

# Rider
.idea/

# vscode
.vscode/
7 changes: 7 additions & 0 deletions MermaidJS.Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidJS.Blazor.Demo", "de
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidJS.Blazor", "src\MermaidJS.Blazor\MermaidJS.Blazor.csproj", "{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidJS.Blazor.Server.Demo", "demo\MermaidJS.Blazor.Server.Demo\MermaidJS.Blazor.Server.Demo.csproj", "{887D025C-1F8D-448F-BE3D-EA57ACCDC277}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,13 +27,18 @@ Global
{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}.Release|Any CPU.Build.0 = Release|Any CPU
{887D025C-1F8D-448F-BE3D-EA57ACCDC277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{887D025C-1F8D-448F-BE3D-EA57ACCDC277}.Debug|Any CPU.Build.0 = Debug|Any CPU
{887D025C-1F8D-448F-BE3D-EA57ACCDC277}.Release|Any CPU.ActiveCfg = Release|Any CPU
{887D025C-1F8D-448F-BE3D-EA57ACCDC277}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0B00860A-AC24-499B-B4A0-24FE02E86E2D} = {4AE5947B-DF02-4073-B088-5F890A64BA9A}
{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA} = {6436A732-DC19-49E5-94A4-8D5837AD0034}
{887D025C-1F8D-448F-BE3D-EA57ACCDC277} = {4AE5947B-DF02-4073-B088-5F890A64BA9A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95FF5783-C238-4ACA-9E5E-1666FA029617}
Expand Down
10 changes: 10 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MermaidJS.Blazor\MermaidJS.Blazor.csproj" />
</ItemGroup>

</Project>
42 changes: 42 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@page
@model MermaidJS.Blazor.Server.Demo.Pages.ErrorModel

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/app.css" rel="stylesheet" />
</head>

<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>

</html>
32 changes: 32 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;

namespace MermaidJS.Blazor.Server.Demo.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
36 changes: 36 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@page "/"


<div class="wrapper">
<div>
<h3>Diagram definition</h3>
<textarea @bind="diagramDefinition"></textarea>
<button @onclick="Refresh" class="btn-primary">Refresh UI</button>
</div>
<div>
<h3>Mermaid diagram</h3>
<MermaidDiagram Definition="@diagramDefinition" OnClick="nodeId => lastClickedNode = nodeId"/>
</div>
</div>
<div>
Last clicked node: @lastClickedNode
</div>


<div>
<h3>So what is this?</h3>
<p>This is a simple Blazor Server demo using the MermaidDiagram component.</p>
<p>To allow for click events to be handled, you have to set the SecurityLevel to 'Loose' in when calling AddMermaidJs(...).</p>
</div>

@code
{
string diagramDefinition = "graph TB\n A-->B\n click A onClickMermaidNode\n click B onClickMermaidNode";
string lastClickedNode = string.Empty;


private void Refresh()
{
StateHasChanged();
}
}
15 changes: 15 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Pages/Index.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.wrapper {
display: flex;
}

.wrapper > div
{
width: 20rem;
}

.wrapper > div > textarea {
width: 20rem;
height: 8rem;
font-family: monospace;
font-size: small;
}
35 changes: 35 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@page "/"
@namespace MermaidJS.Blazor.Server.Demo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MermaidJS.Blazor.Server.Demo</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="MermaidJS.Blazor.Server.Demo.styles.css" rel="stylesheet" />
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MermaidJS.Blazor.Server.Demo
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
28 changes: 28 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17833",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MermaidJS.Blazor.Server.Demo": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
17 changes: 17 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
</div>
70 changes: 70 additions & 0 deletions demo/MermaidJS.Blazor.Server.Demo/Shared/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

.main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}

.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row a, .top-row .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.main > div {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
Loading