Новые правки компоентов

This commit is contained in:
Web-serfer 2026-04-29 03:25:37 +05:00
parent 9122756a58
commit 1838fd302d
14 changed files with 88 additions and 79 deletions

View file

@ -167,5 +167,37 @@ const formatDate = (date: string) => {
};
setupAnimations();
document.addEventListener('astro:page-load', setupAnimations);
setupFilter();
function setupFilter() {
const buttons = document.querySelectorAll('.category-btn');
const cards = document.querySelectorAll('.blog-card-wrapper');
buttons.forEach((btn) => {
btn.addEventListener('click', (e) => {
e.preventDefault();
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');
const el = card as HTMLElement;
if (category === 'Все' || cardCategory === category) {
el.style.display = '';
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
requestAnimationFrame(() => {
el.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
el.style.opacity = '1';
el.style.transform = 'translateY(0)';
});
} else {
el.style.display = 'none';
}
});
});
});
}
</script>

View file

@ -168,5 +168,4 @@ const formatDate = (date: string) => {
};
setupAnimations();
document.addEventListener('astro:page-load', setupAnimations);
</script>

View file

@ -183,8 +183,4 @@ const formatDate = (date: string) => {
setupAnimations();
setupFilter();
document.addEventListener('astro:page-load', () => {
setupAnimations();
setupFilter();
});
</script>

View file

@ -148,6 +148,38 @@ const formatDate = (date: string) => {
});
};
const setupFilter = () => {
const buttons = document.querySelectorAll('.category-btn');
const cards = document.querySelectorAll('.blog-card-wrapper');
buttons.forEach((btn) => {
btn.addEventListener('click', (e) => {
e.preventDefault();
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');
const el = card as HTMLElement;
if (category === 'Все' || cardCategory === category) {
el.style.display = '';
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
requestAnimationFrame(() => {
el.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
el.style.opacity = '1';
el.style.transform = 'translateY(0)';
});
} else {
el.style.display = 'none';
}
});
});
});
};
setupAnimations();
document.addEventListener('astro:page-load', setupAnimations);
setupFilter();
</script>

View file

@ -344,10 +344,4 @@ const isAuthorized = false; // Измените на true, чтобы увиде
// Инициализация
setupAnimations();
setupForm();
// Для поддержки Astro transitions
document.addEventListener('astro:page-load', () => {
setupAnimations();
setupForm();
});
</script>

View file

@ -181,8 +181,4 @@ const categories = getCategories();
};
setupFilter();
document.addEventListener('astro:page-load', () => {
setupFilter();
});
</script>

View file

@ -195,9 +195,4 @@ import ReviewsList from '@components/reviews/ReviewsList.astro';
// Запуск
setupAnimations();
// Для поддержки View Transitions в Astro
document.addEventListener('astro:page-load', () => {
setupAnimations();
});
</script>