Skip to content

Commit

Permalink
Adds a refresh-method and refresh-scroll components
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Jan 5, 2024
1 parent 235e89c commit dad79c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions resources/views/components/refresh-method.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@props(['method' => 'replace'])

@php
throw_unless(in_array($method, ['replace', 'morph']), HotwiredLaravel\TurboLaravel\Exceptions\PageRefreshStrategyException::invalidRefreshMethod($method));
@endphp

<meta name="turbo-refresh-method" content="{{ $method }}">

7 changes: 7 additions & 0 deletions resources/views/components/refresh-scroll.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@props(['scroll' => 'reset'])

@php
throw_unless(in_array($scroll, ['reset', 'preserve']), HotwiredLaravel\TurboLaravel\Exceptions\PageRefreshStrategyException::invalidRefreshScroll($scroll));
@endphp

<meta name="turbo-refresh-scroll" content="{{ $scroll }}">
9 changes: 2 additions & 7 deletions resources/views/components/refreshes-with.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
@props(['method' => 'replace', 'scroll' => 'reset'])

@php
throw_unless(in_array($method, ['replace', 'morph']), HotwiredLaravel\TurboLaravel\Exceptions\PageRefreshStrategyException::invalidRefreshMethod($method));
throw_unless(in_array($scroll, ['reset', 'preserve']), HotwiredLaravel\TurboLaravel\Exceptions\PageRefreshStrategyException::invalidRefreshScroll($scroll));
@endphp

<meta name="turbo-refresh-method" content="{{ $method }}">
<meta name="turbo-refresh-scroll" content="{{ $scroll }}">
<x-turbo::refresh-method :method="$method" />
<x-turbo::refresh-scroll :scroll="$scroll" />

0 comments on commit dad79c7

Please sign in to comment.