From fd382359c027503dade83370075668f15e662977 Mon Sep 17 00:00:00 2001 From: n3p-tun3 Date: Tue, 27 Oct 2026 17:31:26 +0300 Subject: [PATCH] =?UTF-8?q?feat(catalog):=20catalog=20polish=20CT1?= =?UTF-8?q?=E2=80=93CT3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CT1: chip rows scroll without a visible scrollbar; a faded edge hints there's more (also applies to the category chips on home) - CT2: search filters on every keystroke (no 300ms debounce) and gets a search icon, a clear button and Escape-to-clear - CT3: "Taught in" filter next to the result count, listing only languages the visible courses are taught in; the empty state offers "Clear filters" - i18n: catalog.clearSearch, taughtIn, anyLanguage, clearFilters, emptyLanguage (om/ti drafts) --- packages/features/src/student.tsx | 34 +++++++++++++++++++++++-------- packages/features/src/styles.css | 17 +++++++++++++++- packages/i18n/messages/am.json | 7 ++++++- packages/i18n/messages/en.json | 7 ++++++- packages/i18n/messages/om.json | 7 ++++++- packages/i18n/messages/ti.json | 7 ++++++- 6 files changed, 65 insertions(+), 14 deletions(-) diff --git a/packages/features/src/student.tsx b/packages/features/src/student.tsx index c762ea5..e55c8e2 100644 --- a/packages/features/src/student.tsx +++ b/packages/features/src/student.tsx @@ -519,27 +519,43 @@ function Catalog({ categorySlug }: { categorySlug?: string }) { const { categories, locale, nav, catalogLoaded } = useApp(); const { visible, catName } = useCatalog(); const [q, setQ] = useState(''); - const [dq, setDq] = useState(''); - useEffect(() => { const id = setTimeout(() => setDq(q.trim().toLowerCase()), 300); return () => clearTimeout(id); }, [q]); + const [lang, setLang] = useState(''); // '' = any language the course is taught in (CT3) + const searchRef = useRef(null); + const dq = q.trim().toLowerCase(); // the list is in memory: filter on every keystroke, no debounce (CT2) const cat = categories.find((c) => c.slug === categorySlug); - const list = visible.filter((c) => (!cat || c.categoryId === cat.id) && (!dq || [ + const langs = [...new Set(visible.map((c) => c.instructionLocale))]; + const list = visible.filter((c) => (!cat || c.categoryId === cat.id) && (!lang || c.instructionLocale === lang) && (!dq || [ ...Object.values(c.translations).map((x) => x?.title ?? ''), c.instructorName, ...Object.values(categories.find((k) => k.id === c.categoryId)?.translations ?? {}).map((x) => x?.name ?? ''), ].some((s) => s.toLowerCase().includes(dq)))); + const clear = () => { setQ(''); searchRef.current?.focus(); }; return (

{cat ? catName(cat.id) : t('catalog.title')}

