-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
samples/BlazorWebAssembly/Pages/AppearanceModeInteractionOnly.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,42 @@ | ||
@using BlazorTurnstile | ||
|
||
<Turnstile @bind-Token="@_turnstileToken" | ||
SiteKey="1x00000000000000000000AA" | ||
OnCallback="@TurnstileCallback" | ||
OnErrorCallback="@TurnstileErrorCallback" | ||
Theme="@TurnstileTheme.Light" | ||
Appearance="@TurnstileAppearance.InteractionOnly" | ||
@ref="turnstile" /> | ||
|
||
<button class="btn btn-secondary" @onclick="ResetTurnstile">Reset Turnstile</button> | ||
|
||
<h3 class="mt-3 h4">Token:</h3> | ||
@if (_turnstileToken != null) | ||
{ | ||
@_turnstileToken | ||
} | ||
else | ||
{ | ||
<i>Loading or error...</i> | ||
} | ||
|
||
@code { | ||
private Turnstile turnstile = default!; | ||
|
||
private string? _turnstileToken; | ||
|
||
private void TurnstileCallback(string token) | ||
{ | ||
Console.WriteLine($"Turnstile Token: {token}"); | ||
} | ||
|
||
private void TurnstileErrorCallback(string message) | ||
{ | ||
Console.WriteLine($"Turnstile Error: {message}"); | ||
} | ||
|
||
private async void ResetTurnstile() | ||
{ | ||
await turnstile.ResetAsync(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
samples/BlazorWebAssembly/Pages/ExecutionModeExecute.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,49 @@ | ||
@using BlazorTurnstile | ||
|
||
<Turnstile @bind-Token="@_turnstileToken" | ||
SiteKey="1x00000000000000000000AA" | ||
OnCallback="@TurnstileCallback" | ||
OnErrorCallback="@TurnstileErrorCallback" | ||
Theme="@TurnstileTheme.Light" | ||
Appearance="@TurnstileAppearance.Execute" | ||
Execution="@TurnstileExecution.Execute" | ||
@ref="turnstile" /> | ||
|
||
<button class="btn btn-primary" @onclick="ExecuteTurnstile">Execute Turnstile</button> | ||
<button class="btn btn-secondary" @onclick="ResetTurnstile">Reset Turnstile</button> | ||
|
||
<h3 class="mt-3 h4">Token:</h3> | ||
@if (_turnstileToken != null) | ||
{ | ||
@_turnstileToken | ||
} | ||
else | ||
{ | ||
<i>Waiting for execution...</i> | ||
} | ||
|
||
@code { | ||
private Turnstile turnstile = default!; | ||
|
||
private string? _turnstileToken; | ||
|
||
private void TurnstileCallback(string token) | ||
{ | ||
Console.WriteLine($"Turnstile Token: {token}"); | ||
} | ||
|
||
private void TurnstileErrorCallback(string message) | ||
{ | ||
Console.WriteLine($"Turnstile Error: {message}"); | ||
} | ||
|
||
private async void ExecuteTurnstile() | ||
{ | ||
await turnstile.ExecuteAsync(); | ||
} | ||
|
||
private async void ResetTurnstile() | ||
{ | ||
await turnstile.ResetAsync(); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace BlazorTurnstile; | ||
|
||
public enum TurnstileExecution | ||
{ | ||
Render, | ||
Execute | ||
} |
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