Skip to content

Commit

Permalink
Merge pull request #315 from Blazor-Diagrams/new-site
Browse files Browse the repository at this point in the history
3.0.0 beta 6
  • Loading branch information
zHaytam authored May 10, 2023
2 parents 2422aa8 + 02634bf commit c153569
Show file tree
Hide file tree
Showing 100 changed files with 5,054 additions and 126 deletions.
9 changes: 9 additions & 0 deletions Blazor.Diagrams.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Layouts", "docs\Layouts\Lay
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Diagrams.Tests", "tests\Blazor.Diagrams.Tests\Blazor.Diagrams.Tests.csproj", "{ED3B0D8F-F29A-4C66-A167-C36824A76902}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "site", "site", "{F1E6F4C0-3EC7-4CFF-834A-0CF207CCFF3E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Site", "site\Site\Site.csproj", "{F26307EC-C188-44BD-B3E5-960318F43C0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -91,6 +95,10 @@ Global
{ED3B0D8F-F29A-4C66-A167-C36824A76902}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED3B0D8F-F29A-4C66-A167-C36824A76902}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED3B0D8F-F29A-4C66-A167-C36824A76902}.Release|Any CPU.Build.0 = Release|Any CPU
{F26307EC-C188-44BD-B3E5-960318F43C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F26307EC-C188-44BD-B3E5-960318F43C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F26307EC-C188-44BD-B3E5-960318F43C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F26307EC-C188-44BD-B3E5-960318F43C0C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -107,6 +115,7 @@ Global
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5} = {A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}
{78C85C89-B464-4083-8829-78BA52BB4780} = {A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}
{ED3B0D8F-F29A-4C66-A167-C36824A76902} = {CEEAE4C2-CE68-4FC3-9E0F-D4781B91F7F4}
{F26307EC-C188-44BD-B3E5-960318F43C0C} = {F1E6F4C0-3EC7-4CFF-834A-0CF207CCFF3E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {969540A2-8162-4063-A4E3-B488F69BD582}
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Diagrams (3.0.0-beta.6) - 2023-05-09

### Added

- `Style` parameter to `PortRenderer`
- `TargetAttached` to links, which triggers when a dragged link attaches to a target
- If port snapping is enabled, it will trigger only once when you let go of the mouse
- `SuspendSorting` to `Diagram` in order to suspend sorting models in each `OrderChanged`
- If you know what you're doing, you could save some processing and avoid sorting everytime
- `RefreshOrders` to be called after unsuspending sorting in order to sort the models again and refresh the diagram

### Changed

- `BaseLayer.Add` now returns the specific type given to it in argument
- **[BREAKING]** CSS classes are now prefixed with `diagram-` to avoid clashes with other libraries
- `diagram-group`, `diagram-node`, `diagram-link`, `diagram-port`, `diagram-link-label`, `diagram-link-vertex`, `diagram-control`

### Fixed

- Portless links in children not refreshing when moving the parent group
- Link's `GetBounds` not returning a valid box
- Port snapping choosing the first port in radius rather than the closest one
- Remove `Console.WriteLine` from `KeyboardShortcutsBehavior`
- Diagram overwriting `Order` when it's not zero (zero being the default int value, which we now consider as not set)

## Diagrams (3.0.0-beta.5) - 2022-11-23

### Added
Expand Down
26 changes: 13 additions & 13 deletions samples/SharedDemo/wwwroot/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1550,15 +1550,15 @@ body {
max-width: 400px;
}

.custom-node.selected, .custom-node.selected .port {
.custom-node.selected, .custom-node.selected .diagram-port {
border: 1px solid #6e9fd4;
}

.custom-node:hover .port {
.custom-node:hover .diagram-port {
visibility: visible;
}

.custom-node .port {
.custom-node .diagram-port {
width: 20px;
height: 20px;
border-radius: 50%;
Expand All @@ -1568,18 +1568,18 @@ body {
visibility: hidden;
}

.custom-node .port:hover, .node > .card .port.has-links {
.custom-node .diagram-port:hover, .diagram-node > .card .diagram-port.has-links {
visibility: visible;
background-color: black;
}

.custom-node .port.bottom {
.custom-node .diagram-port.bottom {
position: absolute;
bottom: -10px;
left: 115px;
}

.custom-node .port.top {
.custom-node .diagram-port.top {
position: absolute;
top: -10px;
left: 115px;
Expand All @@ -1599,29 +1599,29 @@ body {
border-color: blue;
}

.colored-node .port {
.colored-node .diagram-port {
width: 30px;
height: 30px;
}

.colored-node .port.blue {
.colored-node .diagram-port.blue {
background-color: blue;
}

.colored-node .port.red {
.colored-node .diagram-port.red {
background-color: red;
}

.bg-primary {
background: #40babd !important;
}

div.group:not(.default) {
div.diagram-group:not(.default) {
outline: 2px solid black;
background-color: #6fbb6e;
}

div.group:not(.default) > span.title {
div.diagram-group:not(.default) > span.title {
padding: 20px;
position: absolute;
left: 50%;
Expand All @@ -1634,11 +1634,11 @@ div.group:not(.default) > span.title {
text-transform: uppercase;
}

g.group:not(.default) rect {
g.diagram-group:not(.default) rect {
outline: 2px solid black;
}

g.group:not(.default) text {
g.diagram-group:not(.default) text {
text-anchor: middle;
dominant-baseline: middle;
}
12 changes: 12 additions & 0 deletions site/Site/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(LandingLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(LandingLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
5 changes: 5 additions & 0 deletions site/Site/Components/Documentation/MyDiagram.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="diagram-container">
<CascadingValue Value="Diagram" IsFixed="true">
<DiagramCanvas></DiagramCanvas>
</CascadingValue>
</div>
51 changes: 51 additions & 0 deletions site/Site/Components/Documentation/MyDiagram.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Blazor.Diagrams;
using Blazor.Diagrams.Core.Anchors;
using Blazor.Diagrams.Core.Geometry;
using Blazor.Diagrams.Core.Models;
using Blazor.Diagrams.Core.PathGenerators;
using Blazor.Diagrams.Core.Routers;
using Blazor.Diagrams.Options;

namespace Site.Components.Documentation;

public partial class MyDiagram
{
private BlazorDiagram Diagram { get; set; } = null!;

protected override void OnInitialized()
{
var options = new BlazorDiagramOptions
{
AllowMultiSelection = true,
Zoom =
{
Enabled = false,
},
Links =
{
DefaultRouter = new NormalRouter(),
DefaultPathGenerator = new SmoothPathGenerator()
},
};

Diagram = new BlazorDiagram(options);

var firstNode = Diagram.Nodes.Add(new NodeModel(position: new Point(50, 50))
{
Title = "Node 1"
});
var secondNode = Diagram.Nodes.Add(new NodeModel(position: new Point(200, 100))
{
Title = "Node 2"
});
var leftPort = secondNode.AddPort(PortAlignment.Left);
var rightPort = secondNode.AddPort(PortAlignment.Right);

// The connection point will be the intersection of
// a line going from the target to the center of the source
var sourceAnchor = new ShapeIntersectionAnchor(firstNode);
// The connection point will be the port's position
var targetAnchor = new SinglePortAnchor(leftPort);
var link = Diagram.Links.Add(new LinkModel(sourceAnchor, targetAnchor));
}
}
5 changes: 5 additions & 0 deletions site/Site/Components/Documentation/MyDiagram.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.diagram-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
33 changes: 33 additions & 0 deletions site/Site/Components/Documentation/NavigationButtons.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="mt-10 mb-6 text-slate-700 font-semibold flex items-center">

@if (PreviousTitle != null)
{
<a href="@PreviousLink" class="bg-gray-700 text-white rounded-l-md border-r border-gray-100 py-2 hover:bg-palette-main hover:text-white px-3">
<div class="flex flex-row align-middle">
<svg class="w-5 mr-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" clip-rule="evenodd"></path>
</svg>
<span class="ml-2">@PreviousTitle</span>
</div>
</a>
}

@if (NextTitle != null)
{
<a href="@NextLink" class="ml-auto bg-gray-700 text-white rounded-r-md py-2 border-l border-gray-100 py-2 hover:bg-palette-main hover:text-white px-3">
<div class="flex flex-row align-middle">
<span class="mr-2">@NextTitle</span>
<svg class="w-5 ml-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path>
</svg>
</div>
</a>
}
</div>

@code {
[Parameter] public string? PreviousTitle { get; set; }
[Parameter] public string? PreviousLink { get; set; }
[Parameter] public string? NextTitle { get; set; }
[Parameter] public string? NextLink { get; set; }
}
71 changes: 71 additions & 0 deletions site/Site/Components/Footer.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<footer class="bg-white">
<div class="container mx-auto px-8">
<div class="w-full flex flex-col md:flex-row py-6">
<div class="flex-1 mb-6 text-black">
<a class="text-pink-600 no-underline hover:no-underline font-bold text-2xl lg:text-4xl" href="#">
<!--Icon from: http://www.potlabicons.com/ -->
<svg class="h-8 fill-current inline" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512.005 512.005">
<rect fill="#2a2a31" x="16.539" y="425.626" width="479.767" height="50.502" transform="matrix(1,0,0,1,0,0)" />
<path class="plane-take-off"
d=" M 510.7 189.151 C 505.271 168.95 484.565 156.956 464.365 162.385 L 330.156 198.367 L 155.924 35.878 L 107.19 49.008 L 211.729 230.183 L 86.232 263.767 L 36.614 224.754 L 0 234.603 L 45.957 314.27 L 65.274 347.727 L 105.802 336.869 L 240.011 300.886 L 349.726 271.469 L 483.935 235.486 C 504.134 230.057 516.129 209.352 510.7 189.151 Z " />
</svg>
LANDING
</a>
</div>
<div class="flex-1">
<p class="uppercase text-gray-500 md:mb-6">Links</p>
<ul class="list-reset mb-6">
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">FAQ</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Help</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Support</a>
</li>
</ul>
</div>
<div class="flex-1">
<p class="uppercase text-gray-500 md:mb-6">Legal</p>
<ul class="list-reset mb-6">
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Terms</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Privacy</a>
</li>
</ul>
</div>
<div class="flex-1">
<p class="uppercase text-gray-500 md:mb-6">Social</p>
<ul class="list-reset mb-6">
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Facebook</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Linkedin</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Twitter</a>
</li>
</ul>
</div>
<div class="flex-1">
<p class="uppercase text-gray-500 md:mb-6">Company</p>
<ul class="list-reset mb-6">
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Official Blog</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">About Us</a>
</li>
<li class="mt-2 inline-block mr-2 md:block md:mr-0">
<a href="#" class="no-underline hover:underline text-gray-800 hover:text-pink-500">Contact</a>
</li>
</ul>
</div>
</div>
</div>
<a href="https://www.freepik.com/free-photos-vectors/background" class="text-gray-500">Background vector created by freepik - www.freepik.com</a>
</footer>
27 changes: 27 additions & 0 deletions site/Site/Components/Landing/AddNodeWidget.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="drop-shadow-lg bg-white border">
<div class="bg-main p-2 pr-6 font-semibold text-white uppercase">
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" class="inline">
<path d="M11.883 3.007 12 3a1 1 0 0 1 .993.883L13 4v7h7a1 1 0 0 1 .993.883L21 12a1 1 0 0 1-.883.993L20 13h-7v7a1 1 0 0 1-.883.993L12 21a1 1 0 0 1-.993-.883L11 20v-7H4a1 1 0 0 1-.993-.883L3 12a1 1 0 0 1 .883-.993L4 11h7V4a1 1 0 0 1 .883-.993L12 3l-.117.007Z" fill="#ffffff"/>
</svg>
Add
</div>
<div class="py-4 px-8 relative">
@Node.Value
<PortRenderer Port="@Node.Ports[0]"
Class="rounded-full bg-main p-2 absolute"
Style="left: -8px; top: 33%; transform: translateY(-50%);"/>
<PortRenderer Port="@Node.Ports[1]"
Class="rounded-full bg-main p-2 absolute"
Style="left: -8px; top: 66%; transform: translateY(-50%);"/>
<PortRenderer Port="@Node.Ports[2]"
Class="rounded-full bg-main p-2 absolute"
Style="right: -8px; top: 50%; transform: translateY(-50%);"/>
</div>
</div>

@code {

[Parameter]
public AddNodeModel Node { get; set; } = null!;

}
27 changes: 27 additions & 0 deletions site/Site/Components/Landing/ColoredNodeWidget.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using System.Text;
@using Blazor.Diagrams.Extensions;
@{
var borderColor = Node.Selected ? $"outline-{Node.Color}-darker" : $"outline-{Node.Color}";
var extraClasses = new StringBuilder().Append($"bg-{Node.Color}").AppendIf(" rounded-full", Node.Round);
}

<div class="drop-shadow-lg @borderColor flex items-center justify-center font-bold @extraClasses" style="width: @(Node.Round ? 80 : 120)px; height: @(Node.Round ? 80 : 60)px;">
@Node.Title

@foreach (var port in Node.Ports)
{
var classes = new StringBuilder("absolute -translate-y-1/2 ")
.Append(extraClasses)
.AppendIf(" top-1/2 -right-3", port.Alignment == PortAlignment.Right)
.AppendIf(" top-1/2 -left-3", port.Alignment == PortAlignment.Left);

<PortRenderer Port="port" Class="@classes.ToString()" Style="width: 10px; height: 10px;" />
}
</div>

@code {

[Parameter]
public ColoredNodeModel Node { get; set; } = null!;

}
Loading

0 comments on commit c153569

Please sign in to comment.