Skip to content

Commit 91c312d

Browse files
committed
First release 1.0.0
1 parent f6bc64e commit 91c312d

Some content is hidden

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

65 files changed

+1261
-679
lines changed

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Vladimir Samoilenko
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# React#
2+
3+
## ReactSharp - A C# library for building web user interfaces
4+
[![NuGet](https://img.shields.io/nuget/v/ReactSharp.svg)](https://www.nuget.org/packages/ReactSharp.Blazor/)
5+
[![Gitter](https://badges.gitter.im/ReactSharp/community.svg)](https://gitter.im/MatBlazor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6+
[![GitHub Stars](https://img.shields.io/github/stars/SamProf/ReactSharp.svg)](https://github.com/SamProf/ReactSharp/stargazers)
7+
[![GitHub Issues](https://img.shields.io/github/issues/SamProf/ReactSharp.svg)](https://github.com/SamProf/ReactSharp/issues)
8+
[![Live Demo](https://img.shields.io/badge/demo-online-green.svg)](https://reactsharp.samprof.com)
9+
[![MIT](https://img.shields.io/github/license/SamProf/ReactSharp.svg)](LICENSE)
10+
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XT68N2VKWTPE&source=url)
11+
[![Patreon](https://img.shields.io/badge/Patreon-donation-blue)](https://www.patreon.com/SamProf)
12+
13+
14+
## Demo and Documentation
15+
- [http://reactsharp.samprof.com](http://reactsharp.samprof.com)
16+
17+
18+
## Examples
19+
20+
### Counter.cs
21+
```csharp
22+
public class Counter : ReactComponent
23+
{
24+
private int value = 0;
25+
26+
void Increment()
27+
{
28+
SetState(() => { value++; });
29+
}
30+
31+
void Decrement()
32+
{
33+
SetState(() => { value--; });
34+
}
35+
36+
37+
public override object Render()
38+
{
39+
return new ReactElement($@"
40+
<div>
41+
<h4>Counter value: {value}</h4>
42+
<p>
43+
<button type='button' class='btn btn-primary' onclick='{new Action(Increment)}'>Increment</button>
44+
<button type='button' class='btn btn-primary' onclick='{new Action((Decrement))}'>Decrement</button>
45+
</p>
46+
</div>
47+
");
48+
}
49+
}
50+
```
51+
52+
### App.cs
53+
```csharp
54+
public class App : ReactComponent
55+
{
56+
public override object Render()
57+
{
58+
return new ReactElement($@"
59+
<Fragment>
60+
61+
<p style='padding-top: 20px;'>
62+
<Counter />
63+
</p>
64+
65+
</Fragment>
66+
");
67+
}
68+
}
69+
```
70+
71+
72+
### Index.razor
73+
74+
```html
75+
<ReactSharpBlazor Prerender="true" Element="@_reactElement"></ReactSharpBlazor>
76+
77+
@code
78+
{
79+
ReactElement _reactElement = new ReactElement($@"<App/>");
80+
}
81+
```
82+
83+
84+
### Todo.cs [In action](http://reactsharp.samprof.com/Todo)
85+
```csharp
86+
public class Todo : ReactComponent
87+
{
88+
List<string> items = Enumerable.Range(0, 10).Select(i => i.ToString()).ToList();
89+
90+
91+
void Add()
92+
{
93+
SetState(() => { this.items.Add(Guid.NewGuid().ToString()); });
94+
}
95+
96+
97+
void Remove(string item)
98+
{
99+
SetState(() => { this.items.Remove(item); });
100+
}
101+
102+
103+
public override object Render()
104+
{
105+
return new ReactElement($@"
106+
<div>
107+
<h4>Todo: {items.Count}</h4>
108+
<p>
109+
<button type='button' class='btn btn-primary' onclick='{new Action((Add))}'>Add item</button>
110+
</p>
111+
{items.Select(i => new ReactElement($"<div>Task - {i} <button onclick='{new Action(() => Remove(i))}'>X</button></div>"))}
112+
113+
</div>
114+
");
115+
}
116+
}
117+
```
118+
119+
120+
121+
122+
123+
## News
124+
125+
### ReactSharp 1.0.0
126+
- First public release
127+
128+
129+
## Prerequisites
130+
131+
Don't know what Blazor is? Read [here](https://github.com/aspnet/Blazor)
132+
133+
Complete all Blazor dependencies.
134+
135+
- .NET Core 3.1
136+
- Visual Studio 2019 with the ASP.NET and web development workload selected.
137+
138+
## Installation
139+
140+
Latest version in here: [![NuGet](https://img.shields.io/nuget/v/ReactSharp.Blazor.svg)](https://www.nuget.org/packages/ReactSharp.Blazor/)
141+
142+
143+
To Install
144+
145+
```
146+
Install-Package ReactSharp
147+
Install-Package ReactSharp.Blazor
148+
```
149+
150+
For client-side and server-side Blazor - add script section to index.html or _Host.cshtml (head section)
151+
152+
```html
153+
<script src="_content/ReactSharp.Blazor/react-sharp.js"></script>
154+
```
155+
156+
157+
## Questions
158+
159+
For *how-to* questions and other non-issues, for now you can use issues or you can use [![Gitter](https://badges.gitter.im/MatBlazor/community.svg)](https://gitter.im/MatBlazor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge).
160+
161+
162+
## Contributing
163+
We'd greatly appreciate any contribution you make. :)
164+
165+
## Sponsors & Backers
166+
ReactSharp does not run under the umbrella of any company or anything like that.
167+
It is an independent project created in spare time.
168+
169+
If you think that this project helped you or your company in any way, you can consider becoming a backer/sponsor.
170+
- [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XT68N2VKWTPE&source=url)
171+
- [Patreon](https://www.patreon.com/SamProf)
172+
173+
174+
175+
## License
176+
177+
This project is licensed under the terms of the [MIT license](LICENSE).
178+
179+
## Thank you
180+
- [Blazor](https://blazor.net)
181+
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Router AppAssembly="@typeof(Program).Assembly">
22
<Found Context="routeData">
3-
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
44
</Found>
55
<NotFound>
66
<LayoutView Layout="@typeof(MainLayout)">
77
<p>Sorry, there's nothing at this address.</p>
88
</LayoutView>
99
</NotFound>
10-
</Router>
10+
</Router>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/"
2+
3+
<ReactSharpBlazor Prerender="true" Element="@_reactElement"></ReactSharpBlazor>
4+
5+
@code
6+
{
7+
ReactElement _reactElement = new ReactElement($@"<App/>");
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/Todo"
2+
3+
<ReactSharpBlazor Prerender="true" Element="@_reactElement"></ReactSharpBlazor>
4+
5+
@code
6+
{
7+
ReactElement _reactElement = new ReactElement($@"<Todo/>");
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@page "/"
2+
@namespace ReactSharp.Blazor.Demo.ServerApp.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@{
5+
Layout = null;
6+
}
7+
8+
<!DOCTYPE html>
9+
<html lang="en">
10+
<head>
11+
<meta charset="utf-8" />
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
13+
<title>ReactSharp - A C# library for building web user interfaces</title>
14+
<base href="~/" />
15+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
16+
<link href="css/site.css" rel="stylesheet" />
17+
<script src="_content/ReactSharp.Blazor/react-sharp.js"></script>
18+
</head>
19+
<body>
20+
<app>
21+
<component type="typeof(App)" render-mode="ServerPrerendered" />
22+
</app>
23+
24+
<div id="blazor-error-ui">
25+
<environment include="Staging,Production">
26+
An error has occurred. This application may no longer respond until reloaded.
27+
</environment>
28+
<environment include="Development">
29+
An unhandled exception has occurred. See browser dev tools for details.
30+
</environment>
31+
<a href="" class="reload">Reload</a>
32+
<a class="dismiss">🗙</a>
33+
</div>
34+
35+
<script src="_framework/blazor.server.js"></script>
36+
</body>
37+
</html>

Diff for: ReactSharp/ReactSharp.Demo.ServerApp/Program.cs renamed to ReactSharp/ReactSharp.Blazor.Demo.ServerApp/Program.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Microsoft.Extensions.Hosting;
1010
using Microsoft.Extensions.Logging;
1111

12-
namespace ReactSharp.Demo.ServerApp
12+
namespace ReactSharp.Blazor.Demo.ServerApp
1313
{
1414
public class Program
1515
{
@@ -20,6 +20,9 @@ public static void Main(string[] args)
2020

2121
public static IHostBuilder CreateHostBuilder(string[] args) =>
2222
Host.CreateDefaultBuilder(args)
23-
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
23+
.ConfigureWebHostDefaults(webBuilder =>
24+
{
25+
webBuilder.UseStartup<Startup>();
26+
});
2427
}
25-
}
28+
}

Diff for: ReactSharp/ReactSharp.Demo.ServerApp/Properties/launchSettings.json renamed to ReactSharp/ReactSharp.Blazor.Demo.ServerApp/Properties/launchSettings.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
"windowsAuthentication": false,
44
"anonymousAuthentication": true,
55
"iisExpress": {
6-
"applicationUrl": "http://localhost:63081",
7-
"sslPort": 44324
6+
"applicationUrl": "http://localhost:62646",
7+
"sslPort": 44378
88
}
99
},
1010
"profiles": {
1111
"IIS Express": {
1212
"commandName": "IISExpress",
13+
"launchUrl": "Todo",
1314
"launchBrowser": true,
1415
"environmentVariables": {
1516
"ASPNETCORE_ENVIRONMENT": "Development"
1617
}
1718
},
18-
"ReactSharp.Demo.ServerApp": {
19+
"ReactSharp.Blazor.Demo.ServerApp": {
1920
"commandName": "Project",
2021
"launchBrowser": true,
2122
"applicationUrl": "https://localhost:5001;http://localhost:5000",

Diff for: ReactSharp/ReactSharp.Demo.ServerApp/ReactSharp.Demo.ServerApp.csproj renamed to ReactSharp/ReactSharp.Blazor.Demo.ServerApp/ReactSharp.Blazor.Demo.ServerApp.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<ItemGroup>
88
<ProjectReference Include="..\ReactSharp.Blazor\ReactSharp.Blazor.csproj" />
9+
<ProjectReference Include="..\ReactSharp.Demo\ReactSharp.Demo.csproj" />
910
<ProjectReference Include="..\ReactSharp\ReactSharp.csproj" />
1011
</ItemGroup>
1112

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@inherits LayoutComponentBase
2+
3+
<header>
4+
<div class="navbar navbar-dark bg-dark shadow-sm">
5+
<div class="container">
6+
<a href="#" class="navbar-brand d-flex align-items-center">
7+
<strong>React #</strong>
8+
</a>
9+
<a href="/Todo" class="navbar-brand d-flex align-items-center">
10+
<strong>Todo example</strong>
11+
</a>
12+
13+
<a href="https://github.com/SamProf/ReactSharp" target="_blank" class="navbar-brand d-flex align-items-center">
14+
<strong>GitHub</strong>
15+
</a>
16+
17+
<a href="https://twitter.com/SamProf" target="_blank" class="navbar-brand d-flex align-items-center">
18+
<strong>@@SamProf</strong>
19+
</a>
20+
</div>
21+
</div>
22+
</header>
23+
24+
<main role="main">
25+
26+
<section class="jumbotron text-center">
27+
<div class="container">
28+
<img src="/logo.png" alt="React #"/>
29+
<p class="lead text-muted">ReactSharp - A C# library for building web user interfaces</p>
30+
<p class="lead text-muted">React alternative to Blazor</p>
31+
<p class="lead text-muted">Super Experimental</p>
32+
@* <p> *@
33+
@* <a href="#" class="btn btn-primary my-2">Main call to action</a> *@
34+
@* <a href="#" class="btn btn-secondary my-2">Secondary action</a> *@
35+
@* </p> *@
36+
</div>
37+
</section>
38+
39+
<div class="album py-5">
40+
<div class="container">
41+
@Body
42+
</div>
43+
</div>
44+
45+
</main>

Diff for: ReactSharp/ReactSharp.Demo.ServerApp/Startup.cs renamed to ReactSharp/ReactSharp.Blazor.Demo.ServerApp/Startup.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
using Microsoft.Extensions.Configuration;
1010
using Microsoft.Extensions.DependencyInjection;
1111
using Microsoft.Extensions.Hosting;
12-
using ReactSharp.Demo.ServerApp.Data;
1312

14-
namespace ReactSharp.Demo.ServerApp
13+
14+
namespace ReactSharp.Blazor.Demo.ServerApp
1515
{
1616
public class Startup
1717
{
@@ -28,7 +28,7 @@ public void ConfigureServices(IServiceCollection services)
2828
{
2929
services.AddRazorPages();
3030
services.AddServerSideBlazor();
31-
services.AddSingleton<WeatherForecastService>();
31+
ReactComponentTypeResolver.RegisterAssembly(typeof(ReactSharp.Demo.App).Assembly);
3232
}
3333

3434
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

0 commit comments

Comments
 (0)