Skip to content

Commit 808fc32

Browse files
authored
Merge pull request #62 from laravelcm/fix-patch-discussions
Fix patch discussions
2 parents de5291c + 978e6a7 commit 808fc32

File tree

13 files changed

+59
-18
lines changed

13 files changed

+59
-18
lines changed

app/Http/Livewire/Articles/Browse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\Tag;
77
use App\Traits\WithInfiniteScroll;
88
use App\Traits\WithTags;
9+
use Illuminate\Contracts\View\View;
910
use Livewire\Component;
1011

1112
class Browse extends Component
@@ -26,7 +27,7 @@ public function validSort($sort): bool
2627
]);
2728
}
2829

29-
public function render()
30+
public function render(): View
3031
{
3132
$articles = Article::with('tags')->published()
3233
->notPinned()

app/Http/Livewire/Discussions/Browse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\Tag;
77
use App\Traits\WithInfiniteScroll;
88
use App\Traits\WithTags;
9+
use Illuminate\Contracts\View\View;
910
use Livewire\Component;
1011

1112
class Browse extends Component
@@ -17,7 +18,7 @@ class Browse extends Component
1718
'sortBy' => ['except' => 'recent'],
1819
];
1920

20-
public function validSort($sort): bool
21+
public function validSort(string $sort): bool
2122
{
2223
return in_array($sort, [
2324
'recent',
@@ -26,7 +27,7 @@ public function validSort($sort): bool
2627
]);
2728
}
2829

29-
public function render()
30+
public function render(): View
3031
{
3132
$discussions = Discussion::with('tags')
3233
->withCount('replies')

app/Markdown/MarkdownHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function replaceYouTubeTag($html, $tagArray, $original_string): st
4747
{
4848
if (isset($tagArray[2])) {
4949
$youtubeEmbedURL = $tagArray[2];
50-
$youtubeEmbed = '<iframe width="100%" height="399" src="https://www.youtube.com/embed/'.$youtubeEmbedURL.'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
50+
$youtubeEmbed = '<div class="overflow-hidden rounded-lg"><iframe width="100%" height="399" src="https://www.youtube.com/embed/'.$youtubeEmbedURL.'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>';
5151
$html = str_replace($original_string, $youtubeEmbed, $html);
5252
}
5353

app/Traits/WithInfiniteScroll.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait WithInfiniteScroll
1010

1111
public int $perPage = 10;
1212

13-
public function loadMore()
13+
public function loadMore(): void
1414
{
1515
$this->perPage += 10;
1616
}

app/Traits/WithTags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ trait WithTags
1010

1111
public string $sortBy = 'recent';
1212

13-
public function toggleTag($tag): void
13+
public function toggleTag(string $tag): void
1414
{
1515
$this->tag = $this->tag !== $tag && $this->tagExists($tag) ? $tag : null;
1616
}
1717

18-
public function sortBy($sort): void
18+
public function sortBy(string $sort): void
1919
{
2020
$this->sortBy = $this->validSort($sort) ? $sort : 'recent';
2121
}

database/factories/DiscussionFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
class DiscussionFactory extends Factory
99
{
10-
public function definition()
10+
/**
11+
* Define the model's default state.
12+
*
13+
* @return array<string, mixed>
14+
*/
15+
public function definition(): array
1116
{
1217
return [
1318
'user_id' => $attributes['user_id'] ?? User::factory(),

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"/js/app.js": "/js/app.js?id=3bd7a17ae8879cea08888521628605ff",
3-
"/css/app.css": "/css/app.css?id=a93547189b00f8df18704e2860e78505"
3+
"/css/app.css": "/css/app.css?id=7b8652dcf9744257f1400ac52d15a911"
44
}

resources/views/articles/show.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ class="inline-flex items-center py-2 px-4 border border-skin-base rounded-md sha
273273
@endif
274274

275275
<x-ads />
276+
277+
<x-discord />
276278
</div>
277279
</div>
278280
</article>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="overflow-hidden">
2+
<a href="{{ route('discord') }}">
3+
<svg class="w-auto h-12 text-[#5865F2]" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 272.1">
4+
<path d="M142.8 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11s-4.6-11-10.2-11zM106.3 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11 .1-6.1-4.5-11-10.2-11z"/>
5+
<path d="M191.4 36.9h-134c-11.3 0-20.5 9.2-20.5 20.5v134c0 11.3 9.2 20.5 20.5 20.5h113.4l-5.3-18.3 12.8 11.8 12.1 11.1 21.6 18.7V57.4c-.1-11.3-9.3-20.5-20.6-20.5zm-38.6 129.5s-3.6-4.3-6.6-8c13.1-3.7 18.1-11.8 18.1-11.8-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.4-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.6-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.2-1.8-1-2.8-1.7-2.8-1.7s4.8 7.9 17.5 11.7c-3 3.8-6.7 8.2-6.7 8.2-22.1-.7-30.5-15.1-30.5-15.1 0-31.9 14.4-57.8 14.4-57.8 14.4-10.7 28-10.4 28-10.4l1 1.2c-18 5.1-26.2 13-26.2 13s2.2-1.2 5.9-2.8c10.7-4.7 19.2-5.9 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.5 0 0-7.9-7.5-24.9-12.6l1.4-1.6s13.7-.3 28 10.4c0 0 14.4 25.9 14.4 57.8 0-.1-8.4 14.3-30.5 15zM303.8 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1h33.2c17.8.1 34.5-8.8 34.5-29.2v-29.8c.1-20.8-16.6-29.9-34.4-29.9zm174 59.7v-30.6c0-11 19.8-13.5 25.8-2.5l18.3-7.4c-7.2-15.8-20.3-20.4-31.2-20.4-17.8 0-35.4 10.3-35.4 30.3v30.6c0 20.2 17.6 30.3 35 30.3 11.2 0 24.6-5.5 32-19.9l-19.6-9c-4.8 12.3-24.9 9.3-24.9-1.4zM417.3 113c-6.9-1.5-11.5-4-11.8-8.3.4-10.3 16.3-10.7 25.6-.8l14.7-11.3c-9.2-11.2-19.6-14.2-30.3-14.2-16.3 0-32.1 9.2-32.1 26.6 0 16.9 13 26 27.3 28.2 7.3 1 15.4 3.9 15.2 8.9-.6 9.5-20.2 9-29.1-1.8l-14.2 13.3c8.3 10.7 19.6 16.1 30.2 16.1 16.3 0 34.4-9.4 35.1-26.6 1-21.7-14.8-27.2-30.6-30.1zm-67 55.5h22.4V79.7h-22.4v88.8zM728 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1H728c17.8.1 34.5-8.8 34.5-29.2v-29.8c0-20.8-16.7-29.9-34.5-29.9zm-162.9-1.2c-18.4 0-36.7 10-36.7 30.5v30.3c0 20.3 18.4 30.5 36.9 30.5 18.4 0 36.7-10.2 36.7-30.5V109c0-20.4-18.5-30.5-36.9-30.5zm14.4 60.8c0 6.4-7.2 9.7-14.3 9.7-7.2 0-14.4-3.1-14.4-9.7V109c0-6.5 7-10 14-10 7.3 0 14.7 3.1 14.7 10v30.3zM682.4 109c-.5-20.8-14.7-29.2-33-29.2h-35.5v88.8h22.7v-28.2h4l20.6 28.2h28L665 138.1c10.7-3.4 17.4-12.7 17.4-29.1zm-32.6 12h-13.2v-20.3h13.2c14.1 0 14.1 20.3 0 20.3z"/>
6+
</svg>
7+
<p class="mt-1 text-base leading-6 text-skin-inverted">
8+
<strong class="block">Laravel Cameroun Discord</strong>
9+
<span class="block mt-2 text-sm text-skin-base">Rejoignez le serveur Discord de la communauté et connectez-vous avec d'autres développeurs partageant les mêmes objectifs !</span>
10+
</p>
11+
</a>
12+
</div>

resources/views/components/discussions/overview.blade.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
</div>
3434
</div>
3535
<div class="hidden sm:flex sm:items-center space-x-3">
36-
<livewire:reactions
37-
wire:key="{{ $discussion->id }}"
38-
:model="$discussion"
39-
direction="left"
40-
:with-place-holder="false"
41-
:with-background="false"
42-
/>
36+
@if($discussion->getReactionsSummary()->isNotEmpty())
37+
<div class="flex items-center justify-center space-x-2">
38+
@foreach($discussion->getReactionsSummary() as $reaction)
39+
<img class="w-4 h-4" src="{{ asset("/images/reactions/{$reaction->name}.svg") }}" alt="{{ $reaction->name }} emoji">
40+
@endforeach
41+
<span class="ml-3 text-sm font-medium text-green-500">{{ $discussion->getReactionsSummary()->sum('count') }}</span>
42+
</div>
43+
@endif
4344
<p class="inline-flex text-sm space-x-2 text-skin-base">
4445
<x-heroicon-o-chat-alt-2 class="h-5 w-5" />
4546
<span class="font-normal text-skin-inverted-muted">{{ $discussion->count_all_replies_with_child }}</span>

resources/views/livewire/articles/browse.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class="mt-5 flex justify-center"
5555
<x-sponsors />
5656

5757
<x-ads />
58+
59+
<x-discord />
5860
</div>
5961
</div>
6062
</div>

resources/views/livewire/discussions/browse.blade.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
@endauth
2020
</aside>
2121
</div>
22-
<div class="relative lg:col-span-7">
22+
<div
23+
x-data
24+
x-intersect="@this.call('loadMore')"
25+
class="relative lg:col-span-7"
26+
>
2327
<div class="w-full">
2428
<nav class="relative z-0 rounded-lg shadow flex divide-x divide-skin-base" aria-label="Tabs">
2529
<button
@@ -58,6 +62,19 @@ class="w-full {{ $selectedSortBy === 'active' ? 'text-skin-inverted': 'text-skin
5862
<x-discussions.overview :discussion="$discussion" />
5963
@endforeach
6064
</div>
65+
66+
@if($discussions->hasMorePages())
67+
<div
68+
x-data
69+
x-intersect="@this.call('loadMore')"
70+
class="mt-5 flex justify-center"
71+
>
72+
<p class="flex items-center">
73+
<x-loader class="text-skin-primary" />
74+
Chargement...
75+
</p>
76+
</div>
77+
@endif
6178
</div>
6279
<div class="hidden relative lg:block lg:col-span-3">
6380
@include('discussions._contributions')

0 commit comments

Comments
 (0)