Skip to content

Commit

Permalink
Add PureFooter, PureNavLink, enable Nullables
Browse files Browse the repository at this point in the history
  • Loading branch information
codymullins committed Apr 3, 2024
1 parent aa04e9a commit f0ba4c2
Show file tree
Hide file tree
Showing 20 changed files with 450 additions and 173 deletions.
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# file: build.sh

dotnet build src/Pure.Blazor.Components
9 changes: 9 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<NuGetAuditMode>All</NuGetAuditMode>
<NuGetAuditLevel>low</NuGetAuditLevel>
</PropertyGroup>
</Project>
31 changes: 31 additions & 0 deletions src/Pure.Blazor.Components.Docs/Pages/Dev.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
@page "/dev"
@inject ILogger<Dev> Logger
<Header1 Styles="mt-4">Dev Page</Header1>
<Paragraph Styles="mb-8">Kitchen sink page for testing.</Paragraph>
<div class="flex flex-col gap-8">
<div>
<Header2>Radio Group</Header2>
<Header3 Styles="my-2">Basic</Header3>
<PureRadioGroup Name="test" SelectedRadio="@selectedRadio">
<PureRadio Checked="false" Title="Foo" Value="foo"></PureRadio>
<PureRadio Checked="false" Title="Bar" Value="bar"></PureRadio>
<PureRadio Checked="false" Title="Fuzz" Value="fuzz"></PureRadio>
</PureRadioGroup>
<PureLabel>Selected:</PureLabel>
<PureText>@selectedRadio?.Value</PureText>
<Header3 Styles="mb-2 mt-6">With Description</Header3>
<PureRadioGroup Name="test">
<PureRadio Checked="false"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
Title="Foo"
Value="foo">
</PureRadio>
<PureRadio Checked="false"
Description="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
Title="Bar"
Value="bar">
</PureRadio>
</PureRadioGroup>
</div>
<div>
<Header2>Status Indicators</Header2>
<Header3 Styles="my-2">Minimal</Header3>
Expand Down Expand Up @@ -49,5 +74,11 @@
</div>

@code {
private PureRadio? selectedRadio = null;

private void Callback(PureRadio radio)
{
Logger.LogInformation("Radio changed to {0}", radio.Value);
}

}
5 changes: 2 additions & 3 deletions src/Pure.Blazor.Components.Docs/Pages/Forms.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

<div class="grid grid-cols-4 pt-10">
<div class="hidden sm:block sm:col-span-1">
<PureVertNav />
<PureVertNav/>
</div>
<div class="col-span-4 sm:col-span-3">
<Header2>Components</Header2>
<FormSample />
</div>
</div>

@code {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@using Microsoft.Extensions.Logging

@inject ILogger<PureDropdown> Log
@inject ILogger<PureDropdown> Log

<Header1 Id="dropdowns">Dropdowns</Header1>
<div class="mb-10">
Expand All @@ -18,7 +16,7 @@
@code {
public string MenuItemClicked { get; set; } = "Select a menu item";

public List<DropdownMenuItem> Items { get; set; } = new List<DropdownMenuItem>();
public List<DropdownMenuItem> Items { get; set; } = new();

protected override void OnInitialized()
{
Expand All @@ -30,7 +28,7 @@

protected void ItemSelected(DropdownMenuItem item)
{
MenuItemClicked = item.Text;
MenuItemClicked = item.Text ?? "";
}

private string Markup = @"<PureDropdown Items=""Items"">Settings</PureDropdown>
Expand Down
83 changes: 45 additions & 38 deletions src/Pure.Blazor.Components.Docs/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ namespace Pure.Blazor.Components.Docs;
// src: https://learn.microsoft.com/en-us/archive/msdn-magazine/2019/october/csharp-accessing-xml-documentation-via-reflection
public static class AssemblyExtensions
{
internal static HashSet<Assembly> loadedAssemblies = new HashSet<Assembly>();
internal static HashSet<Assembly> loadedAssemblies = new();

public static string GetDirectoryPath(this Assembly assembly)
internal static Dictionary<string, string> loadedXmlDocumentation = new();

public static string? GetDirectoryPath(this Assembly assembly)
{
string codeBase = assembly.CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
var codeBase = assembly.Location;
var uri = new UriBuilder(codeBase);
var path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}

Expand All @@ -23,33 +25,42 @@ internal static void LoadXmlDocumentation(Assembly assembly)
{
return; // Already loaded
}
string directoryPath = assembly.GetDirectoryPath();
string xmlFilePath = Path.Combine(directoryPath, assembly.GetName().Name + ".xml");

var directoryPath = assembly.GetDirectoryPath();
if (directoryPath is null)
{
return;
}

var xmlFilePath = Path.Combine(directoryPath, assembly.GetName().Name + ".xml");
if (File.Exists(xmlFilePath))
{
LoadXmlDocumentation(File.ReadAllText(xmlFilePath));
loadedAssemblies.Add(assembly);
}
}

internal static Dictionary<string, string> loadedXmlDocumentation =
new Dictionary<string, string>();
public static void LoadXmlDocumentation(string xmlDocumentation)
{
using (XmlReader xmlReader = XmlReader.Create(new StringReader(xmlDocumentation)))
using (var xmlReader = XmlReader.Create(new StringReader(xmlDocumentation)))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "member")
{
string raw_name = xmlReader["name"];
var raw_name = xmlReader["name"];
if (raw_name is null)
{
continue;
}

loadedXmlDocumentation[raw_name] = xmlReader.ReadInnerXml();
}
}
}
}

