Skip to content

Commit b78621a

Browse files
committed
initial commit
1 parent 48f637f commit b78621a

31 files changed

+1332
-0
lines changed

.editorconfig

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; EditorConfig to support per-solution formatting.
2+
; Use the EditorConfig VS add-in to make this work.
3+
; http://editorconfig.org/
4+
;
5+
; Here are some resources for what's supported for .NET/C#
6+
; https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
7+
; https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
8+
;
9+
; Be **careful** editing this because some of the rules don't support adding a severity level
10+
; For instance if you change to `dotnet_sort_system_directives_first = true:warning` (adding `:warning`)
11+
; then the rule will be silently ignored.
12+
13+
; This is the default for the codeline.
14+
root = true
15+
16+
[*]
17+
indent_style = space
18+
charset = utf-8
19+
trim_trailing_whitespace = true
20+
insert_final_newline = true
21+
22+
[*.cs]
23+
indent_size = 4
24+
dotnet_sort_system_directives_first = true
25+
26+
[*.{xml,config,*proj,nuspec,props,resx,targets,yml,tasks}]
27+
indent_size = 2
28+
29+
[*.json]
30+
indent_size = 2
31+
32+
[*.{ps1,psm1}]
33+
indent_size = 4
34+
35+
[*.sh]
36+
indent_size = 4
37+
end_of_line = lf

.gitattributes

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Make sh files under the build directory always have LF as line endings
8+
###############################################################################
9+
*.sh eol=lf
10+
11+
###############################################################################
12+
# Set default behavior for command prompt diff.
13+
#
14+
# This is need for earlier builds of msysgit that does not have it on by
15+
# default for csharp files.
16+
# Note: This is only used by command line
17+
###############################################################################
18+
#*.cs diff=csharp
19+
20+
###############################################################################
21+
# Set the merge driver for project and solution files
22+
#
23+
# Merging from the command prompt will add diff markers to the files if there
24+
# are conflicts (Merging from VS is not affected by the settings below, in VS
25+
# the diff markers are never inserted). Diff markers may cause the following
26+
# file extensions to fail to load in VS. An alternative would be to treat
27+
# these files as binary and thus will always conflict and require user
28+
# intervention with every merge. To do so, just uncomment the entries below
29+
###############################################################################
30+
#*.sln merge=binary
31+
#*.csproj merge=binary
32+
#*.vbproj merge=binary
33+
#*.vcxproj merge=binary
34+
#*.vcproj merge=binary
35+
#*.dbproj merge=binary
36+
#*.fsproj merge=binary
37+
#*.lsproj merge=binary
38+
#*.wixproj merge=binary
39+
#*.modelproj merge=binary
40+
#*.sqlproj merge=binary
41+
#*.wwaproj merge=binary
42+
43+
###############################################################################
44+
# behavior for image files
45+
#
46+
# image files are treated as binary by default.
47+
###############################################################################
48+
#*.jpg binary
49+
#*.png binary
50+
#*.gif binary
51+
52+
###############################################################################
53+
# diff behavior for common document formats
54+
#
55+
# Convert binary document formats to text before diffing them. This feature
56+
# is only available from the command line. Turn it on by uncommenting the
57+
# entries below.
58+
###############################################################################
59+
#*.doc diff=astextplain
60+
#*.DOC diff=astextplain
61+
#*.docx diff=astextplain
62+
#*.DOCX diff=astextplain
63+
#*.dot diff=astextplain
64+
#*.DOT diff=astextplain
65+
#*.pdf diff=astextplain
66+
#*.PDF diff=astextplain
67+
#*.rtf diff=astextplain
68+
#*.RTF diff=astextplain

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Folders
2+
artifacts/
3+
bin/
4+
obj/
5+
.dotnet/
6+
.nuget/
7+
.packages/
8+
.tools/
9+
.vs/
10+
.vscode/
11+
node_modules/
12+
BenchmarkDotNet.Artifacts/
13+
.gradle/
14+
src/SignalR/clients/**/dist/
15+
modules/
16+
17+
# File extensions
18+
*.aps
19+
*.binlog
20+
*.dll
21+
*.DS_Store
22+
*.exe
23+
*.idb
24+
*.lib
25+
*.log
26+
*.pch
27+
*.pdb
28+
*.pidb
29+
*.psess
30+
*.res
31+
*.snk
32+
*.suo
33+
*.tlog
34+
*.user
35+
*.userprefs
36+
*.vspx
37+
38+
# Specific files, typically generated by tools
39+
launchSettings.json
40+
msbuild.ProjectImports.zip
41+
StyleCop.Cache
42+
UpgradeLog.htm
43+
.idea

