Skip to content

Commit

Permalink
Merge branch 'develop' into 9503-blazorui-extras-promodal
Browse files Browse the repository at this point in the history
  • Loading branch information
msynk committed Dec 23, 2024
2 parents 1ace76c + 44ab21b commit 5a64fbe
Show file tree
Hide file tree
Showing 22 changed files with 227 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/bit.full.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:

- name: Simple tests (no --advancedTests)
id: simple-test
continue-on-error: true
run: |
dotnet new bit-bp --name SimpleTest --database Sqlite --framework net8.0
cd SimpleTest/src/Server/SimpleTest.Server.Api/
Expand All @@ -79,6 +80,7 @@ jobs:

- name: Test Sqlite database option
id: sqlite-test
continue-on-error: true
run: |
dotnet new bit-bp --name TestSqlite --database Sqlite --advancedTests --framework net9.0
cd TestSqlite/src/Server/TestSqlite.Server.Api/
Expand All @@ -101,6 +103,7 @@ jobs:

- name: Test SqlServer database option
id: sqlserver-test
continue-on-error: true
run: |
dotnet new bit-bp --name TestSqlServer --database SqlServer --advancedTests --framework net8.0
cd TestSqlServer/src/Server/TestSqlServer.Server.Api/
Expand All @@ -121,6 +124,7 @@ jobs:

