Skip to content

Commit

Permalink
Merge pull request #192 from TimeWarpEngineering/Cramer/2024-05-04/Fl…
Browse files Browse the repository at this point in the history
…uentUI

Cramer/2024 05 04/fluent UI
  • Loading branch information
StevenTCramer committed May 8, 2024
2 parents 9339f4e + 2e96c90 commit 07553cd
Show file tree
Hide file tree
Showing 30 changed files with 359 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case
#### Analyizer settings ####
dotnet_code_quality.null_check_validation_methods = NotNull

# CA1062: Validate arguments of public methods
# TODO: Turn this back on when figure out how to get Dawn.Guard to not trigger it.
dotnet_diagnostic.ca1062.severity = silent

# CA1308: Normalize strings to uppercase
dotnet_diagnostic.ca1308.severity = none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageVersion Include="Azure.Identity" Version="1.11.2" />
<PackageVersion Include="Blazor-State" Version="11.0.0-beta.31" />
<PackageVersion Include="BlazorComponentUtilities" Version="1.8.0" />
<PackageVersion Include="Dawn.Guard" Version="1.12.0" />
<PackageVersion Include="FakeItEasy" Version="8.2.0" />
<PackageVersion Include="Fixie" Version="3.4.0" />
<PackageVersion Include="Fixie.TestAdapter" Version="3.4.0" />
Expand Down Expand Up @@ -98,4 +97,4 @@
<PackageVersion Include="timewarp-heroicons" Version="2.0.19" />
<PackageVersion Include="timewarp-simple-icons" Version="11.11.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
<title>TimeWarp.Architecture</title>
<base href="/"/>

<!-- add inter font -->
@* add inter font *@
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">

<!-- Compiled Tailwind CSS -->
<link href="css/site.css" rel="stylesheet" />
@* Compiled Tailwind CSS *@
<link href="css/site.css" rel="stylesheet"/>

@* Add FluentUI *@
@* <link href="Web.Spa.styles.css" rel="stylesheet" /> *@
@* <link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" /> *@
<link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" />
<script src="_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js" type="module" async></script>


@* Web.Spa scoped styles *@
@* <link href="Web.Spa.styles.css" rel="stylesheet" /> *@

@* Icons *@
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<ItemGroup Label="Core">
<PackageReference Include="AutoMapper" />
<PackageReference Include="Dawn.Guard" />
<PackageReference Include="FluentValidation.AspNetCore" />
<PackageReference Include="MediatR" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,97 @@
@namespace TimeWarp.Architecture.Components
@inherits ParentComponent

<div @attributes=Attributes class=@CssBuilder role="alert">
<strong class="font-bold">@Title</strong>
<span class="block sm:inline">@ChildContent</span>
<div @attributes=RootAttributes class=@RootCssBuilder>
<FluentCard Class=@CardClasses.ToString() role="alert" Style=@CardStyle>
<FluentLabel Typo=Typography.Body Class=@LabelClasses.ToString() Style=@LabelStyle>
<span class=@TitleClasses style=@TitleStyle>@Title</span>
<span class=@ContentClasses style=@ContentStyle>@ChildContent</span>
</FluentLabel>
</FluentCard>
</div>

