Созданы хлебные крошки
This commit is contained in:
parent
7d4289bd9e
commit
70e75dc11b
16 changed files with 350 additions and 44 deletions
|
|
@ -2,9 +2,10 @@
|
|||
export interface Props {
|
||||
categories: string[];
|
||||
activeCategory?: string;
|
||||
currentPage?: number;
|
||||
}
|
||||
|
||||
const { categories, activeCategory = 'Все' } = Astro.props;
|
||||
const { categories, activeCategory = 'Все', currentPage = 1 } = Astro.props;
|
||||
---
|
||||
|
||||
<div class="blog-categories">
|
||||
|
|
@ -12,12 +13,13 @@ const { categories, activeCategory = 'Все' } = Astro.props;
|
|||
<div class="categories-inner animate-on-scroll" data-animation="fade-up">
|
||||
<div class="categories-wrapper">
|
||||
{categories.map((cat) => (
|
||||
<button
|
||||
<a
|
||||
href={cat === 'Все' ? '/blog' : `/blog/category/${cat.toLowerCase()}`}
|
||||
class={`category-btn ${cat === activeCategory ? 'active' : ''}`}
|
||||
data-category={cat}
|
||||
>
|
||||
{cat}
|
||||
</button>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
|
|
@ -82,12 +84,15 @@ const { categories, activeCategory = 'Все' } = Astro.props;
|
|||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.category-btn:hover {
|
||||
border-color: #d4af37;
|
||||
color: #d4af37;
|
||||
transform: translateY(-2px);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.category-btn.active {
|
||||
|
|
@ -95,6 +100,7 @@ const { categories, activeCategory = 'Все' } = Astro.props;
|
|||
border-color: #d4af37;
|
||||
color: #1e293b;
|
||||
box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Анимации */
|
||||
|
|
@ -144,42 +150,7 @@ const { categories, activeCategory = 'Все' } = Astro.props;
|
|||
document.addEventListener('astro:page-load', initFilter);
|
||||
|
||||
function initFilter() {
|
||||
const buttons = document.querySelectorAll('.category-btn');
|
||||
const cards = document.querySelectorAll('.blog-card-wrapper');
|
||||
|
||||
buttons.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const category = btn.getAttribute('data-category');
|
||||
|
||||
// Обновляем активную кнопку
|
||||
buttons.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
|
||||
// Фильтрация карточек
|
||||
cards.forEach(card => {
|
||||
const cardCategory = card.getAttribute('data-category');
|
||||
|
||||
if (category === 'Все' || cardCategory === category) {
|
||||
card.style.display = '';
|
||||
card.style.opacity = '0';
|
||||
card.style.transform = 'translateY(20px)';
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
card.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
|
||||
card.style.opacity = '1';
|
||||
card.style.transform = 'translateY(0)';
|
||||
});
|
||||
} else {
|
||||
card.style.opacity = '0';
|
||||
card.style.transform = 'translateY(20px)';
|
||||
|
||||
setTimeout(() => {
|
||||
card.style.display = 'none';
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
const links = document.querySelectorAll('.category-btn');
|
||||
|
||||
// Открытие поиска
|
||||
const searchBtn = document.getElementById('search-icon-btn');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue