Use CSS classes to hide n-th elements instead of JS
This commit is contained in:
@@ -28,6 +28,4 @@
|
||||
<div class="mx-auto pt-6 sm:px-6 lg:px-8 space-y-6 max-w-[100%] xl:max-w-[95%] 2xl:max-w-[85%] pb-2">
|
||||
@include('home.partials.comments')
|
||||
</div>
|
||||
|
||||
@vite(['resources/js/responsive.js'])
|
||||
</x-app-layout>
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
@php
|
||||
$random = \cache()->remember('random_home', 300, function () {
|
||||
return \App\Models\Episode::inRandomOrder()->limit(7)->get(); ;
|
||||
return \App\Models\Episode::inRandomOrder()->limit(16)->get(); ;
|
||||
});
|
||||
@endphp
|
||||
|
||||
<div class="mb-6">
|
||||
@include('home.partials.tab.template', ['episodes' => $random, 'isThumbnail' => false, 'rowsCount' => 1])
|
||||
@include('home.partials.tab.template', ['episodes' => $random, 'isThumbnail' => false])
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
@props([
|
||||
'isThumbnail',
|
||||
'rowsCount' => 2,
|
||||
])
|
||||
@props(['isThumbnail'])
|
||||
|
||||
@php
|
||||
$gridClasses = $isThumbnail
|
||||
? 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4'
|
||||
: 'grid-cols-2 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 3xl:grid-cols-7';
|
||||
|
||||
// Render enough items for largest possible layout
|
||||
$limit = 24;
|
||||
$limit = 16;
|
||||
|
||||
$view = $isThumbnail ? 'thumbnail' : 'poster';
|
||||
@endphp
|
||||
|
||||
@if ($isThumbnail)
|
||||
<div
|
||||
class="episode-grid grid {{ $gridClasses }}"
|
||||
data-rows="{{ $rowsCount }}"
|
||||
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5
|
||||
[&>.episode-item]:hidden
|
||||
[&>.episode-item:nth-child(-n+8)]:block
|
||||
md:[&>.episode-item:nth-child(-n+8)]:block
|
||||
lg:[&>.episode-item:nth-child(-n+9)]:block
|
||||
xl:[&>.episode-item:nth-child(-n+9)]:block
|
||||
2xl:[&>.episode-item:nth-child(-n+12)]:block
|
||||
3xl:[&>.episode-item:nth-child(-n+15)]:block"
|
||||
>
|
||||
@else
|
||||
<div
|
||||
class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-4 2xl:grid-cols-5 3xl:grid-cols-8
|
||||
[&>.episode-item]:hidden
|
||||
[&>.episode-item:nth-child(-n+12)]:block
|
||||
md:[&>.episode-item:nth-child(-n+12)]:block
|
||||
xl:[&>.episode-item:nth-child(-n+12)]:block
|
||||
2xl:[&>.episode-item:nth-child(-n+15)]:block
|
||||
3xl:[&>.episode-item:nth-child(-n+16)]:block"
|
||||
>
|
||||
@endif
|
||||
@foreach ($episodes->take($limit) as $ep)
|
||||
@php
|
||||
$episode = isset($popularView)
|
||||
|
||||
Reference in New Issue
Block a user