mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
feat: position filter
This commit is contained in:
@@ -51,9 +51,13 @@ class ChampionController extends Controller
|
||||
return $champion->load('skins', 'lanes');
|
||||
});
|
||||
|
||||
$splashColor = Cache::remember('championSplashColorCache' . $champion->slug, 60 * 60 * 24, function () use ($champion) {
|
||||
$splashColor = Cache::remember(
|
||||
'championSplashColorCache' . $champion->slug,
|
||||
60 * 60 * 24,
|
||||
function () use ($champion) {
|
||||
return getAverageColorFromImageUrl($champion->getChampionImageAttribute());
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$champion->splash_color = $splashColor;
|
||||
|
||||
|
||||
35
resources/js/lane-filter.js
Normal file
35
resources/js/lane-filter.js
Normal file
@@ -0,0 +1,35 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const laneFilters = document.querySelectorAll('.lane-filter');
|
||||
const championDivs = document.querySelectorAll('.champ-card');
|
||||
|
||||
laneFilters.forEach((filter) => {
|
||||
filter.addEventListener('click', function () {
|
||||
const selectedLane = filter.getAttribute('data-lane');
|
||||
|
||||
if (filter.classList.contains('opacity-100')) {
|
||||
// If the filter is already active, unselect it and show all
|
||||
championDivs.forEach((championDiv) => {
|
||||
championDiv.style.display = 'block';
|
||||
});
|
||||
filter.classList.remove('opacity-100');
|
||||
filter.classList.add('opacity-40');
|
||||
} else {
|
||||
// If the filter is not active, activate it and filter champions
|
||||
laneFilters.forEach((otherFilter) => {
|
||||
otherFilter.classList.remove('opacity-100');
|
||||
otherFilter.classList.add('opacity-40');
|
||||
});
|
||||
filter.classList.remove('opacity-40');
|
||||
filter.classList.add('opacity-100');
|
||||
|
||||
championDivs.forEach((championDiv) => {
|
||||
if (selectedLane === 'All' || championDiv.classList.contains('POS-' + selectedLane)) {
|
||||
championDiv.style.display = 'block';
|
||||
} else {
|
||||
championDiv.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
@vite('resources/css/app.css')
|
||||
@vite('resources/js/app.js')
|
||||
@vite('resources/js/lane-filter.js')
|
||||
</head>
|
||||
|
||||
<body class="antialiased bg-stone-900 dark scroll-smooth">
|
||||
|
||||
19
resources/views/components/champions/lane-selector.blade.php
Normal file
19
resources/views/components/champions/lane-selector.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="lane-selector">
|
||||
<div class="flex mt-2">
|
||||
<div class="cursor-pointer mr-4 lane-icon lane-filter opacity-40 hover:opacity-70" data-lane="Toplane">
|
||||
<x-icon-position-top class="text-orange-400"/>
|
||||
</div>
|
||||
<div class="cursor-pointer mr-4 lane-icon lane-filter opacity-40 hover:opacity-70" data-lane="Jungle">
|
||||
<x-icon-position-jungle class="text-orange-400"/>
|
||||
</div>
|
||||
<div class="cursor-pointer mr-4 lane-icon lane-filter opacity-40 hover:opacity-70" data-lane="Midlane">
|
||||
<x-icon-position-middle class="text-orange-400"/>
|
||||
</div>
|
||||
<div class="cursor-pointer mr-4 lane-icon lane-filter opacity-40 hover:opacity-70" data-lane="Botlane">
|
||||
<x-icon-position-bottom class="text-orange-400"/>
|
||||
</div>
|
||||
<div class="cursor-pointer lane-icon lane-filter opacity-40 hover:opacity-70" data-lane="Support">
|
||||
<x-icon-position-utility class="text-orange-400"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,21 +3,22 @@
|
||||
|
||||
/** @var App\Models\ChampionRole $roles */
|
||||
?>
|
||||
|
||||
|
||||
<section class="max-w-screen-xl mx-auto mt-12">
|
||||
<h2
|
||||
class="text-3xl font-bold text-center text-transparent uppercase sm:text-4xl
|
||||
bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
Champions</h2>
|
||||
<div class="flex justify-center items-center mx-auto max-w-screen-xl mt-2.5">
|
||||
<x-champions.lane-selector class="text-center"/>
|
||||
</div>
|
||||
|
||||
<div class="container mx-auto p-4 flex items-center justify-center mt-3">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-12 ">
|
||||
|
||||
@foreach($champions as $key => $champion)
|
||||
<div
|
||||
class="flex flex-col text-gray-700 bg-stone-800/40 shadow-md rounded-2xl bg-clip-border
|
||||
border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||
class="champ-card flex flex-col text-gray-700 bg-stone-800/40 shadow-md rounded-2xl bg-clip-border
|
||||
border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10 @foreach($roles[$key]->roles as $lane)POS-{{$lane}}@endforeach">
|
||||
<div
|
||||
class="mx-4 mt-4 overflow-hidden h-52 rounded-2xl bg-clip-border border-2 border-orange-400/40">
|
||||
<img @if($key < 8) loading="eager" @else loading="lazy" @endif
|
||||
|
||||
Reference in New Issue
Block a user