Poprawki w wyszikiwaniu kanałów i wyświetlaniu

This commit is contained in:
dm
2025-12-13 12:34:37 +01:00
parent 32d77ac5ad
commit 71d1b18314
6 changed files with 266 additions and 317 deletions

View File

@@ -46,13 +46,6 @@ if (section.image) {
<JamboxChannelsSearch client:load /> <JamboxChannelsSearch client:load />
{section.button && (
<div class="f-section-nav">
<a href={section.button.url} class="btn btn-primary" title={section.button.title}>
{section.button.text}
</a>
</div>
)}
</div> </div>
</div> </div>
</section> </section>

View File

@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from "preact/hooks"; import { useEffect, useMemo, useState } from "preact/hooks";
import "../../styles/modal.css"; import "../../styles/modal.css";
import "../../styles/offers/offers-table.css"; import "../../styles/offers/offers-table.css";
import "../../styles/channels-search.css"; // żeby input miał identyczny styl import "../../styles/channels-search.css";
export default function JamboxChannelsModal({ isOpen, onClose, pkg }) { export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
const [channels, setChannels] = useState([]); const [channels, setChannels] = useState([]);
@@ -18,9 +18,8 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
const meta = useMemo(() => { const meta = useMemo(() => {
if (loading) return "Ładowanie…"; if (loading) return "Ładowanie…";
if (error) return error; if (error) return error;
if (!query.trim()) return `Wyniki: ${filtered.length} / ${channels.length}`;
return `Wyniki: ${filtered.length} / ${channels.length}`; return `Wyniki: ${filtered.length} / ${channels.length}`;
}, [loading, error, query, filtered.length, channels.length]); }, [loading, error, filtered.length, channels.length]);
useEffect(() => { useEffect(() => {
if (!isOpen || !pkg?.id) return; if (!isOpen || !pkg?.id) return;
@@ -36,7 +35,6 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
try { try {
const params = new URLSearchParams({ packageId: String(pkg.id) }); const params = new URLSearchParams({ packageId: String(pkg.id) });
const res = await fetch(`/api/jambox/channels?${params.toString()}`); const res = await fetch(`/api/jambox/channels?${params.toString()}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`); if (!res.ok) throw new Error(`HTTP ${res.status}`);
const json = await res.json(); const json = await res.json();
@@ -81,7 +79,6 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
<div class="max-w-8xl mx-auto px-3 md:px-6"> <div class="max-w-8xl mx-auto px-3 md:px-6">
<h2 class="f-modal-title">Kanały w pakiecie {pkg.name}</h2> <h2 class="f-modal-title">Kanały w pakiecie {pkg.name}</h2>
{/* INPUT jak w wyszukiwarce (z własnym X) */}
<div class="f-chsearch__top"> <div class="f-chsearch__top">
<div class="f-chsearch__inputwrap"> <div class="f-chsearch__inputwrap">
<input <input
@@ -99,13 +96,14 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
class="f-chsearch__clear" class="f-chsearch__clear"
aria-label="Wyczyść wyszukiwanie" aria-label="Wyczyść wyszukiwanie"
onClick={() => setQuery("")} onClick={() => setQuery("")}
onMouseDown={(e) => e.preventDefault()} // nie zabieraj focusa inputowi onMouseDown={(e) => e.preventDefault()}
> >
</button> </button>
)} )}
</div> </div>
{/* ✅ tu musi być __meta */}
<div class="f-chsearch__meta">{meta}</div> <div class="f-chsearch__meta">{meta}</div>
</div> </div>
@@ -117,19 +115,25 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
{filtered.length === 0 ? ( {filtered.length === 0 ? (
<p>Brak kanałów spełniających kryteria.</p> <p>Brak kanałów spełniających kryteria.</p>
) : ( ) : (
<div class="f-section-channel"> <div class="jmb-channels-grid">
{filtered.map((ch) => ( {filtered.map((ch) => (
<div <div
class="jmb-channel-card" class="jmb-channel-card"
key={ch.number} key={ch.number}
role="button"
tabIndex={0}
onClick={(e) => { onClick={(e) => {
// żeby klik w link w opisie nie flipował
if (e.target.closest("a, button")) return; if (e.target.closest("a, button")) return;
e.currentTarget.classList.toggle("is-flipped"); e.currentTarget.classList.toggle("is-flipped");
}} }}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
e.currentTarget.classList.toggle("is-flipped");
}
}}
> >
<div class="jmb-channel-inner"> <div class="jmb-channel-inner">
{/* FRONT */}
<div class="jmb-channel-face jmb-channel-front"> <div class="jmb-channel-face jmb-channel-front">
{ch.logo_url && ( {ch.logo_url && (
<img <img
@@ -143,7 +147,6 @@ export default function JamboxChannelsModal({ isOpen, onClose, pkg }) {
<div class="jmb-channel-number">kanał {ch.number}</div> <div class="jmb-channel-number">kanał {ch.number}</div>
</div> </div>
{/* BACK */}
<div class="jmb-channel-face jmb-channel-back"> <div class="jmb-channel-face jmb-channel-back">
<div class="jmb-channel-back-title">{ch.name}</div> <div class="jmb-channel-back-title">{ch.name}</div>
<div <div

View File

@@ -13,7 +13,7 @@ export default function JamboxChannelsSearch() {
const qq = q.trim(); const qq = q.trim();
setErr(""); setErr("");
if (qq.length < 2) { if (qq.length === 0) {
setItems([]); setItems([]);
setLoading(false); setLoading(false);
return; return;
@@ -58,7 +58,8 @@ export default function JamboxChannelsSearch() {
const meta = useMemo(() => { const meta = useMemo(() => {
const qq = q.trim(); const qq = q.trim();
if (qq.length < 2) return "Wpisz min. 2 znaki"; if (qq.length === 0) return "";
// "Zacznij pisać, aby wyszukać"
if (loading) return "Szukam…"; if (loading) return "Szukam…";
if (err) return err; if (err) return err;
return `Znaleziono: ${items.length}`; return `Znaleziono: ${items.length}`;
@@ -71,7 +72,7 @@ export default function JamboxChannelsSearch() {
el.scrollIntoView({ behavior: "smooth", block: "start" }); el.scrollIntoView({ behavior: "smooth", block: "start" });
el.classList.add("is-target"); el.classList.add("is-target");
window.setTimeout(() => el.classList.remove("is-target"), 1200); window.setTimeout(() => el.classList.remove("is-target"), 5400);
} }
return ( return (
@@ -101,7 +102,7 @@ export default function JamboxChannelsSearch() {
)} )}
</div> </div>
<div class="f-chsearch__meta">{meta}</div> <div class="f-chsearch-meta">{meta}</div>
</div> </div>
<div class="f-chsearch__list" role="list"> <div class="f-chsearch__list" role="list">
@@ -138,16 +139,19 @@ export default function JamboxChannelsSearch() {
<div class="f-chsearch__packages"> <div class="f-chsearch__packages">
Dostępny w:&nbsp; Dostępny w:&nbsp;
{c.packages.map((p, i) => ( {c.packages.map((p, i) => (
<span key={p.id}>
<button <button
type="button" type="button"
class="f-chsearch__pkg" class="f-chsearch__pkg"
key={p.id}
onClick={() => scrollToPackage(p.id)} onClick={() => scrollToPackage(p.id)}
> >
{p.name}{" "} {p.name}
<span class="f-chsearch__pkgnum">(kanał {p.number})</span>
{i < c.packages.length - 1 ? ", " : ""}
</button> </button>
<span class="f-chsearch__pkgnum">
{" "} (kanał {p.number})
</span>
{i < c.packages.length - 1 ? ", " : ""}
</span>
))} ))}
</div> </div>
)} )}
@@ -156,7 +160,7 @@ export default function JamboxChannelsSearch() {
))} ))}
{q.trim().length >= 2 && !loading && items.length === 0 && ( {q.trim().length >= 2 && !loading && items.length === 0 && (
<div class="f-chsearch__empty"> <div class="f-chsearch-empty">
Brak wyników dla: <strong>{q}</strong> Brak wyników dla: <strong>{q}</strong>
</div> </div>
)} )}

View File

@@ -14,7 +14,7 @@ export function GET({ url }) {
const q = (url.searchParams.get("q") || "").trim(); const q = (url.searchParams.get("q") || "").trim();
const limit = clamp(Number(url.searchParams.get("limit") || 50), 1, 200); const limit = clamp(Number(url.searchParams.get("limit") || 50), 1, 200);
if (q.length < 2) { if (q.length < 0) {
return new Response(JSON.stringify({ ok: true, data: [] }), { return new Response(JSON.stringify({ ok: true, data: [] }), {
status: 200, status: 200,
headers: { "Content-Type": "application/json; charset=utf-8" }, headers: { "Content-Type": "application/json; charset=utf-8" },
@@ -27,9 +27,6 @@ export function GET({ url }) {
const db = getDb(); const db = getDb();
try { try {
// ✅ 1 rekord na kanał (grupujemy po name+logo_url)
// ✅ pakiety zbieramy do jednego pola packages_blob
// UWAGA: zakładam, że jambox_base_packages ma kolumnę "name"
const rows = db const rows = db
.prepare( .prepare(
` `

View File

@@ -27,8 +27,8 @@
@apply opacity-100; @apply opacity-100;
} }
.f-chsearch__meta { .f-chsearch-meta {
@apply text-sm opacity-70 pl-1; @apply text-sm opacity-70 pl-1 ml-2;
} }
/* ========================= /* =========================
@@ -110,8 +110,8 @@
/* ========================= /* =========================
Empty state Empty state
========================== */ ========================== */
.f-chsearch__empty { .f-chsearch-empty {
@apply mt-2 p-4 rounded-2xl border border-slate-200 dark:border-slate-700 opacity-80; @apply mt-2 p-4 text-lg;
} }
.f-chsearch__input::-webkit-search-cancel-button { .f-chsearch__input::-webkit-search-cancel-button {

View File

@@ -1,98 +1,93 @@
/* GŁÓWNE SEKCJE */ .f-offers {
.f-offers {
@apply my-6; @apply my-6;
} }
/* GRID FLEX — zawsze centrowany */ /* GRID FLEX — zawsze centrowany */
.f-offers-grid { .f-offers-grid {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: center; justify-content: center;
gap: 2rem; gap: 2rem;
padding: 0 1rem; padding: 0 1rem;
} }
/* ----------------------------- /* MOBILE: każda karta prawie pełna szerokość */
KARTA MOBILE FIRST .f-card {
------------------------------ */ /* przewijanie uwzględnia sticky navbar */
scroll-margin-top: calc(var(--f-navbar-height, 64px) + 16px);
/* MOBILE: każda karta ~pełna szerokość */
.f-card {
flex: 1 1 100%; flex: 1 1 100%;
max-width: 26rem; /* możesz dać 100%, jeśli chcesz naprawdę full */ max-width: 26rem;
@apply bg-[--f-bg] text-[--f-text] border border-[--f-offers-border]
rounded-2xl shadow-md p-6 relative flex flex-col gap-4;
}
.f-card:hover { @apply bg-[--f-bg] text-[--f-text] border border-[--f-offers-border] rounded-2xl shadow-md p-6 relative flex flex-col gap-4;
transition: transform 220ms ease, box-shadow 220ms ease;
}
.f-card:hover {
@apply shadow-lg; @apply shadow-lg;
transform: translateY(-3px); transform: translateY(-3px);
} }
/* POPULARNY PLAN */ /* POPULARNY PLAN */
.f-card-popular { .f-card-popular {
border: 2px solid var(--f-offers-popular); border: 2px solid var(--f-offers-popular);
background: var(--f-offers-popular-bg); background: var(--f-offers-popular-bg);
} }
.f-card-badge { .f-card-badge {
@apply absolute top-3 right-3 bg-[--btn-background] @apply absolute top-3 right-3 bg-[--btn-background] text-[--btn-text] text-sm font-semibold px-3 py-1 rounded-full;
text-[--btn-text] text-sm font-semibold px-3 py-1 rounded-full; }
}
/* HEADER */ /* HEADER */
.f-card-header { .f-card-header {
@apply flex flex-col items-start gap-1; @apply flex flex-col items-start gap-1;
} }
.f-card-name { .f-card-name {
@apply text-xl font-semibold; @apply text-xl font-semibold;
} }
.f-card-price { .f-card-price {
@apply text-3xl font-extrabold text-[--f-offers-price]; @apply text-3xl font-extrabold text-[--f-offers-price];
} }
/* FEATURES */ /* FEATURES */
.f-card-features { .f-card-features {
@apply list-none p-0 m-0; @apply list-none p-0 m-0;
} }
.f-card-row { .f-card-row {
display: grid; display: grid;
grid-template-columns: 2fr 1fr; grid-template-columns: 2fr 1fr;
gap: 0.75rem; gap: 0.75rem;
padding: 0.5rem 0; padding: 0.5rem 0;
border-bottom: 1px solid var(--f-offers-border); border-bottom: 1px solid var(--f-offers-border);
align-items: center; align-items: center;
} }
.f-card-row:last-child { .f-card-row:last-child {
border-bottom: none; border-bottom: none;
} }
.f-card-label { .f-card-label {
@apply text-base font-medium opacity-80; @apply text-base font-medium opacity-80;
} }
.f-card-value { .f-card-value {
@apply text-base font-semibold text-right; @apply text-base font-semibold text-right;
} }
.f-card-value.yes { .f-card-value.yes {
@apply text-green-600; @apply text-green-600;
} }
.f-card-value.no { .f-card-value.no {
@apply text-red-600 opacity-60; @apply text-red-600 opacity-60;
} }
/* ----------------------------- /* INTELIGENTNY UKŁAD OD MD↑ */
INTELIGENTNY UKŁAD OD MD↑ @media (min-width: 768px) {
------------------------------ */
@media (min-width: 768px) {
/* DOMYŚLNE: responsywnie */
.f-card { .f-card {
flex: 1 1 300px; flex: 1 1 300px;
max-width: 360px; max-width: 360px;
@@ -108,6 +103,7 @@
.f-count-5 .f-card { .f-count-5 .f-card {
flex: 0 1 calc(33% - 2rem); flex: 0 1 calc(33% - 2rem);
} }
.f-count-5 .f-card:nth-child(n + 4) { .f-count-5 .f-card:nth-child(n + 4) {
flex: 0 1 calc(50% - 2rem); flex: 0 1 calc(50% - 2rem);
max-width: 420px; max-width: 420px;
@@ -117,6 +113,7 @@
.f-count-7 .f-card { .f-count-7 .f-card {
flex: 0 1 calc(33% - 2rem); flex: 0 1 calc(33% - 2rem);
} }
.f-count-7 .f-card:last-child { .f-count-7 .f-card:last-child {
flex: 0 1 calc(33% - 2rem); flex: 0 1 calc(33% - 2rem);
margin-left: auto; margin-left: auto;
@@ -127,6 +124,7 @@
.f-count-8 .f-card { .f-count-8 .f-card {
flex: 0 1 calc(33% - 2rem); flex: 0 1 calc(33% - 2rem);
} }
.f-count-8 .f-card:nth-child(n + 7) { .f-count-8 .f-card:nth-child(n + 7) {
flex: 0 1 calc(50% - 2rem); flex: 0 1 calc(50% - 2rem);
max-width: 420px; max-width: 420px;
@@ -138,125 +136,84 @@
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
} }
/* =========================================
TARGET — PODŚWIETLENIE PAKIETU PO KLIKNIĘCIU
========================================== */
.f-card.is-target {
outline: none;
box-shadow:
0 0 0 3px rgba(59, 130, 246, 0.45),
0 10px 25px rgba(15, 23, 42, 0.18);
transform: translateY(-6px) scale(1.01);
position: relative;
background-color: var(--f-navbar-background);
z-index: 2;
}
.f-card.is-target:hover {
transform: translateY(-6px) scale(1.01);
}
/* JAMBOX — GRID KANAŁÓW (MODAL) */
/* .jmb-channels-grid {
obszar ze scrollem wewnątrz modala
.jmb-channels-scroll {
margin-top: 1rem;
padding-right: 0.25rem;
max-height: 72vh;
overflow-y: auto;
} */
/* dużo kart w wierszu */
.jmb-channels-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 0.9rem; gap: 0.9rem;
} align-items: stretch;
}
/* pojedyncza karta kanału */ .jmb-channel-card {
.jmb-channel-card {
background: var(--fuz-bg);
border-radius: 0.75rem;
padding: 0.75rem 0.5rem;
text-align: center;
border: 1px solid rgba(148, 163, 184, 0.25);
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
display: flex;
flex-direction: column;
justify-content: space-between;
}
/* logo kanału */
.jmb-channel-logo {
max-width: 90px;
max-height: 60px;
margin: 0 auto 0.5rem auto;
display: block;
object-fit: contain;
}
/* podpisy pod logo */
.jmb-channel-name {
font-size: 0.85rem;
font-weight: 600;
margin-bottom: 0.15rem;
}
.jmb-channel-number {
font-size: 0.75rem;
color: #94a3b8;
}
/* badge "gwarantowany" */
.jmb-channel-tag {
margin-top: 0.35rem;
font-size: 0.7rem;
display: inline-block;
padding: 0.1rem 0.5rem;
border-radius: 9999px;
background: rgba(34, 197, 94, 0.08);
color: #22c55e;
}
/* === FIX: stabilny grid + flip (nie rozjeżdża kart) === */
.jmb-channels-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 0.9rem;
align-items: stretch; /* ważne: równe wysokości w wierszu */
}
.jmb-channel-card {
position: relative; position: relative;
perspective: 1000px; perspective: 1000px;
/* zostawiamy Twój wygląd */ background: var(--f-bg);
background: var(--fuz-bg); color: var(--f-text);
border-radius: 0.75rem; border-radius: 0.75rem;
border: 1px solid rgba(148, 163, 184, 0.25); border: 1px solid rgba(148, 163, 184, 0.25);
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
/* kluczowe: karta ma “ramę” */ min-height: 170px;
min-height: 170px; /* dopasuj: 160200 */
height: 100%; height: 100%;
padding: 0; /* padding przenosimy na face */ padding: 0;
overflow: hidden; /* żeby back nie wystawał */ overflow: hidden;
}
.jmb-channel-inner { -webkit-tap-highlight-color: transparent;
touch-action: manipulation;
cursor: pointer;
}
.jmb-channel-inner {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
transform-style: preserve-3d; transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
transition: transform 0.6s ease; transition: transform 0.6s ease;
} }
@media (hover: hover) and (pointer: fine) { /* DESKTOP: flip na hover */
@media (hover: hover) and (pointer: fine) {
.jmb-channel-card:hover .jmb-channel-inner { .jmb-channel-card:hover .jmb-channel-inner {
transform: rotateY(180deg); transform: rotateY(180deg);
} }
} }
/* front + back */ /* MOBILE/TAP: flip po klasie */
.jmb-channel-face { .jmb-channel-card.is-flipped .jmb-channel-inner {
transform: rotateY(180deg);
}
.jmb-channel-face {
position: absolute; position: absolute;
inset: 0; inset: 0;
padding: 0.75rem 0.5rem; /* to był Twój padding z card */
padding: 0.75rem 0.5rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
@@ -264,70 +221,65 @@ obszar ze scrollem wewnątrz modala
backface-visibility: hidden; backface-visibility: hidden;
-webkit-backface-visibility: hidden; -webkit-backface-visibility: hidden;
} }
.jmb-channel-front { .jmb-channel-front {
transform: rotateY(0deg); transform: rotateY(0deg);
} }
.jmb-channel-back { .jmb-channel-back {
transform: rotateY(180deg); transform: rotateY(180deg);
text-align: left; text-align: left;
justify-content: flex-start; justify-content: flex-start;
gap: 0.5rem; gap: 0.5rem;
} }
.jmb-channel-back-title { .jmb-channel-logo {
max-width: 90px;
max-height: 60px;
margin: 0 auto 0.5rem auto;
display: block;
object-fit: contain;
}
.jmb-channel-name {
font-size: 0.85rem;
font-weight: 600;
margin-bottom: 0.15rem;
}
.jmb-channel-number {
font-size: 0.75rem;
color: rgba(148, 163, 184, 0.95);
}
.jmb-channel-back-title {
font-size: 0.9rem; font-size: 0.9rem;
font-weight: 700; font-weight: 700;
} }
.jmb-channel-desc { .jmb-channel-desc {
font-size: 0.85rem; font-size: 0.85rem;
line-height: 1.35; line-height: 1.35;
opacity: 0.9; opacity: 0.92;
overflow: auto; /* długi opis nie rozwala karty */ overflow: auto;
}
scrollbar-width: thin;
scrollbar-color: rgba(148, 163, 184, 0.55) transparent;
}
.jmb-search { .jmb-channel-desc::-webkit-scrollbar {
display: flex; width: 10px;
gap: 0.5rem; }
align-items: center;
margin: 0.75rem 0 0.25rem;
}
.jmb-search-input { .jmb-channel-desc::-webkit-scrollbar-thumb {
flex: 1; background: rgba(148, 163, 184, 0.45);
padding: 0.6rem 0.75rem; border-radius: 9999px;
border-radius: 0.75rem; border: 3px solid transparent;
border: 1px solid rgba(148, 163, 184, 0.35); background-clip: content-box;
background: var(--fuz-bg); }
color: var(--fuz-text);
outline: none;
}
.jmb-search-input:focus { .jmb-channel-desc::-webkit-scrollbar-track {
border-color: rgba(59, 130, 246, 0.55);
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.jmb-search-clear {
padding: 0.55rem 0.7rem;
border-radius: 0.75rem;
border: 1px solid rgba(148, 163, 184, 0.35);
background: transparent; background: transparent;
} }
.jmb-search-meta {
font-size: 0.85rem;
opacity: 0.75;
margin-bottom: 0.5rem;
}
.f-card.is-target {
outline: 2px solid rgba(59, 130, 246, 0.55);
/* var(--f-link); */
outline-offset: 4px;
}