@code {

public enum AlertType
{
Success, Danger, Warning, Info, Custom
}

private const string RootClass = "simple-alert";
private const string CardClass = "simple-alert__card";
private const string LabelClass = "simple-alert__label";
private const string TitleClass = "simple-alert__title";
private const string ContentClass = "simple-alert__content";

[Parameter, EditorRequired] public string Title { get; set; } = null!;
[Parameter] public AlertType Type { get; set; } = AlertType.Success;
[Parameter] public string? CardStyle { get; set; }
[Parameter] public string? TitleStyle { get; set; }
[Parameter] public string? ContentStyle { get; set; }
[Parameter] public string? LabelStyle { get; set; }


private string SimpleAlertTypeClass => $"{RootClass}--{Type.ToString().ToLower()}";

private CssBuilder RootCssBuilder = new(RootClass);
private CssBuilder CardClasses = new(CardClass);
private CssBuilder LabelClasses = new(LabelClass);
private CssBuilder TitleClasses = new(TitleClass);
private CssBuilder ContentClasses = new(ContentClass);

private Dictionary<string, object> RootAttributes = new();

protected override void OnParametersSet()
{
base.OnParametersSet();
Guard.Against.Null(Title);
Guard.Against.EnumOutOfRange(Type);

ProcessAttributes();
}

private void ProcessAttributes()
{
RootAttributes.Clear();
RootCssBuilder.AddClass(SimpleAlertTypeClass);

// Process the "class" attribute specifically
if (Attributes.TryGetValue("class", out object? classValue) && classValue is string classString)
{
string[] classes = classString.Split(' ', StringSplitOptions.RemoveEmptyEntries);

foreach (string className in classes)
{
if (className.StartsWith($"{CardClass}-"))
{
CardClasses.AddClass(className[(CardClass.Length + 2)..]);
}
else if (className.StartsWith($"{LabelClass}-"))
{
LabelClasses.AddClass(className[(LabelClass.Length + 2)..]);
}
else if (className.StartsWith($"{TitleClass}-"))
{
TitleClasses.AddClass(className[(TitleClass.Length + 2)..]);
}
else if (className.StartsWith($"{ContentClass}-"))
{
ContentClasses.AddClass(className[(ContentClass.Length + 2)..]);
}
else
{
RootCssBuilder.AddClass(className);
}
}
}

// Copy all other attributes except "class" to the root
foreach (KeyValuePair<string, object> attribute in Attributes)
{
if (attribute.Key != "class")
{
RootAttributes[attribute.Key] = attribute.Value;
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.simple-alert {
}

::deep .simple-alert__label {
@apply m-0;
}

::deep .simple-alert__title {
@apply font-bold;
}

::deep .simple-alert__content {
@apply block sm:inline
}

/* Base styles for any alert */
::deep .simple-alert__card {
@apply px-4 py-3 rounded relative border;
}

/* Success Alert Styles */
::deep.simple-alert--success .simple-alert__card {
@apply bg-positive-100 border-positive-400;
}

::deep.simple-alert--success .simple-alert__label {
@apply text-positive-700;
}

/* Danger Alert Styles */
::deep.simple-alert--danger .simple-alert__card {
@apply bg-danger-100 border-danger-400;
}

::deep.simple-alert--danger .simple-alert__label {
@apply text-danger-700;
}

/* Warning Alert Styles */
::deep.simple-alert--warning .simple-alert__card {
@apply bg-warning-100 border-warning-400;
}

::deep.simple-alert--warning .simple-alert__label {
@apply text-warning-700;
}

/* Info Alert Styles */
::deep.simple-alert--info .simple-alert__card {
@apply bg-info-100 border-info-400;
}

::deep.simple-alert--info .simple-alert__label {
@apply text-info-700;
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="mt-5 sm:mt-6">
@if (ActionContent is null)
{
<Button Variant=Button.ButtonVariant.Default data-qa="ModalButton" @onclick=CloseModal>Close</Button>
<FluentButton Appearance=Appearance.Accent data-qa="ModalButton" OnClick=CloseModal>Close</FluentButton>
}
else
{
Expand All @@ -25,3 +25,5 @@
</div>
</div>
}


Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,55 @@
</HeaderContent>

<MainContent>
<div class="px-4 py-6 sm:px-0">
<div class="flex flex-col">
<div>
Welcome to your new
<HyperLink href="https://github.com/TimeWarpEngineering/timewarp-architecture">TimeWarp Architecture</HyperLink>
app with
<ul>
<li>
<HyperLink href="https://www.nuget.org/profiles/TimeWarp.Enterprises">TimeWarp.Enterprises nugets</HyperLink>
</li>
<li>
<HyperLink href="https://timewarpengineering.github.io/blazor-state/"> Blazor State</HyperLink>
</li>
<li>
<HyperLink href="https://github.com/jbogard/MediatR" target="blank">MediatR.</HyperLink>
</li>
<li>
<HyperLink href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en" target="blank">Redux Dev Tools Chrome Extension </HyperLink>
</li>
</ul>
</div>
<FluentStack Orientation=Orientation.Vertical>
<FluentLabel Typo=Typography.Body>
Welcome to your new
<NavLink href="https://github.com/TimeWarpEngineering/timewarp-architecture">TimeWarp Architecture</NavLink>
app with
<ul>
<li>
<NavLink href="https://www.nuget.org/profiles/TimeWarp.Enterprises">TimeWarp.Enterprises nugets</NavLink>
</li>
<li>
<NavLink href="https://timewarpengineering.github.io/blazor-state/"> Blazor State</NavLink>
</li>
<li>
<NavLink href="https://github.com/jbogard/MediatR" target="blank">MediatR.</NavLink>
</li>
<li>
<NavLink href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en" target="blank">Redux Dev Tools Chrome Extension </NavLink>
</li>
</ul>
</FluentLabel>

<SimpleAlert class="mt-4 w-fit" Title="Alert">
This site is built with
<NavLink href="https://github.com/microsoft/fluentui-blazor" target="blank">Fluent UI</NavLink>
and
<HyperLink href="https://tailwindcss.com/" target="blank">Tailwind css</HyperLink>
</SimpleAlert>

<SimpleAlert class="mt-4" Title="Tailwind UI">
This site is built with
<HyperLink href="https://tailwindcss.com/" target="blank">Tailwind css</HyperLink>
and
<HyperLink href="https://tailwindui.com" target="blank">Tailwind UI</HyperLink>
</SimpleAlert>

<img alt="Solid Team" class="w-full" src="/images/TheFreezeTeam/SOLID_Team.png" />
<div>
<FluentButton Appearance="Appearance.Accent" OnClick=FiveSecondTaskButtonClick>Launch Five Second Task</FluentButton>
<Button Variant=Button.ButtonVariant.Default data-qa="FiveSecondButton" @onclick=FiveSecondTaskButtonClick>Launch Five Second Task</Button>
<Button Variant=Button.ButtonVariant.Default data-qa="TwoSecondButton" @onclick=TwoSecondTaskButtonClick>Launch Two Second Task</Button>
<Button Variant=Button.ButtonVariant.Default data-qa="ModalButton" @onclick=ModalButtonClick>Show Modal</Button>
</div>
<img alt="Solid Team" class="w-full" src="/images/TheFreezeTeam/SOLID_Team.png" />
<div>
<FluentButton Appearance="Appearance.Accent" OnClick=FiveSecondTaskButtonClick>Launch Five Second Task</FluentButton>
<FluentButton Appearance="Appearance.Accent" OnClick=TwoSecondTaskButtonClick>Launch Two Second Task</FluentButton>
<FluentButton Appearance="Appearance.Accent" OnClick=ModalButtonClick>Show Modal</FluentButton>
</div>
</div>

<FluentLabel Typo="Typography.Body"> Example 'Body' label </FluentLabel>
<FluentLabel Typo="Typography.Subject"> Example 'Subject' label </FluentLabel>
<FluentLabel Typo="Typography.Header"> Example 'Header' label </FluentLabel>
<FluentLabel Typo="Typography.PaneHeader"> Example 'PaneHeader' label </FluentLabel>
<FluentLabel Typo="Typography.EmailHeader"> Example 'EmailHeader' label </FluentLabel>
<FluentLabel Typo="Typography.PageTitle"> Example 'PageTitle' label </FluentLabel>
<FluentLabel Typo="Typography.HeroTitle"> Example 'HeroTitle' label </FluentLabel>
<FluentLabel Typo="Typography.H1"> Example 'H1' label </FluentLabel>
<FluentLabel Typo="Typography.H2"> Example 'H2' label </FluentLabel>
<FluentLabel Typo="Typography.H3"> Example 'H3' label </FluentLabel>
<FluentLabel Typo="Typography.H4"> Example 'H4' label </FluentLabel>
<FluentLabel Typo="Typography.H5"> Example 'H5' label </FluentLabel>
<FluentLabel Typo="Typography.H6"> Example 'H6' label </FluentLabel>

</FluentStack>
</MainContent>
</SidebarPage>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<label for="message">Message</label>
<input type="text" class="form-control" id="message" @bind=Message @onkeydown=HandleKeyDown />
</div>
<Button Variant=Button.ButtonVariant.Default @onclick=SendMessage>Send</Button>
<FluentButton Appearance=Appearance.Accent OnClick=SendMessage>Send</FluentButton>

<hr />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<div data-qa="@TestId" @attributes=Attributes >
<p>Current count: @CounterState.Count</p>

<Button Variant=Button.ButtonVariant.Default @onclick=ButtonClick>Click me</Button>
<FluentButton Appearance=Appearance.Accent OnClick=ButtonClick>Click me</FluentButton>
</div>

@code
{
protected async Task ButtonClick() => await Send(new CounterState.IncrementCounter.Action(Amount: 5));
}

This file was deleted.

Loading

0 comments on commit 07553cd

Please sign in to comment.