Skip to content

Commit a146daa

Browse files
committed
Create Label and CondtionalLabel components
1 parent de30986 commit a146daa

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

Joinrpg.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JoinRpg.PrimitiveTypes", "s
103103
EndProject
104104
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JoinRpg.BlobStorage", "src\JoinRpg.BlobStorage\JoinRpg.BlobStorage.csproj", "{9F846CF9-3FB8-4164-9BEA-08DE68B239AD}"
105105
EndProject
106+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JoinRpg.WebComponents", "src\JoinRpg.WebComponents\JoinRpg.WebComponents.csproj", "{80AF606D-0576-480E-8D2E-AE736C2EE73C}"
107+
EndProject
106108
Global
107109
GlobalSection(SolutionConfigurationPlatforms) = preSolution
108110
Debug|Any CPU = Debug|Any CPU
@@ -261,6 +263,10 @@ Global
261263
{9F846CF9-3FB8-4164-9BEA-08DE68B239AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
262264
{9F846CF9-3FB8-4164-9BEA-08DE68B239AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
263265
{9F846CF9-3FB8-4164-9BEA-08DE68B239AD}.Release|Any CPU.Build.0 = Release|Any CPU
266+
{80AF606D-0576-480E-8D2E-AE736C2EE73C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
267+
{80AF606D-0576-480E-8D2E-AE736C2EE73C}.Debug|Any CPU.Build.0 = Debug|Any CPU
268+
{80AF606D-0576-480E-8D2E-AE736C2EE73C}.Release|Any CPU.ActiveCfg = Release|Any CPU
269+
{80AF606D-0576-480E-8D2E-AE736C2EE73C}.Release|Any CPU.Build.0 = Release|Any CPU
264270
EndGlobalSection
265271
GlobalSection(SolutionProperties) = preSolution
266272
HideSolutionNode = FALSE
@@ -295,6 +301,7 @@ Global
295301
{17FBA40C-1B31-4575-A4EC-27D40F65D63A} = {8BB208B6-13CD-4942-B3AC-037BDF858727}
296302
{AC09C4CB-0D6C-4301-A4BF-8129A9881BE5} = {B8A1A61E-CD98-49F5-98BA-30B0869576B1}
297303
{3623C97E-251A-4233-A359-18F76F9598C8} = {7645AC35-A68C-40EF-8AAD-1BF62D822E4C}
304+
{80AF606D-0576-480E-8D2E-AE736C2EE73C} = {B3BB8906-62C8-44A0-822C-566A144C05AE}
298305
EndGlobalSection
299306
GlobalSection(ExtensibilityGlobals) = postSolution
300307
SolutionGuid = {1A5E4F92-A0F4-4350-92C7-361C88D58588}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@using System.Linq.Expressions;
2+
@if (For.Compile()())
3+
{
4+
<Label For="@For" @attributes="@InputAttributes">@ChildContent</Label>
5+
}
6+
@code {
7+
[Parameter] public Expression<Func<bool>> For { get; set; }
8+
[Parameter] public RenderFragment? ChildContent { get; set; }
9+
[Parameter(CaptureUnmatchedValues = true)]
10+
public Dictionary<string, object> InputAttributes { get; set; }
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
8+
<ItemGroup>
9+
<SupportedPlatform Include="browser" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.5" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\JoinRpg.Helpers\JoinRpg.Helpers.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@using System.Linq.Expressions;
2+
@using JoinRpg.Helpers
3+
@typeparam T
4+
@if (ChildContent == null)
5+
{
6+
<label @attributes="@InputAttributes" class="@labelStyle">@label</label>
7+
}
8+
else
9+
{
10+
<label @attributes="@InputAttributes" class="@labelStyle">
11+
@label
12+
@ChildContent
13+
</label>
14+
}
15+
@code {
16+
[Parameter] public Expression<Func<T>> For { get; set; }
17+
[Parameter] public RenderFragment? ChildContent { get; set; }
18+
[Parameter] public VariationStyleEnum? Variation { get; set; }
19+
20+
[Parameter(CaptureUnmatchedValues = true)]
21+
public Dictionary<string, object> InputAttributes { get; set; }
22+
23+
private string label {
24+
get {
25+
var property = For.AsPropertyAccess();
26+
if (property is null)
27+
{
28+
throw new ArgumentException("Expression should be property access", nameof(For));
29+
}
30+
return property.GetDisplayName();
31+
}
32+
}
33+
34+
private string labelStyle
35+
{
36+
get
37+
{
38+
return Variation switch
39+
{
40+
VariationStyleEnum.Success => "label label-success",
41+
_ => "label",
42+
};
43+
}
44+
}
45+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace JoinRpg.WebComponents
2+
{
3+
public enum VariationStyleEnum
4+
{
5+
None,
6+
Success,
7+
}
8+
}

0 commit comments

Comments
 (0)