Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway page #918

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Havit.Blazor.Documentation/Pages/Premium/GatewayToPremium.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@page "/premium/access-content"

<HeadContent>
@GenerateHeadContent()
</HeadContent>

<h1>HAVIT Blazor Premium</h1>

<p class="lead">Only for premium subscribers.</p>

<div class="hstack align-items-start gap-3">
<HxButton Text="How to get access?" Size="ButtonSize.Large" Color="ThemeColor.Primary" OnClick="LearnMoreAboutPremium" />
<div>
<HxButton Text="Continue"
Size="ButtonSize.Large"
Color="ThemeColor.Secondary"
OnClick="ContinueToPremiumContent"
Outline="true" />
<HxCheckbox @bind-Value="_skipGatewayPage" Text="Skip this page next time" CssClass="mt-1" TextCssClass="small" />
</div>
</div>
50 changes: 50 additions & 0 deletions Havit.Blazor.Documentation/Pages/Premium/GatewayToPremium.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.JSInterop;

namespace Havit.Blazor.Documentation.Pages.Premium;

public partial class GatewayToPremium
{
[SupplyParameterFromQuery] public string Url { get; set; }

[Inject] private NavigationManager NavigationManager { get; set; }
[Inject] private IJSRuntime JSRuntime { get; set; }

private IJSObjectReference _jsModule;

private bool _skipGatewayPage = false;
private string _gitHubFolderUrl = "https://github.com/havit/Havit.Blazor.Premium";

protected override void OnParametersSet()
{
_gitHubFolderUrl = Uri.UnescapeDataString(Url);
}

private void LearnMoreAboutPremium()
{
NavigationManager.NavigateTo("/premium");
}

private async Task ContinueToPremiumContent()
{
if (_skipGatewayPage)
{
await EnsureJsModuleAsync();
await _jsModule.InvokeVoidAsync("setSkipGatewayPage", true);
}
NavigationManager.NavigateTo(_gitHubFolderUrl);
}

private async Task EnsureJsModuleAsync()
{
_jsModule ??= await JSRuntime.ImportModuleAsync($"./Pages/Premium/{nameof(GatewayToPremium)}.razor.js");
}

private MarkupString GenerateHeadContent()
{
return (MarkupString)$@"<script>
if (document.cookie.split(';').some((item) => item.trim() === 'SkipGatewayPage=true')) {{
window.location.href = '{_gitHubFolderUrl}'
}}
</script>";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function setSkipGatewayPage(skipGatewayPage) {
const date = new Date();
date.setTime(date.getTime() + (60 * 24 * 60 * 60 * 1000)); // 60 days
document.cookie = "SkipGatewayPage=" + skipGatewayPage + "; expires = " + date.toGMTString() + "; path = /";
}
4 changes: 2 additions & 2 deletions Havit.Blazor.Documentation/Pages/Premium/GetPremium.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/premium/"
@page "/premium"
@layout EmptyLayout

<PageTitle>Get Premium | HAVIT Blazor Bootstrap - Free components for ASP.NET Core Blazor</PageTitle>
Expand Down Expand Up @@ -62,7 +62,7 @@
<p class="fw-medium">Contact sales</p>
<div class="d-flex flex-column gap-2 opacity-75 mb-5 mt-2 small">
<strong>Tailor-made support for your team</strong>
<PlanItem Text="Regular team consulations (mentorship)" />
<PlanItem Text="Regular team consultations (mentorship)" />
<PlanItem Text="Custom components development" />
<PlanItem Text="Enterprise support" />
<PlanItem Text="Custom themes implementation" />
Expand Down
2 changes: 1 addition & 1 deletion Havit.Blazor.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# 17
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Havit.Blazor.Components.Web", "Havit.Blazor.Components.Web\Havit.Blazor.Components.Web.csproj", "{DF1C423F-ACA1-446E-A9F1-099DFDF70D44}"
Expand Down