Skclusive.Blazor.TodoApp/App.razor

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<ReduxToolScript />
2+
<Router AppAssembly="@typeof(Program).Assembly">
3+
<Found Context="routeData">
4+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
5+
</Found>
6+
<NotFound>
7+
<LayoutView Layout="@typeof(MainLayout)">
8+
<p>Sorry, there's nothing at this address.</p>
9+
</LayoutView>
10+
</NotFound>
11+
</Router>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@using Skclusive.Core.Component
2+
3+
@inherits PureComponentBase
4+
5+
<TodoHost>
6+
<div class="todoapp">
7+
<TodoHeader />
8+
<TodoSection />
9+
</div>
10+
</TodoHost>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@inherits TodoComponent
2+
3+
@if (CanClear)
4+
{
5+
<button class="clear-completed" @onclick="OnClear">
6+
Clear completed
7+
</button>
8+
}
9+
10+
@code {
11+
12+
protected bool CanClear => TodoStore.CompletedCount > 0;
13+
14+
protected void OnClear()
15+
{
16+
TodoStore.ClearCompleted();
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Skclusive.Blazor.TodoApp.Models;
2+
using Microsoft.AspNetCore.Components;
3+
using Skclusive.Mobx.Component;
4+
5+
namespace Skclusive.Blazor.TodoApp.Components
6+
{
7+
public class TodoComponent : ObservableComponentBase
8+
{
9+
[Parameter]
10+
public RenderFragment ChildContent { get; set; }
11+
12+
[CascadingParameter]
13+
public ITodoStore TodoStore { get; set; }
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@inherits TodoComponent
2+
3+
<span class="todo-count">
4+
<strong>@ActiveCount</strong> @ItemWord left
5+
</span>
6+
7+
@code {
8+
protected string ActiveCount
9+
{
10+
get
11+
{
12+
var activeCount = TodoStore.ActiveCount;
13+
14+
return activeCount == 0 ? "No" : activeCount.ToString();
15+
}
16+
}
17+
18+
protected string ItemWord
19+
{
20+
get
21+
{
22+
var activeCount = TodoStore.ActiveCount;
23+
24+
return activeCount == 1 ? "Item" : "Items";
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@inherits TodoComponent
2+
3+
<a class="@Class" style="cursor: pointer;" @onclick="OnFilter">
4+
@Title
5+
</a>
6+
7+
@code {
8+
9+
[Parameter]
10+
public string Filter { set; get; }
11+
12+
protected bool Selected => TodoStore.Filter == Filter;
13+
14+
protected string Class => Selected ? nameof(Selected) : null;
15+
16+
protected string Title => Filter.Replace("Show", "");
17+
18+
protected void OnFilter()
19+
{
20+
if (!Selected)
21+
{
22+
TodoStore.SetFilter(Filter);
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@using Skclusive.Core.Component
2+
3+
@inherits PureComponentBase
4+
5+
<footer class="footer">
6+
<TodoCount />
7+
<ul class="filters">
8+
@foreach (var filter in Filters)
9+
{
10+
<li @key="filter">
11+
<TodoFilter Filter="@filter"/>
12+
</li>
13+
}
14+
</ul>
15+
<TodoClear />
16+
</footer>
17+
18+
@code {
19+
protected readonly static List<string> Filters = new List<string> { "ShowAll", "ShowActive", "ShowCompleted" };
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@inherits TodoComponent
2+
3+
<header class="header">
4+
<h1>todos</h1>
5+
<TodoTextInput
6+
NewTodo
7+
Placeholder="What needs to be done?"
8+
OnSave="@OnSave"
9+
/>
10+
</header>
11+
12+
@code {
13+
protected void OnSave(string title)
14+
{
15+
if (!string.IsNullOrEmpty(title))
16+
{
17+
TodoStore.AddTodo(title);
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Skclusive.Blazor.TodoApp.Models;
4+
using Microsoft.AspNetCore.Components;
5+
using Microsoft.AspNetCore.Components.Rendering;
6+
using Skclusive.Core.Component;
7+
using Skclusive.Script.DevTools.StateTree;
8+
using Skclusive.Mobx.StateTree;
9+
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Serialization;
11+
12+
namespace Skclusive.Blazor.TodoApp.Components
13+
{
14+
public class TodoHostComponent : DisposableComponentBase
15+
{
16+
[Parameter]
17+
public RenderFragment ChildContent { get; set; }
18+
19+
[Inject]
20+
public IStateTreeTool<TodoStoreSnapshot> StateTreeTool { get; set; }
21+
22+
protected ITodoStore TodoStore { get; set; }
23+
24+
public TodoHostComponent()
25+
{
26+
TodoStore = ModelTypes.StoreType.Create(new TodoStoreSnapshot
27+
{
28+
Filter = "ShowAll",
29+
30+
Todos = new TodoSnapshot[]
31+
{
32+
new TodoSnapshot { Title = "Get coffee" },
33+
34+
new TodoSnapshot { Title = "Learn Blazor" }
35+
}
36+
});
37+
}
38+
39+
protected override async Task OnInitializedAsync()
40+
{
41+
await base.OnInitializedAsync();
42+
43+
RunTimeout(() =>
44+
{
45+
_ = StateTreeTool.ConnectAsync(TodoStore);
46+
47+
}, 100);
48+
}
49+
50+
protected override void Dispose()
51+
{
52+
base.Dispose();
53+
54+
StateTreeTool?.Dispose();
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@inherits TodoHostComponent
2+
3+
<CascadingValue Value="TodoStore">
4+
@ChildContent
5+
</CascadingValue>
6+

0 commit comments

Comments
 (0)