Skip to content

Commit e7756e5

Browse files
committed
add project files.
1 parent b2e95df commit e7756e5

42 files changed

Lines changed: 1988 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/blank.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: publish to nuget
2+
on:
3+
push:
4+
branches:
5+
- master # Your default release branch
6+
jobs:
7+
publish:
8+
name: list on nuget
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
# Required for a specific dotnet version that doesn't come with ubuntu-latest / windows-latest
14+
# Visit bit.ly/2synnZl to see the list of SDKs that are pre-installed with ubuntu-latest / windows-latest
15+
# - name: Setup dotnet
16+
# uses: actions/setup-dotnet@v1
17+
# with:
18+
# dotnet-version: 3.1.100
19+
20+
# Publish
21+
- name: publish on version change
22+
uses: rohith/publish-nuget@v2
23+
with:
24+
PROJECT_FILE_PATH: src/BlazorTextDiff.csproj # Relative to repository root
25+
# VERSION_FILE_PATH: Directory.Build.props # Filepath with version info, relative to repository root. Defaults to project file
26+
# VERSION_REGEX: <Version>(.*)<\/Version> # Regex pattern to extract version info in a capturing group
27+
# TAG_COMMIT: true # Flag to enable / disalge git tagging
28+
# TAG_FORMAT: v* # Format of the git tag, [*] gets replaced with version
29+
NUGET_KEY: ${{ secrets.NUGET_API_KEY }} # nuget.org API key

