Skip to content

Commit

Permalink
Release 1.0.0 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
DotJoshJohnson authored Jun 25, 2021
1 parent 527ce4a commit 9fe1c34
Show file tree
Hide file tree
Showing 39 changed files with 1,658 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches:
- release/*
- refs/tags/*
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract Version Number
id: version
run: |
semver=$(echo ${{github.ref}} | rev | cut -d "/" -f 1 | rev)
if [[ "${{github.ref}}" == *"/release/"* ]]; then semver="${semver}-preview.${{github.run_number}}"; fi
echo ::set-output name=semver::$semver
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.8.0
with:
dotnet-version: "5.0"

- run: dotnet pack ./src/MermaidJS.Blazor/MermaidJS.Blazor.csproj -c Release -o ./dist -p:PackageVersion=${{steps.version.outputs.semver}}
- run: dotnet nuget push ./dist/*.nupkg -s 'https://api.nuget.org/v3/index.json' -k '${{secrets.NUGET_API_KEY}}'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Client-Side Libraries
**/wwwroot/lib/
39 changes: 39 additions & 0 deletions MermaidJS.Blazor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6436A732-DC19-49E5-94A4-8D5837AD0034}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{4AE5947B-DF02-4073-B088-5F890A64BA9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidJS.Blazor.Demo", "demo\MermaidJS.Blazor.Demo\MermaidJS.Blazor.Demo.csproj", "{0B00860A-AC24-499B-B4A0-24FE02E86E2D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidJS.Blazor", "src\MermaidJS.Blazor\MermaidJS.Blazor.csproj", "{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B00860A-AC24-499B-B4A0-24FE02E86E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B00860A-AC24-499B-B4A0-24FE02E86E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B00860A-AC24-499B-B4A0-24FE02E86E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B00860A-AC24-499B-B4A0-24FE02E86E2D}.Release|Any CPU.Build.0 = Release|Any CPU
{B5DDD653-4376-4D0F-880D-5E3E9CE4A8CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95FF5783-C238-4ACA-9E5E-1666FA029617}
EndGlobalSection
EndGlobal
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# MermaidJS.Blazor

A simple MermaidDiagram component for Blazor.

## Getting Started

* Install the `MermaidJS.Blazor` NuGet package.

```bash
> dotnet add package MermaidJS.Blazor
```

* Add `builder.Services.AddMermaidJS()` to your `Program.cs`.

```csharp
using Microsoft.Extensions.DependencyInjection;

// ... //
builder.Services.AddMermaidJS();
```

* Use the `MermaidDiagram` component in your app.

```html
@using MermaidJS.Blazor

<!-- ... -->

<MermaidDiagram Definition="@diagramDefinition" OnClick="OnClickNode" />

@code
{
string diagramDefinition = "graph TB\nA-->B";

void OnClickNode(string nodeId)
{
// TODO: do something with nodeId
}
}
```

## Handling Node Clicks

To raise node click events back to your blazor component, set your click callback to `onClickMermaidNode`:

```mermaid
graph TB
A--B
click A onClickMermaidNode
```
10 changes: 10 additions & 0 deletions demo/MermaidJS.Blazor.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>
17 changes: 17 additions & 0 deletions demo/MermaidJS.Blazor.Demo/MermaidJS.Blazor.Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.7" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>

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

</Project>
16 changes: 16 additions & 0 deletions demo/MermaidJS.Blazor.Demo/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
55 changes: 55 additions & 0 deletions demo/MermaidJS.Blazor.Demo/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@page "/fetchdata"
@inject HttpClient Http

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[] forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public string Summary { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
19 changes: 19 additions & 0 deletions demo/MermaidJS.Blazor.Demo/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@page "/"

<div style="display:flex;">
<div>
<textarea @bind="diagramDefinition"></textarea>
</div>
<div>
<MermaidDiagram Definition="@diagramDefinition" OnClick="nodeId => lastClickedNode = nodeId" />
</div>
</div>
<div>
Last clicked node: @lastClickedNode
</div>

@code
{
string diagramDefinition = string.Empty;
string lastClickedNode = string.Empty;
}
28 changes: 28 additions & 0 deletions demo/MermaidJS.Blazor.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace MermaidJS.Blazor.Demo
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddMermaidJS();

await builder.Build().RunAsync();
}
}
}
30 changes: 30 additions & 0 deletions demo/MermaidJS.Blazor.Demo/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:21051",
"sslPort": 44330
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MermaidJS.Blazor.Demo": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
17 changes: 17 additions & 0 deletions demo/MermaidJS.Blazor.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="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
</div>
Loading

0 comments on commit 9fe1c34

Please sign in to comment.