-
); } diff --git a/packages/features/src/styles.css b/packages/features/src/styles.css index befa066..36cfc51 100644 --- a/packages/features/src/styles.css +++ b/packages/features/src/styles.css @@ -189,7 +189,22 @@ textarea.input { min-height: 110px; resize: vertical; } .continue-body { justify-content: center; padding: 24px 28px; } .continue-body .btn { align-self: flex-start; width: auto; } } -.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; } +/* CT1: chip rows scroll without a visible scrollbar; the faded edge says there's more */ +.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); } +.chips::-webkit-scrollbar { display: none; } +@media (max-width: 599px) { .chips { margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 32px), transparent); } } +/* CT2: search with an icon and a clear button (the browser's own cancel glyph is hidden so there's only one) */ +.search { position: relative; display: block; } +.search > svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; } +.search .input { min-height: 48px; padding-inline: 42px 46px; border-radius: 14px; } +.search .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; } +.search-clear { position: absolute; right: 4px; top: 50%; translate: 0 -50%; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--ink-3); cursor: pointer; } +@media (hover: hover) and (pointer: fine) { .search-clear:hover { color: var(--ink); background: var(--mist); } } +/* CT3: result count with the "taught in" filter beside it */ +.catalog-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; } +.catalog-lang { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-3); } +.catalog-lang select { min-height: 40px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; } +@media (pointer: coarse) { .catalog-lang select { font-size: 16px; } } /* iOS zooms into anything smaller */ .chip { flex: none; border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; color: var(--ink-2); } .chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); } diff --git a/packages/i18n/messages/am.json b/packages/i18n/messages/am.json index 6bf63df..ea7fb04 100644 --- a/packages/i18n/messages/am.json +++ b/packages/i18n/messages/am.json @@ -124,7 +124,12 @@ "all": "ሁሉም", "count": "{n} ኮርሶች", "empty": "ከ«{q}» ጋር የሚዛመድ ኮርስ የለም። አጠር ያለ ቃል ይሞክሩ።", - "emptyCategory": "በዚህ ምድብ እስካሁን ኮርስ የለም።" + "emptyCategory": "በዚህ ምድብ እስካሁን ኮርስ የለም።", + "clearSearch": "ፍለጋውን አጽዳ", + "taughtIn": "የማስተማሪያ ቋንቋ", + "anyLanguage": "ማንኛውም ቋንቋ", + "clearFilters": "ማጣሪያዎችን አጽዳ", + "emptyLanguage": "በዚህ ቋንቋ እስካሁን ኮርስ የለም።" }, "course": { "buyShort": "ኮርሱን ይግዙ", diff --git a/packages/i18n/messages/en.json b/packages/i18n/messages/en.json index b197c12..0621ccb 100644 --- a/packages/i18n/messages/en.json +++ b/packages/i18n/messages/en.json @@ -124,7 +124,12 @@ "all": "All", "count": "{n, plural, one {# course} other {# courses}}", "empty": "No courses match “{q}”. Try a shorter word.", - "emptyCategory": "No courses in this category yet." + "emptyCategory": "No courses in this category yet.", + "clearSearch": "Clear search", + "taughtIn": "Taught in", + "anyLanguage": "Any language", + "clearFilters": "Clear filters", + "emptyLanguage": "No courses in this language here yet." }, "course": { "buyShort": "Buy course", diff --git a/packages/i18n/messages/om.json b/packages/i18n/messages/om.json index 2eaa4a6..148b2da 100644 --- a/packages/i18n/messages/om.json +++ b/packages/i18n/messages/om.json @@ -124,7 +124,12 @@ "all": "Hunda", "count": "Koorsii {n}", "empty": "Koorsiin “{q}” wajjin walsimu hin jiru. Jecha gabaabaa yaali.", - "emptyCategory": "Ramaddii kana keessa ammatti koorsiin hin jiru." + "emptyCategory": "Ramaddii kana keessa ammatti koorsiin hin jiru.", + "clearSearch": "Barbaacha haqi", + "taughtIn": "Afaan barsiisaa", + "anyLanguage": "Afaan kamiyyuu", + "clearFilters": "Calaltuu haqi", + "emptyLanguage": "Afaan kanaan koorsiin ammaaf hin jiru." }, "course": { "buyShort": "Koorsii bitadhu", diff --git a/packages/i18n/messages/ti.json b/packages/i18n/messages/ti.json index 99e9e43..90fdd06 100644 --- a/packages/i18n/messages/ti.json +++ b/packages/i18n/messages/ti.json @@ -124,7 +124,12 @@ "all": "ኩሉ", "count": "{n} ኮርሳት", "empty": "ምስ «{q}» ዝሰማማዕ ኮርስ የለን። ሓጺር ቃል ፈትን።", - "emptyCategory": "ኣብዚ ምድብ ክሳብ ሕጂ ኮርስ የለን።" + "emptyCategory": "ኣብዚ ምድብ ክሳብ ሕጂ ኮርስ የለን።", + "clearSearch": "ምድላይ ኣጽሪ", + "taughtIn": "ቋንቋ ምምሃር", + "anyLanguage": "ዝኾነ ቋንቋ", + "clearFilters": "መጻረዪታት ኣጽሪ", + "emptyLanguage": "ብዚ ቋንቋ ክሳብ ሕጂ ኮርስ የለን።" }, "course": { "buyShort": "ኮርስ ግዝእ",