- name: Test Multilingual disabled option
id: multilingual-disabled-test
continue-on-error: true
run: |
dotnet new bit-bp --name MultilingualDisabled --database Sqlite --advancedTests --framework net8.0
cd MultilingualDisabled/src/Server/MultilingualDisabled.Server.Api/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![License](https://img.shields.io/github/license/bitfoundation/bitplatform.svg)
![CI Status](https://github.com/bitfoundation/bitplatform/actions/workflows/bit.ci.yml/badge.svg)
![NuGet version](https://img.shields.io/nuget/v/bit.blazorui.svg?logo=nuget)
[![Nuget downloads](https://img.shields.io/badge/packages_download-5.5M-blue.svg?logo=nuget)](https://www.nuget.org/profiles/bit-foundation)
[![Nuget downloads](https://img.shields.io/badge/packages_download-5.6M-blue.svg?logo=nuget)](https://www.nuget.org/profiles/bit-foundation)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/bitfoundation/bitplatform.svg)](http://isitmaintained.com/project/bitfoundation/bitplatform "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/bitfoundation/bitplatform.svg)](http://isitmaintained.com/project/bitfoundation/bitplatform "Percentage of issues still open")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ else
{
<a @ref="RootElement" @attributes="HtmlAttributes" @onclick="HandleOnClick"
id="@_Id"
rel="@_rel"
style="@StyleBuilder.Value"
class="@ClassBuilder.Value"
dir="@Dir?.ToString().ToLower()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Bit.BlazorUI;

public partial class BitActionButton : BitComponentBase
{
private string? _rel;
private int? _tabIndex;
private BitButtonType _buttonType;

Expand Down Expand Up @@ -62,7 +63,9 @@ public partial class BitActionButton : BitComponentBase
/// The value of the href attribute of the link rendered by the button.
/// If provided, the component will be rendered as an anchor tag instead of button.
/// </summary>
[Parameter] public string? Href { get; set; }
[Parameter]
[CallOnSet(nameof(OnSetHrefAndRel))]
public string? Href { get; set; }

/// <summary>
/// The icon name of the icon to render inside the button.
Expand Down Expand Up @@ -90,6 +93,13 @@ public partial class BitActionButton : BitComponentBase
[Parameter, ResetClassBuilder]
public bool ReversedIcon { get; set; }

/// <summary>
/// If Href provided, specifies the relationship between the current document and the linked document.
/// </summary>
[Parameter]
[CallOnSet(nameof(OnSetHrefAndRel))]
public BitLinkRel? Rel { get; set; }

/// <summary>
/// The size of the button.
/// </summary>
Expand Down Expand Up @@ -172,4 +182,15 @@ protected virtual async Task HandleOnClick(MouseEventArgs e)
await OnClick.InvokeAsync(e);
}
}

private void OnSetHrefAndRel()
{
if (Rel.HasValue is false || Href.HasNoValue() || Href!.StartsWith('#'))
{
_rel = null;
return;
}

_rel = BitLinkRelUtils.GetRels(Rel.Value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Color" RazorCode="@example3RazorCode" Id="example3">
<ComponentExampleBox Title="Rel" RazorCode="@example3RazorCode" Id="example3">
<ExamplePreview>
<div>Use BitActionButton as a hyperlink to external URLs, with a rel attribute.</div>
<br />
<div class="example-content">
<BitActionButton Rel="BitLinkRel.NoFollow" Href="https://bitplatform.dev" Target="_blank" IconName="@BitIconName.Globe" Variant="BitVariant.Outline">
Open bitplatform.dev with a rel attribute (nofollow)
</BitActionButton>

<BitActionButton Rel="BitLinkRel.NoFollow | BitLinkRel.NoReferrer" Href="https://bitplatform.dev" Target="_blank" IconName="@BitIconName.Globe" Variant="BitVariant.Outline">
Open bitplatform.dev with a rel attribute (nofollow & noreferrer)
</BitActionButton>
</div>
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Color" RazorCode="@example4RazorCode" Id="example4">
<ExamplePreview>
<div>Demonstrates BitActionButton with various predefined colors: Primary, Secondary, Tertiary, Info, Success, Warning, SevereWarning, and Error.</div>
<br />
Expand Down Expand Up @@ -133,7 +149,7 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Size" RazorCode="@example4RazorCode" Id="example4">
<ComponentExampleBox Title="Size" RazorCode="@example5RazorCode" Id="example5">
<ExamplePreview>
<div>Show BitActionButton in different sizes: Small, Medium, and Large.</div>
<br />
Expand All @@ -145,7 +161,7 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Style & Class" RazorCode="@example5RazorCode" Id="example5">
<ComponentExampleBox Title="Style & Class" RazorCode="@example6RazorCode" Id="example6">
<ExamplePreview>
<div>Customize the appearance of BitActionButton using styles and CSS classes.</div>
<br />
Expand All @@ -167,7 +183,7 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Template" RazorCode="@example6RazorCode" Id="example6">
<ComponentExampleBox Title="Template" RazorCode="@example7RazorCode" Id="example7">
<ExamplePreview>
<div>Add custom template within BitActionButton.</div>
<br />
Expand All @@ -182,7 +198,7 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="Button Type" RazorCode="@example7RazorCode" CsharpCode="@example7CsharpCode" Id="example7">
<ComponentExampleBox Title="Button Type" RazorCode="@example8RazorCode" CsharpCode="@example8CsharpCode" Id="example8">
<ExamplePreview>
<div>Use BitActionButton within a form and validate its state.</div>
<br />
Expand Down Expand Up @@ -214,7 +230,7 @@
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="RTL" RazorCode="@example8RazorCode" Id="example8">
<ComponentExampleBox Title="RTL" RazorCode="@example9RazorCode" Id="example9">
<ExamplePreview>
<div>Use BitActionButton in right-to-left (RTL).</div>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public partial class BitActionButtonDemo
Description = "Reverses the positions of the icon and the content of the button.",
},
new()
{
Name = "Rel",
Type = "BitLinkRel?",
DefaultValue = "null",
Description = "If Href provided, specifies the relationship between the current document and the linked document.",
LinkType = LinkType.Link,
Href = "#button-rel",
},
new()
{
Name = "Size",
Type = "BitSize?",
Expand Down Expand Up @@ -334,5 +343,92 @@ public partial class BitActionButtonDemo
}
]
},
new()
{
Id = "button-rel",
Name = "BitLinkRel",
Description = "",
Items =
[
new()
{
Name = "Alternate",
Value = "1",
Description = "Provides a link to an alternate representation of the document. (i.e. print page, translated or mirror)"
},
new()
{
Name = "Author",
Value = "2",
Description = "Provides a link to the author of the document."
},
new()
{
Name = "Bookmark",
Value = "4",
Description = "Permanent URL used for bookmarking."
},
new()
{
Name = "External",
Value = "8",
Description = "Indicates that the referenced document is not part of the same site as the current document."
},
new()
{
Name = "Help",
Value = "16",
Description = "Provides a link to a help document."
},
new()
{
Name = "License",
Value = "32",
Description = "Provides a link to licensing information for the document."
},
new()
{
Name = "Next",
Value = "64",
Description = "Provides a link to the next document in the series."
},
new()
{
Name = "NoFollow",
Value = "128",
Description = @"Links to an unendorsed document, like a paid link. (""NoFollow"" is used by Google, to specify that the Google search spider should not follow that link)"
},
new()
{
Name = "NoOpener",
Value = "256",
Description = "Requires that any browsing context created by following the hyperlink must not have an opener browsing context."
},
new()
{
Name = "NoReferrer",
Value = "512",
Description = "Makes the referrer unknown. No referrer header will be included when the user clicks the hyperlink."
},
new()
{
Name = "Prev",
Value = "1024",
Description = "The previous document in a selection."
},
new()
{
Name = "Search",
Value = "2048",
Description = "Links to a search tool for the document."
},
new()
{
Name = "Tag",
Value = "4096",
Description = "A tag (keyword) for the current document."
}
]
},
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Go to bitplatform GitHub
</BitActionButton>";

private readonly string example3RazorCode = @"
<BitActionButton Rel=""BitLinkRel.NoFollow"" Href=""https://bitplatform.dev"" Target=""_blank"" IconName=""@BitIconName.Globe"" Variant=""BitVariant.Outline"">
Open bitplatform.dev with a rel attribute (nofollow)
</BitActionButton>
<BitActionButton Rel=""BitLinkRel.NoFollow | BitLinkRel.NoReferrer"" Href=""https://bitplatform.dev"" Target=""_blank"" IconName=""@BitIconName.Globe"" Variant=""BitVariant.Outline"">
Open bitplatform.dev with a rel attribute (nofollow & noreferrer)
</BitActionButton>";

private readonly string example4RazorCode = @"
<BitActionButton Color=""BitColor.Primary"" IconName=""@BitIconName.ColorSolid"">Primary</BitActionButton>
<BitActionButton Color=""BitColor.Primary"">Primary</BitActionButton>
Expand Down Expand Up @@ -69,12 +78,12 @@ Go to bitplatform GitHub
<BitActionButton Color=""BitColor.TertiaryBorder"" IconName=""@BitIconName.ColorSolid"">TertiaryBorder</BitActionButton>
<BitActionButton Color=""BitColor.TertiaryBorder"">TertiaryBorder</BitActionButton>";

private readonly string example4RazorCode = @"
private readonly string example5RazorCode = @"
<BitActionButton Size=""BitSize.Small"" IconName=""@BitIconName.FontSize"">Small</BitActionButton>
<BitActionButton Size=""BitSize.Medium"" IconName=""@BitIconName.FontSize"">Medium</BitActionButton>
<BitActionButton Size=""BitSize.Large"" IconName=""@BitIconName.FontSize"">Large</BitActionButton>";

private readonly string example5RazorCode = @"
private readonly string example6RazorCode = @"
<style>
.custom-icon {
color: hotpink;
Expand Down Expand Up @@ -119,15 +128,15 @@ Action Button Styles
Action Button Classes (Hover me)
</BitActionButton>";

private readonly string example6RazorCode = @"
private readonly string example7RazorCode = @"
<BitActionButton IconName=""@BitIconName.AddFriend"">
<div style=""display:flex;gap:0.5rem;"">
<div>This is a custom template</div>
<BitSpinnerLoading CustomSize=""20"" />
</div>
</BitActionButton>";

private readonly string example7RazorCode = @"
private readonly string example8RazorCode = @"
<EditForm Model=""validationButtonModel"" OnValidSubmit=""HandleValidSubmit"">
<DataAnnotationsValidator />
Expand All @@ -144,7 +153,7 @@ Action Button Classes (Hover me)
<BitActionButton IconName=""@BitIconName.ButtonControl"" ButtonType=""BitButtonType.Button"">Button</BitActionButton>
</div>
</EditForm>";
private readonly string example7CsharpCode = @"
private readonly string example8CsharpCode = @"
public class ButtonValidationModel
{
[Required]
Expand All @@ -164,7 +173,7 @@ private async Task HandleValidSubmit()
StateHasChanged();
}";

private readonly string example8RazorCode = @"
private readonly string example9RazorCode = @"
<BitActionButton Dir=""BitDir.Rtl"" IconName=""@BitIconName.AddFriend"">ساخت حساب</BitActionButton>";

}
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ private void SubscribeToSignalREventsMessages()
// You can also leverage IPubSubService to notify other components in the application.
}));

signalROnDisposables.Add(hubConnection.On<string>(SignalREvents.PUBLISH_MESSAGE, async (message) =>
signalROnDisposables.Add(hubConnection.On<string, object?>(SignalREvents.PUBLISH_MESSAGE, async (message, payload) =>
{
logger.LogInformation("SignalR Message {Message} received from server to publish.", message);
PubSubService.Publish(message);
PubSubService.Publish(message, payload);
}));

hubConnection.Closed += HubConnectionStateChange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected override async Task OnInitAsync()
{
unsubscribePageTitleChanged = PubSubService.Subscribe(ClientPubSubMessages.PAGE_TITLE_CHANGED, async payload =>
{
(pageTitle, pageSubtitle) = (ValueTuple<string?, string?>)payload!;
(pageTitle, pageSubtitle) = ((string, string))payload!;

StateHasChanged();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected override Task OnInitAsync()
{
unsubscribe = PubSubService.Subscribe(ClientPubSubMessages.SHOW_SNACK, async args =>
{
var (title, body, color) = (ValueTuple<string, string, BitColor>)args!;
var (title, body, color) = ((string, string, BitColor))args!;

await snackbarRef.Show(title, body, color);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ protected override async Task OnInitAsync()
{
if (payload is null) return;

user = (UserDto)payload;
user = payload is JsonElement jsonDocument
? jsonDocument.Deserialize(JsonSerializerOptions.GetTypeInfo<UserDto>())! // PROFILE_UPDATED can be invoked from server through SignalR
: (UserDto)payload;

await InvokeAsync(StateHasChanged);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class DashboardPage
protected async override Task OnInitAsync()
{
//#if (signalR == true)
unsubscribe = PubSubService.Subscribe(SharedPubSubMessages.DASHBOARD_DATA_CHANGED, async _ =>
unsubscribe = PubSubService.Subscribe(ClientPubSubMessages.DASHBOARD_DATA_CHANGED, async _ =>
{
NavigationManager.NavigateTo(Urls.DashboardPage, replace: true);
});
Expand Down
Loading

0 comments on commit 5a64fbe

Please sign in to comment.