Skip to content

Commit

Permalink
Added Styx - Razor Component Library
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuen committed Nov 13, 2024
1 parent cf367ed commit 5f4fe8b
Show file tree
Hide file tree
Showing 54 changed files with 18,878 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Authorization.Access
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Authorization.AccessPackages", "src\Altinn.Authorization.AccessPackages\Altinn.Authorization.AccessPackages.csproj", "{F8894253-1209-4076-ADDC-598AFFF69D12}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Styx", "..\..\..\..\..\poc\Styx\Styx\Styx.csproj", "{C8F95A18-0794-46B9-8C84-8A9138274334}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Authorization.FFB", "src\Altinn.Authorization.AccessPackages.FFB\Altinn.Authorization.FFB.csproj", "{D11A8DD1-692C-46D6-9C7A-0E2A5B468ED5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.Authorization.Importers.BRREG", "src\Altinn.Authorization.Importers.BRREG\Altinn.Authorization.Importers.BRREG.csproj", "{FA0ECB21-12E4-4299-88A0-72D4EB5A2B86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccessPackages.Aspire", "AccessPackages.Aspire\AccessPackages.Aspire.csproj", "{3758A91B-C5D8-4263-B292-5E099B8F8063}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Styx", "src\Styx\Styx.csproj", "{4165FABC-566A-47E6-BF05-8A5C85E773CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccessPackages.Aspire", "src\AccessPackages.Aspire\AccessPackages.Aspire.csproj", "{9EC42A8E-5CE5-4240-833C-B2673E1AE403}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -49,10 +49,6 @@ Global
{F8894253-1209-4076-ADDC-598AFFF69D12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8894253-1209-4076-ADDC-598AFFF69D12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8894253-1209-4076-ADDC-598AFFF69D12}.Release|Any CPU.Build.0 = Release|Any CPU
{C8F95A18-0794-46B9-8C84-8A9138274334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8F95A18-0794-46B9-8C84-8A9138274334}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8F95A18-0794-46B9-8C84-8A9138274334}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8F95A18-0794-46B9-8C84-8A9138274334}.Release|Any CPU.Build.0 = Release|Any CPU
{D11A8DD1-692C-46D6-9C7A-0E2A5B468ED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D11A8DD1-692C-46D6-9C7A-0E2A5B468ED5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D11A8DD1-692C-46D6-9C7A-0E2A5B468ED5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -61,10 +57,14 @@ Global
{FA0ECB21-12E4-4299-88A0-72D4EB5A2B86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA0ECB21-12E4-4299-88A0-72D4EB5A2B86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA0ECB21-12E4-4299-88A0-72D4EB5A2B86}.Release|Any CPU.Build.0 = Release|Any CPU
{3758A91B-C5D8-4263-B292-5E099B8F8063}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3758A91B-C5D8-4263-B292-5E099B8F8063}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3758A91B-C5D8-4263-B292-5E099B8F8063}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3758A91B-C5D8-4263-B292-5E099B8F8063}.Release|Any CPU.Build.0 = Release|Any CPU
{4165FABC-566A-47E6-BF05-8A5C85E773CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4165FABC-566A-47E6-BF05-8A5C85E773CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4165FABC-566A-47E6-BF05-8A5C85E773CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4165FABC-566A-47E6-BF05-8A5C85E773CB}.Release|Any CPU.Build.0 = Release|Any CPU
{9EC42A8E-5CE5-4240-833C-B2673E1AE403}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EC42A8E-5CE5-4240-833C-B2673E1AE403}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EC42A8E-5CE5-4240-833C-B2673E1AE403}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EC42A8E-5CE5-4240-833C-B2673E1AE403}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -75,10 +75,10 @@ Global
{A187084E-5459-45D1-A897-56FEEEAD5879} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{B67A1BE1-FC3E-48A6-841D-474F27B7296F} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{F8894253-1209-4076-ADDC-598AFFF69D12} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{C8F95A18-0794-46B9-8C84-8A9138274334} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{D11A8DD1-692C-46D6-9C7A-0E2A5B468ED5} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{FA0ECB21-12E4-4299-88A0-72D4EB5A2B86} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{3758A91B-C5D8-4263-B292-5E099B8F8063} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{4165FABC-566A-47E6-BF05-8A5C85E773CB} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
{9EC42A8E-5CE5-4240-833C-B2673E1AE403} = {9287E06E-BAF1-4F4B-B795-0B53B745DA50}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5EBE6D29-F6B8-4EE6-9C6C-A70E98E65748}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Altinn.Authorization.AccessPackages.CLI\Altinn.Authorization.AccessPackages.CLI.csproj" />
<ProjectReference Include="..\src\Altinn.Authorization.AccessPackages.FFB\Altinn.Authorization.FFB.csproj" />
<ProjectReference Include="..\src\Altinn.Authorization.AccessPackages\Altinn.Authorization.AccessPackages.csproj" />
<ProjectReference Include="..\Altinn.Authorization.AccessPackages.CLI\Altinn.Authorization.AccessPackages.CLI.csproj" />
<ProjectReference Include="..\Altinn.Authorization.AccessPackages.FFB\Altinn.Authorization.FFB.csproj" />
<ProjectReference Include="..\Altinn.Authorization.AccessPackages\Altinn.Authorization.AccessPackages.csproj" />
<ProjectReference Include="..\Altinn.Authorization.Importers.BRREG\Altinn.Authorization.Importers.BRREG.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"AllowedHosts": "*",
"DbObjDefConfig": {
"BaseSchema": "dbo",
"TranslationSchema": "translation",
"TranslationSchema": "translation",git commit
"HistorySchema": "history",
"TranslateObjects": [
"Area",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\..\poc\Styx\Styx\Styx.csproj" />
<ProjectReference Include="..\Altinn.Authorization.AccessPackages.Common\Altinn.Authorization.AccessPackages.Common.csproj" />
<ProjectReference Include="..\Altinn.Authorization.AccessPackages.Repo\Altinn.Authorization.AccessPackages.Repo.csproj" />
<ProjectReference Include="..\Styx\Styx.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<button type="button" class="@(Class())" @onclick="@(()=>OnClick.InvokeAsync())">@ChildContent</button>

@code {
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public ButtonVariant Variant { get; set; } = ButtonVariant.Normal;
[Parameter] public ButtonState State { get; set; } = ButtonState.Default;
[Parameter] public bool Pill { get; set; } = false;
[Parameter] public bool Small { get; set; } = false;

[Parameter] public EventCallback OnClick { get; set; }

private string Class()
{
string res = "bf-button";

//res += Variant == ButtonVariant.Normal ? "" : "";
res += Variant == ButtonVariant.Filled ? " bf-button-filled" : "";
res += Variant == ButtonVariant.Flat ? " bf-button-flat" : "";

//res += State == ButtonState.Default ? "" : "";
res += State == ButtonState.Neutral ? " bf-button-neutral" : "";
res += State == ButtonState.Inactive ? " bf-button-inactive" : "";
res += State == ButtonState.Inverted ? " bf-button-inverted" : "";
res += State == ButtonState.Alert ? " bf-button-alert" : "";

res += Pill ? " bf-button-pill" : "";
res += Small ? " bf-button-small" : "";

return res;
}

public enum ButtonVariant { Normal, Filled, Flat };
public enum ButtonState { Default, Neutral, Inactive, Inverted, Alert }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="bf-button-group">
@ChildContent
</div>

@code {

[Parameter] public RenderFragment ChildContent { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="bf-input-container @(Disabled ? "bf-input-disabled" : "")">
<label for="input-@Id" class="bf-label">@Title</label>
<div class="bf-label-description">@Description</div>
<input id="input-@Id" class="bf-input" disabled=@Disabled @bind-value="@Value" @bind-value:event="oninput" placeholder="@Placeholder" />
</div>

@code {

[Parameter] public string Id { get; set; }
[Parameter] public string Title { get; set; }
[Parameter] public string Description { get; set; }
[Parameter] public string Placeholder { get; set; }
[Parameter] public bool Disabled { get; set; }

[Parameter] public EventCallback<string> ValueChanged { get; set; }

private string _value;
[Parameter]
public string Value
{
get => _value;
set
{
if (value == _value)
return;

_value = value;
if (ValueChanged.HasDelegate)
{
ValueChanged.InvokeAsync(_value);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@namespace Styx

<div class="bf-input-container">
<label for="input-" class="bf-label">@Title</label>
<div class="bf-label-description">@Description</div>
@ChildContent
</div>

@code {
[Parameter] public string Title { get; set; }
[Parameter] public string Description { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@namespace Styx
<CascadingValue TValue="RadioGroup" Value="this">
@ChildContent
</CascadingValue>

@code {

[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public string Key { get; set; }
[Parameter] public string Value { get; set; } = "";
[Parameter] public EventCallback<string> ValueChanged { get; set; }

public void Set(string value)
{
if (Value == value)
{
Value = "";
}
else
{
Value = value;
}
ValueChanged.InvokeAsync(Value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@namespace Styx

<label class="bf-checkbox @(UseButtonStyle ? "bf-checkbox-button" : "") @(Compact ? "bf-checkbox-small" : "")">
<input type="radio" checked="@(Group.Value == this.Value)" id=@Value name=@Group.Key @onchange=@(() => Group.Set(Value)) />
<span class="bf-checkbox-icon">
<i class="bf-checkbox-checked fa-solid fa-circle-dot"></i>
<i class="bf-checkbox-unchecked fa-regular fa-circle"></i>
</span>
@ChildContent
</label>


@code {

[CascadingParameter] public RadioGroup Group { get; set; }
[Parameter] public string Value { get; set; }
[Parameter] public bool UseButtonStyle { get; set; }
[Parameter] public bool Compact { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-button">

<input type="checkbox" checked="@Checked" @onchange="eventArgs => { CheckedChanged.InvokeAsync((bool)eventArgs.Value); }" />
<span class="bf-switch @(Checked ? "bf-switch-checked" : "")">
<span class="bf-switch-thumb">
<i class="bf-checkbox-checked fa-solid fa-check"></i>
<i class="bf-checkbox-unchecked fa-solid"></i>
</span>
</span>
<span class="bf-checkbox-text">@ChildContent</span>

</label>

@code {

[Parameter] public bool Checked { get; set; }
[Parameter] public EventCallback<bool> CheckedChanged { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="my-component">
This component is defined in the <strong>Styx</strong> library.
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.my-component {
border: 2px dashed red;
padding: 1em;
margin: 1em 0;
background-image: url('background.png');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.JSInterop;

namespace Styx
{
// This class provides an example of how JavaScript functionality can be wrapped
// in a .NET class for easy consumption. The associated JavaScript module is
// loaded on demand when first needed.
//
// This class can be registered as scoped DI service and then injected into Blazor
// components for use.

public class ExampleJsInterop : IAsyncDisposable
{
private readonly Lazy<Task<IJSObjectReference>> moduleTask;

public ExampleJsInterop(IJSRuntime jsRuntime)
{
moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>(
"import", "./_content/Styx/exampleJsInterop.js").AsTask());
}

public async ValueTask<string> Prompt(string message)
{
var module = await moduleTask.Value;
return await module.InvokeAsync<string>("showPrompt", message);
}

public async ValueTask DisposeAsync()
{
if (moduleTask.IsValueCreated)
{
var module = await moduleTask.Value;
await module.DisposeAsync();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="bf-accordion">
<CascadingValue TValue="Accordion" Value="this">
@ChildContent
</CascadingValue>
</div>

@code {

[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public bool MultiOpen { get; set; }
public string ActiveItem { get; set; } = "";

public void SetActiveItem(string title)
{
ActiveItem = title;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div class="bf-accordion-item @(IsOpen ? "bf-accordion-item-active" : "")">
<div class="bf-accordion-item-title">
<button type="button" @onclick="() => Toggle()">
<span class="bf-accordion-item-angle-circle">
<i class="fa-solid fa-angle-right fa-fw bf-accordion-item-angle"></i>
</span>
<span>
@if (!string.IsNullOrEmpty(Icon))
{
<Icon Name="@Icon"></Icon><span>&nbsp;</span>
}
@Title
</span>
<div style="display: flex; gap: 6px; padding: 0 6px;">
@foreach (var tag in Tags)
{
<span class="bf-badge bfc-theme-bg bf-badge-compact">@tag</span>
}
</div>
<div>
@if (!string.IsNullOrEmpty(Url))
{
<a href="@Url">
<i class="fa-solid fa-arrow-up-right-from-square"></i>
</a>
}
</div>

</button>
</div>
<div class="bf-expand @(ShowContent() ? "" : "bf-expand-closed")">
<div>
<div class="bf-accordion-item-content">
@ChildContent
</div>
</div>
</div>
</div>

@code {

[CascadingParameter] public Accordion Parent { get; set; }

[Parameter] public string Title { get; set; }
[Parameter] public string Icon { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public bool IsOpen { get; set; } = false;
[Parameter] public string Url { get; set; }
[Parameter] public List<string> Tags { get; set; } = new List<string>();

protected async override Task OnParametersSetAsync()
{
if (IsOpen)
{
Parent.SetActiveItem(Title);
}
}

private bool ShowContent() => IsOpen ? Parent.MultiOpen || Parent.MultiOpen == false && Parent.ActiveItem == Title : false;

protected void Toggle()
{
IsOpen = !IsOpen;
if (IsOpen)
{
Parent.SetActiveItem(Title);
}
}

}
Loading

0 comments on commit 5f4fe8b

Please sign in to comment.