public static string GetDocumentation(this MemberInfo memberInfo)
public static string? GetDocumentation(this MemberInfo memberInfo)
{
try
{
Expand All @@ -63,53 +74,49 @@ public static string GetDocumentation(this MemberInfo memberInfo)
//}
if (memberInfo.MemberType.HasFlag(MemberTypes.Event))
{
return ((EventInfo) memberInfo).GetDocumentation();
}
else if (memberInfo.MemberType.HasFlag(MemberTypes.Constructor))
{
return ((ConstructorInfo) memberInfo).GetDocumentation();
return ((EventInfo)memberInfo).GetDocumentation();
}
else if (memberInfo.MemberType.HasFlag(MemberTypes.Method))

if (memberInfo.MemberType.HasFlag(MemberTypes.Constructor))
{
return ((MethodInfo) memberInfo).GetDocumentation();
return ((ConstructorInfo)memberInfo).GetDocumentation();
}
else if (memberInfo.MemberType.HasFlag(MemberTypes.TypeInfo) ||
memberInfo.MemberType.HasFlag(MemberTypes.NestedType))

if (memberInfo.MemberType.HasFlag(MemberTypes.Method))
{
return ((TypeInfo) memberInfo).GetDocumentation();
return ((MethodInfo)memberInfo).GetDocumentation();
}
else

if (memberInfo.MemberType.HasFlag(MemberTypes.TypeInfo) ||
memberInfo.MemberType.HasFlag(MemberTypes.NestedType))
{
return null;
return ((TypeInfo)memberInfo).GetDocumentation();
}

return null;
}
catch (Exception ex)
catch (Exception)
{
return "";
}
}

public static string GetDocumentation(this ParameterInfo parameterInfo)
public static string? GetDocumentation(this ParameterInfo parameterInfo)
{
string memberDocumentation = parameterInfo.Member.GetDocumentation();
var memberDocumentation = parameterInfo.Member.GetDocumentation();
if (memberDocumentation != null)
{
string regexPattern =
Regex.Escape(@"<param name=" + "\"" + parameterInfo.Name + "\"" + @">") +
".*?" +
Regex.Escape(@"</param>");
Match match = Regex.Match(memberDocumentation, regexPattern);
var regexPattern =
Regex.Escape(@"<param name=" + "\"" + parameterInfo.Name + "\"" + @">") +
".*?" +
Regex.Escape(@"</param>");
var match = Regex.Match(memberDocumentation, regexPattern);
if (match.Success)
{
return match.Value;
}
}

return null;
}
}

public class Utilities
{


}
1 change: 0 additions & 1 deletion src/Pure.Blazor.Components/Common/PureComponent.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@code {
string? prevStyles;

protected override void OnParametersSet()
{
Expand Down
Loading

0 comments on commit f0ba4c2

Please sign in to comment.