generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from kaptk2/widget-configurations
- Loading branch information
Showing
19 changed files
with
191 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
|
||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/[email protected].5 | ||
uses: dependabot/[email protected].4 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
|
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,19 @@ | ||
<div | ||
class="cf-turnstile" | ||
data-sitekey="{{ config('services.turnstile.key') }}" | ||
@if ($attributes->has('wire:model')) | ||
wire:ignore | ||
data-callback="captchaCallback" | ||
{{ $attributes->filter(fn($value, $key) => ! in_array($key, ['data-callback', 'wire:model'])) }} | ||
@else | ||
{{ $attributes->whereStartsWith('data-') }} | ||
@endif | ||
></div> | ||
|
||
@if ($attributes->has('wire:model')) | ||
<script> | ||
function captchaCallback(token) { | ||
@this.set("{{ $attributes->get('wire:model') }}", token); | ||
} | ||
</script> | ||
@endif |
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,18 @@ | ||
<?php | ||
|
||
namespace RyanChandler\LaravelCloudflareTurnstile\View\Components; | ||
|
||
use Illuminate\View\Component; | ||
|
||
class Turnstile extends Component | ||
{ | ||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return \Illuminate\Contracts\View\View|\Closure|string | ||
*/ | ||
public function render() | ||
{ | ||
return view('cloudflare-turnstile::components.turnstile'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Blade; | ||
use function Spatie\Snapshots\assertMatchesHtmlSnapshot; | ||
|
||
beforeEach(function () { | ||
config()->set('services.turnstile.key', '1x00000000000000000000AA'); | ||
config()->set('services.turnstile.secret', '2x0000000000000000000000000000000AA'); | ||
}); | ||
|
||
it('can render a turnstile widget', function () { | ||
$html = Blade::render('<x-turnstile />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom action', function () { | ||
$html = Blade::render('<x-turnstile data-action="test-action" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom cdata', function () { | ||
$html = Blade::render('<x-turnstile data-cdata="test-cdata" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom callback', function () { | ||
$html = Blade::render('<x-turnstile data-callback="testCallback" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom expired callback', function () { | ||
$html = Blade::render('<x-turnstile data-expired-callback="testExpiredCallback" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom error callback', function () { | ||
$html = Blade::render('<x-turnstile data-error-callback="testErrorCallback" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a custom theme', function () { | ||
$html = Blade::render('<x-turnstile data-theme="dark" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a tabindex', function () { | ||
$html = Blade::render('<x-turnstile data-tabindex="1" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); | ||
|
||
it('can render a turnstile widget with a wire model', function () { | ||
$html = Blade::render('<x-turnstile wire:model="captcha" />'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); |
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,10 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Blade; | ||
use function Spatie\Snapshots\assertMatchesHtmlSnapshot; | ||
|
||
it('can render a turnstile script snippet', function () { | ||
$html = Blade::render('@turnstileScripts'); | ||
|
||
assertMatchesHtmlSnapshot($html); | ||
}); |
4 changes: 4 additions & 0 deletions
4
tests/__snapshots__/TurnstileBladeDirectiveTest__it_can_render_a_turnstile_widget__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...urnstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_action__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-action="test-action"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...nstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_callback__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-callback="testCallback"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...TurnstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_cdata__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-cdata="test-cdata"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...BladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_error_callback__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-error-callback="testErrorCallback"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...adeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_expired_callback__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-expired-callback="testExpiredCallback"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...TurnstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_custom_theme__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-theme="dark"></div> | ||
|
||
</body></html> |
4 changes: 4 additions & 0 deletions
4
...s__/TurnstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_tabindex__1.html
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,4 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" data-tabindex="1"></div> | ||
|
||
</body></html> |
9 changes: 9 additions & 0 deletions
9
..._/TurnstileBladeDirectiveTest__it_can_render_a_turnstile_widget_with_a_wire_model__1.html
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,9 @@ | ||
<html><body> | ||
<div class="cf-turnstile" data-sitekey="1x00000000000000000000AA" wire:ignore data-callback="captchaCallback"></div> | ||
|
||
<script> | ||
function captchaCallback(token) { | ||
@this.set("captcha", token); | ||
} | ||
</script> | ||
</body></html> |
1 change: 1 addition & 0 deletions
1
...ots__/TurnstileScriptBladeDirectiveTest__it_can_render_a_turnstile_script_snippet__1.html
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 @@ | ||
<html><head><script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script></head></html> |