BlazorTextDiff.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29613.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorTextDiff", "src\BlazorTextDiff.csproj", "{BD68CFEA-CA90-4513-9B45-F56891BB82CD}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorTextDiff.Web", "samples\BlazorTextDiff.Web\BlazorTextDiff.Web.csproj", "{6AEC9F46-B137-48E0-BC43-C62E339B5483}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{BD68CFEA-CA90-4513-9B45-F56891BB82CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{BD68CFEA-CA90-4513-9B45-F56891BB82CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{BD68CFEA-CA90-4513-9B45-F56891BB82CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{BD68CFEA-CA90-4513-9B45-F56891BB82CD}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{6AEC9F46-B137-48E0-BC43-C62E339B5483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{6AEC9F46-B137-48E0-BC43-C62E339B5483}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{6AEC9F46-B137-48E0-BC43-C62E339B5483}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{6AEC9F46-B137-48E0-BC43-C62E339B5483}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {7B508BCF-52CC-4CB1-9F82-F85A4CDC4A16}
30+
EndGlobalSection
31+
EndGlobal

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Blazor Text Diff
2+
A component to display side by side text diff using the [DiffPlex](https://github.com/mmanela/diffplex) library. The CSS can probably be cleaned up a lot.
3+
4+
5+
[![publish to nuget](https://github.com/lzinga/BlazorTextDiff/workflows/publish%20to%20nuget/badge.svg)![Nuget](https://img.shields.io/nuget/v/BlazorTextDiff)](https://www.nuget.org/packages/BlazorTextDiff)
6+
7+
8+
9+
Here is an image showing some example data from the sample folder.
10+
![Diff](https://i.imgur.com/nfo1OzH.png)
11+
12+
# Installation
13+
You will need to add the nuget package DiffPlex into your project for this to work. An example project can be found in the [Samples Folder](https://github.com/lzinga/BlazorTextDiff/tree/master/samples/BlazorTextDiff.Web) for implementation.
14+
15+
```csharp
16+
// Program.cs
17+
public static async Task Main(string[] args)
18+
{
19+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
20+
21+
// These must be injected into your application to supply the component with its diff checking.
22+
builder.Services.AddScoped<ISideBySideDiffBuilder, SideBySideDiffBuilder>();
23+
builder.Services.AddScoped<IDiffer, Differ>();
24+
25+
builder.RootComponents.Add<App>("app");
26+
27+
await builder.Build().RunAsync();
28+
}
29+
```
30+
31+
```html
32+
<!-- Index.html -->
33+
<link href="_content/BlazorTextDiff/css/BlazorDiff.css" rel="stylesheet" />
34+
<script src="_content/BlazorTextDiff/js/BlazorTextDiff.js"></script>
35+
```
36+
37+
38+
# Usage
39+
```html
40+
<TextDiff
41+
42+
<!-- The left side of the comparison -->
43+
OldText="Old Text"
44+
45+
<!-- The right side of the comparison -->
46+
NewText="New Text"
47+
48+
<!-- Determines if the div containing the diffs should be collapsed if there is a lot of data. -->
49+
<!-- There is currently an issue where the toggling doesn't work accurately with the js interop. -->
50+
CollapseContent="true"
51+
52+
<!-- Converts space values into \u00B7 and tab values into \u00B7\u00B7 -->
53+
ShowWhiteSpace="true"
54+
55+
>
56+
<Header>
57+
<!-- Context Variables -->
58+
<!-- @context.Additions -->
59+
<!-- @context.Modifications -->
60+
<!-- @context.Deletions -->
61+
</Header>
62+
</TextDiff>
63+
```

docs/.nojekyll

Whitespace-only changes.

docs/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Pages
2+
Eventually I want to get the github pages working so I can place one of the sample pages here so users can view the component live.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.2.0-preview1.20073.1" />
10+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\src\BlazorTextDiff.csproj" />
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/counter"
2+
3+
<h1>Counter</h1>
4+
5+
<p>Current count: @currentCount</p>
6+
7+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
8+
9+
@code {
10+
private int currentCount = 0;
11+
12+
private void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page "/fetchdata"
2+
@inject HttpClient Http
3+
4+
<h1>Weather forecast</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
@if (forecasts == null)
9+
{
10+
<p><em>Loading...</em></p>
11+
}
12+
else
13+
{
14+
<table class="table">
15+
<thead>
16+
<tr>
17+
<th>Date</th>
18+
<th>Temp. (C)</th>
19+
<th>Temp. (F)</th>
20+
<th>Summary</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
@foreach (var forecast in forecasts)
25+
{
26+
<tr>
27+
<td>@forecast.Date.ToShortDateString()</td>
28+
<td>@forecast.TemperatureC</td>
29+
<td>@forecast.TemperatureF</td>
30+
<td>@forecast.Summary</td>
31+
</tr>
32+
}
33+
</tbody>
34+
</table>
35+
}
36+
37+
@code {
38+
private WeatherForecast[] forecasts;
39+
40+
protected override async Task OnInitializedAsync()
41+
{
42+
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43+
}
44+
45+
public class WeatherForecast
46+
{
47+
public DateTime Date { get; set; }
48+
49+
public int TemperatureC { get; set; }
50+
51+
public string Summary { get; set; }
52+
53+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54+
}
55+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@page "/"
2+
@inject HttpClient Http
3+
4+
5+
<h1>Static</h1>
6+
<TextDiff OldText="Old Text" NewText="New Text" CollapseContent="@collapsible">
7+
<Header>
8+
<h6 style="padding: 12px; margin: 0px;">Test</h6>
9+
</Header>
10+
</TextDiff>
11+
<br />
12+
<h1>Async</h1>
13+
<TextDiff OldText="@left" NewText="@right" CollapseContent="@collapsible">
14+
<Header>
15+
<h6 style="padding: 12px; margin: 0px;">@context.Additions Additions @context.Modifications Modifications and @context.Deletions Deletions</h6>
16+
<button type="button" @onclick="@(() => collapsible = !collapsible)">Toggle Collapse</button>
17+
</Header>
18+
</TextDiff>
19+
20+
@code {
21+
22+
23+
string left = "";
24+
string right = "";
25+
bool collapsible = true;
26+
27+
28+
protected override async Task OnInitializedAsync()
29+
{
30+
left = await Http.GetStringAsync("https://raw.githubusercontent.com/lzinga/TTTWeightedTraitorSelection/fe20c3e645aaa20e40cecc615037d51a34f9cb4a/README.md");
31+
right = await Http.GetStringAsync("https://raw.githubusercontent.com/lzinga/TTTWeightedTraitorSelection/c763193e8a5bddfbec097c7b96ea0f875eedb01b/README.md");
32+
}
33+
}

0 commit comments

Comments
 (0)