Skip to content

Commit f4d8c41

Browse files
authored
Splade v0.5 (#51)
* Refactored Transitions + Public Transition/Animation API (#50) * Persistent layout (#47) * Teleport component * Lazy loading (#53)
1 parent 1221191 commit f4d8c41

File tree

94 files changed

+1546
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1546
-253
lines changed

ExtractTransitionClasses.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use ProtoneMedia\Splade\ServiceProvider;
4+
use ProtoneMedia\Splade\TransitionRepository;
5+
6+
require __DIR__ . '/vendor/autoload.php';
7+
8+
$transitionRepository = new TransitionRepository;
9+
10+
ServiceProvider::registerTransitionAnimations($transitionRepository);
11+
12+
$classes = implode(' ', $transitionRepository->classes());
13+
14+
file_put_contents(
15+
__DIR__ . '/resources/views/transitions/classes.blade.php',
16+
"<div class='{$classes}'>\n<!-- This is an automatically generated template so that Tailwind won't purge these transition classes... -->\n</div>",
17+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use ProtoneMedia\Splade\Facades\Splade;
6+
7+
class LazyController
8+
{
9+
public function show()
10+
{
11+
$sleep = request()->query('sleep', 1);
12+
13+
return view('lazy', [
14+
'always' => 'always',
15+
'init' => Splade::onInit('init'),
16+
'lazy' => Splade::onLazy(fn () => sleep($sleep) ? null : ['key' => 'Hi from controller!']),
17+
'time' => Splade::onLazy(fn () => sleep($sleep) ? null : now()->format('H:i:s')),
18+
]);
19+
}
20+
21+
public function notifications()
22+
{
23+
return view('notifications', [
24+
'notifications' => Splade::onLazy(fn () => sleep(1) ? null : ['Notification 1', 'Notification 2']),
25+
]);
26+
}
27+
}

app/app/Http/Controllers/NavigationController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ public function form()
3333
{
3434
return view('navigation.form');
3535
}
36+
37+
public function videoOne()
38+
{
39+
return view('navigation.videoOne');
40+
}
41+
42+
public function videoTwo()
43+
{
44+
return view('navigation.videoTwo');
45+
}
3646
}

app/app/View/Components/Header.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\View\Components;
4+
5+
use Illuminate\View\Component;
6+
7+
class Header extends Component
8+
{
9+
/**
10+
* Create a new component instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct(public string $title)
15+
{
16+
//
17+
}
18+
19+
/**
20+
* Get the view / contents that represent the component.
21+
*
22+
* @return \Illuminate\Contracts\View\View|\Closure|string
23+
*/
24+
public function render()
25+
{
26+
return view('components.header');
27+
}
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\View\Components;
4+
5+
use ProtoneMedia\Splade\Components\PersistentComponent;
6+
7+
class VideoLayout extends PersistentComponent
8+
{
9+
public function render()
10+
{
11+
return view('navigation.videoLayout');
12+
}
13+
}

app/public/video_no_audio.mp4

321 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
<h4>{{ $title }}</h4>
3+
<h5>{{ $subtitle }}</h5>
4+
<h6>{{ $attributes->get('help') }}</h6>
5+
6+
<div dusk="header-slot">{{ $slot }}</div>
7+
</div>

app/resources/views/lazy.blade.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@extends('layout')
2+
3+
@section('content')
4+
5+
LazyComponent
6+
7+
<h1>{{ $always }}</h1>
8+
<h2>{{ $init }}</h2>
9+
10+
<x-splade-lazy attr1="1">
11+
<x-slot:placeholder>
12+
<p>Placeholder 1</p>
13+
</x-slot:placeholder>
14+
15+
<h3>Lazy slot 1 : {{ $lazy['key'] }}</h3>
16+
</x-splade-lazy>
17+
18+
<x-splade-lazy attr2="2">
19+
<x-slot:placeholder>
20+
<p>Placeholder 2</p>
21+
</x-slot:placeholder>
22+
23+
<h4>Lazy slot 2 : {{ $lazy['key'] }}</h4>
24+
</x-splade-lazy>
25+
26+
<x-splade-toggle>
27+
<button class="block" @click="toggle">Load notifications</button>
28+
29+
<x-splade-lazy show="toggled" url="/lazy/notifications">
30+
<x-slot:placeholder>
31+
<p>Loading notifications...</p>
32+
</x-slot:placeholder>
33+
</x-splade-lazy>
34+
</x-splade-toggle>
35+
36+
<x-splade-toggle>
37+
<button class="block" @click="toggle">Load time</button>
38+
39+
<x-splade-lazy show="toggled">
40+
<x-slot:placeholder>
41+
<p>Want to see the time?</p>
42+
</x-slot:placeholder>
43+
44+
<h5>{{ $time }}</h5>
45+
</x-splade-lazy>
46+
</x-splade-toggle>
47+
48+
@endsection

app/resources/views/navigation/nav.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<Link dusk="three" href="/navigation/three">Three</Link>
55
<Link dusk="notFound" href="/navigation/notFound">notFound</Link>
66
<Link dusk="serverError" href="/navigation/serverError">serverError</Link>
7+
<Link dusk="video" href="/navigation/video/one">Video</Link>
8+
<Link dusk="lazy" href="/lazy">Lazy</Link>
79

810
<Link confirm dusk="confirm" href="/navigation/two">Confirm to two</Link>
911
<Link
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="container mt-4 mx-auto">
2+
<h1 class="text-3xl mb-8">{{ $title }}</h1>
3+
4+
{{ $subtitle }}
5+
6+
{{ $slot }}
7+
8+
<div class="fixed bottom-0 left-0 flex justify-between items-center bg-indigo-50 w-full">
9+
<h3 class="text-xl ml-8">Persistent Video</h3>
10+
<video class="w-full max-w-[16rem] aspect-video" controls loop muted>
11+
<source src="/video_no_audio.mp4" type="video/mp4">
12+
</video>
13+
</div>
14+
</div>

0 commit comments

Comments
 (0)