-
-
Notifications
You must be signed in to change notification settings - Fork 364
doc(Mermaid): Add doc for Mermaid component #4711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/BootstrapBlazor.Server/Components/Samples/Mermaids.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| @page "/mermaid" | ||
| @inject IStringLocalizer<Mermaids> Localizer | ||
|
|
||
| <h3>@Localizer["MermaidTitle"]</h3> | ||
|
|
||
| <h4>@Localizer["MermaidDescription"]</h4> | ||
|
|
||
| <PackageTips Name="BootstrapBlazor.Mermaid" /> | ||
|
|
||
| <DemoBlock Title="@Localizer["MermaidNormalTitle"]" | ||
| Introduction="@Localizer["NormalIntro"]" | ||
| Name="GroupNormal"> | ||
| @foreach (var diagram in data) | ||
| { | ||
| <Mermaid Type="diagram.Key" Direction="MermaidDirection.TB" DiagramString="@diagram.Value" | ||
| style="@(_options == diagram.Key ? "display:flex; justify-content:center;" : "display:none;")" | ||
| Title="@($"Title {diagram.Key}")" /> | ||
| } | ||
| <div class="col-12 col-sm-3 mt-3"> | ||
| <Select @bind-Value="_options" ShowLabel="true" /> | ||
| </div> | ||
| </DemoBlock> | ||
|
|
||
| <DemoBlock Title="@Localizer["MermaidStyleTitle"]" | ||
| Introduction="@Localizer["StyleTitle"]" | ||
| Name="GroupStyle"> | ||
| <Mermaid DiagramString=" | ||
| flowchart LR | ||
| A[start] --> | ||
| B{Whether the conditions are met?} | ||
| B -- yes --> C[Perform tasks 1] | ||
| B -- no --> D[Perform tasks 2] | ||
| C --> E{Condition checks} | ||
| D --> E | ||
| E -- The conditions are established --> F[Sub-processes] | ||
| F --> G[Complete the subprocess] | ||
| E -- The condition failed --> H[Error handling] | ||
| H --> I[Keep a log] | ||
| G --> J[end] | ||
| I --> J | ||
|
|
||
| style A fill:#ffe0b3,stroke:#ff9900,stroke-width:2px; | ||
| style B fill:#ffcccc,stroke:#ff0000,stroke-width:2px; | ||
| style C fill:#e6ffcc,stroke:#009933,stroke-width:2px; | ||
| style D fill:#cce6ff,stroke:#0033cc,stroke-width:2px; | ||
| style E fill:#ffccff,stroke:#9900cc,stroke-width:2px; | ||
| style F fill:#ccccff,stroke:#3300cc,stroke-width:2px; | ||
| style G fill:#b3ffff,stroke:#00cccc,stroke-width:2px; | ||
| style H fill:#ffd9b3,stroke:#ff6600,stroke-width:2px; | ||
| style I fill:#d9d9d9,stroke:#808080,stroke-width:2px; | ||
| style J fill:#ccffcc,stroke:#009900,stroke-width:2px; | ||
|
|
||
| linkStyle 0 stroke:#00cc00,stroke-width:2px; | ||
| linkStyle 1 fill:#006600,stroke:#009933,stroke-width:2px,font-size:12px; | ||
| linkStyle 2 fill:#990000,stroke:#ff3300,stroke-width:2px,font-size:12px; | ||
| linkStyle 3 stroke:#ff33cc,stroke-width:2px; | ||
| linkStyle 4 stroke:#cc33ff,stroke-width:2px; | ||
| linkStyle 5 stroke:#33ccff,stroke-width:2px; | ||
| linkStyle 6 stroke:#ff6600,stroke-width:2px,stroke-dasharray: 10,10; | ||
| linkStyle 7 stroke:#999999,stroke-width:2px; | ||
| linkStyle 8 stroke:#009900,stroke-width:2px; | ||
| linkStyle 9 stroke:#ff6600,stroke-width:2px; | ||
| "/> | ||
| </DemoBlock> | ||
|
|
||
| <AttributeTable Items="GetAttributes()" /> | ||
|
|
||
| <MethodTable Items="GetMethods()"></MethodTable> |
175 changes: 175 additions & 0 deletions
175
src/BootstrapBlazor.Server/Components/Samples/Mermaids.razor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| using System.ComponentModel; | ||
|
|
||
| namespace BootstrapBlazor.Server.Components.Samples; | ||
|
|
||
| /// <summary> | ||
| /// MermaidViews | ||
| /// </summary> | ||
| public partial class Mermaids | ||
| { | ||
| [DisplayName("类型选择")] | ||
| private MermaidType _options { set; get; } = new(); | ||
| private Dictionary<MermaidType, string> data { get; set; } = new Dictionary<MermaidType, string> | ||
| { | ||
| { MermaidType.None, | ||
| """ | ||
| flowchart LR | ||
|
|
||
| A[Hard] -->|Text| B(Round) | ||
| B --> C{Decision} | ||
| C -->|One| D[Result 1] | ||
| C -->|Two| E[Result 2] | ||
| """ | ||
| }, | ||
| { MermaidType.Flowchart, | ||
| """ | ||
| A[Start] --> B{Is it working?} | ||
| B -- Yes --> C[Keep going] | ||
| B -- No --> D[Fix it] | ||
| D --> B | ||
| """ | ||
| }, | ||
| { MermaidType.SequenceDiagram, | ||
| """ | ||
| participant Alice | ||
| participant Bob | ||
| Alice->>John: Hello John, how are you? | ||
| loop HealthCheck | ||
| John->>John: Fight against hypochondria | ||
| end | ||
| Note right of John: Rational thoughts <br/>prevail! | ||
| John-->>Alice: Great! | ||
| John->>Bob: How about you? | ||
| Bob-->>John: Jolly good! | ||
| """ | ||
| }, | ||
| { MermaidType.ClassDiagram, | ||
| """ | ||
| Class01 <|-- AveryLongClass : Cool | ||
| Class03 *-- Class04 | ||
| Class05 o-- Class06 | ||
| Class07 .. Class08 | ||
| Class09 --> C2 : Where am i? | ||
| Class09 --* C3 | ||
| Class09 --|> Class07 | ||
| Class07 : equals() | ||
| Class07 : Object[] elementData | ||
| Class01 : size() | ||
| Class01 : int chimp | ||
| Class01 : int gorilla | ||
| Class08 <--> C2: Cool label | ||
| """ | ||
| }, | ||
| { MermaidType.StateDiagram, | ||
| """ | ||
| [*] --> Still | ||
| Still --> [*] | ||
|
|
||
| Still --> Moving | ||
| Moving --> Still | ||
| Moving --> Crash | ||
| Crash --> [*] | ||
| """ | ||
| }, | ||
| { MermaidType.ErDiagram, | ||
| """ | ||
| CUSTOMER ||--o{ ORDER : places | ||
| ORDER ||--|{ LINE-ITEM : contains | ||
| CUSTOMER }|..|{ DELIVERY-ADDRESS : uses | ||
| """ | ||
| }, | ||
| { MermaidType.Journey, | ||
| """ | ||
| section Go to work | ||
| Make tea: 5: Me | ||
| Go upstairs: 3: Me | ||
| Do work: 1: Me, Cat | ||
| section Go home | ||
| Go downstairs: 5: Me | ||
| Sit down: 5: Me | ||
| """ | ||
| }, | ||
| { MermaidType.Gantt, | ||
| """ | ||
| dateFormat YYYY-MM-DD | ||
| excludes weekdays 2014-01-10 | ||
|
|
||
| section A section | ||
| Completed task :done, des1, 2014-01-06,2014-01-08 | ||
| Active task :active, des2, 2014-01-09, 3d | ||
| Future task : des3, after des2, 5d | ||
| Future task2 : des4, after des3, 5d | ||
| """ | ||
| }, | ||
| { MermaidType.Pie, | ||
| """ | ||
| "Dogs" : 386 | ||
| "Cats" : 85 | ||
| "Rats" : 15 | ||
| """ | ||
| } | ||
| }; | ||
|
|
||
| /// <summary> | ||
| /// GetAttributes | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| private AttributeItem[] GetAttributes() => | ||
| [ | ||
| new() | ||
| { | ||
| Name = "DiagramString", | ||
| Description = Localizer["DiagramString"], | ||
| Type = "string", | ||
| ValueList = " — ", | ||
| DefaultValue = " — " | ||
| }, | ||
|
|
||
| new() | ||
| { | ||
| Name = "Title", | ||
| Description = Localizer["Title"], | ||
| Type = "string", | ||
| ValueList = " — ", | ||
| DefaultValue = " — " | ||
| }, | ||
| new() | ||
| { | ||
| Name = "Direction", | ||
| Description = Localizer["Direction"], | ||
| Type = "MermaidDirection", | ||
| ValueList = "TB / BT / LR / RL", | ||
| DefaultValue = "TB" | ||
| }, | ||
| new() | ||
| { | ||
| Name = "Type", | ||
| Description = Localizer["Type"], | ||
| Type = "MermaidType", | ||
| ValueList = "None / Flowchart / SequenceDiagram / ClassDiagram / StateDiagram / ErDiagram / Journey / Gantt / Pie", | ||
| DefaultValue = "None" | ||
| } | ||
| ]; | ||
|
|
||
| /// <summary> | ||
| /// Methods | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| private MethodItem[] GetMethods() => | ||
| [ | ||
| new() | ||
| { | ||
| Name = "ExportBase64MermaidAsync", | ||
| Description = Localizer["ExportBase64Mermaid"], | ||
| Parameters = " — ", | ||
| ReturnValue = "string" | ||
| }, | ||
|
|
||
| ]; | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.