-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Gateway page to HBP GitHub repo * Gateway page to HBP GitHub repo - skip next time functionality * Gateway page - text adj. * review - simplification, fixes --------- Co-authored-by: Robert Haken <haken@havit.cz>
- Loading branch information
1 parent
27a3d80
commit aa4c10f
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
Havit.Blazor.Documentation/Pages/Premium/GatewayToPremium.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@page "/premium/access-content" | ||
|
||
<HeadContent> | ||
@GenerateHeadContent() | ||
</HeadContent> | ||
|
||
<h1>HAVIT Blazor Premium</h1> | ||
|
||
<p class="lead">You are accessing content for Premium subscribers.</p> | ||
|
||
<div class="hstack align-items-start gap-3"> | ||
<div> | ||
<HxButton Text="Continue" | ||
Size="ButtonSize.Large" | ||
Color="ThemeColor.Primary" | ||
OnClick="ContinueToPremiumContent" /> | ||
<HxCheckbox @bind-Value="_skipGatewayPage" Text="Skip this page next time" CssClass="mt-1" TextCssClass="small" /> | ||
</div> | ||
<HxButton Text="How to get Premium" | ||
Size="ButtonSize.Large" | ||
Color="ThemeColor.Secondary" | ||
Outline="true" | ||
OnClick="LearnMoreAboutPremium" /> | ||
</div> |
53 changes: 53 additions & 0 deletions
53
Havit.Blazor.Documentation/Pages/Premium/GatewayToPremium.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace Havit.Blazor.Documentation.Pages.Premium; | ||
|
||
public partial class GatewayToPremium : IAsyncDisposable | ||
{ | ||
[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 void LearnMoreAboutPremium() | ||
{ | ||
NavigationManager.NavigateTo("/premium"); | ||
} | ||
|
||
private async Task ContinueToPremiumContent() | ||
{ | ||
if (_skipGatewayPage) | ||
{ | ||
await EnsureJsModuleAsync(); | ||
await _jsModule.InvokeVoidAsync("setSkipGatewayPage", true); | ||
} | ||
NavigationManager.NavigateTo(Url); | ||
} | ||
|
||
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 = '{{Url}}' | ||
} | ||
</script> | ||
"""; | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_jsModule != null) | ||
{ | ||
await _jsModule.DisposeAsync(); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Havit.Blazor.Documentation/Pages/Premium/GatewayToPremium.razor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = /"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters