Новые компоенты

This commit is contained in:
Web-serfer 2026-04-07 18:53:23 +05:00
parent 410a1c3235
commit ffd99c404a
9 changed files with 756 additions and 733 deletions

View file

@ -0,0 +1,258 @@
---
const title = 'Поиск статей';
---
<div id="search-modal" class="modal-overlay" aria-hidden="true">
<div class="modal-container" role="dialog" aria-modal="true" aria-labelledby="search-modal-title">
<button class="modal-close" aria-label="Закрыть" id="search-modal-close-btn">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
<div class="modal-content">
<h2 id="search-modal-title" class="modal-title">{title}</h2>
<p class="modal-description">
Введите ключевые слова для поиска статей
</p>
<form class="search-form" id="search-form">
<div class="search-input-wrapper">
<svg class="search-icon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
<input
type="text"
id="search-input"
name="search"
class="search-input"
placeholder="Например: ДТП, ОСАГО, лишение прав..."
required
autocomplete="off"
/>
</div>
<button type="submit" class="search-submit">
Найти статьи
</button>
</form>
</div>
</div>
</div>
<script>
(function() {
const modal = document.getElementById('search-modal');
const closeBtn = document.getElementById('search-modal-close-btn');
const form = document.getElementById('search-form');
const searchInput = document.getElementById('search-input');
function openModal() {
if (!modal) return;
modal.classList.add('active');
modal.setAttribute('aria-hidden', 'false');
document.body.style.overflow = 'hidden';
// Фокус на поле ввода после открытия
setTimeout(() => (searchInput as HTMLInputElement)?.focus(), 100);
}
function closeModal() {
if (!modal) return;
modal.classList.remove('active');
modal.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
(searchInput as HTMLInputElement).value = '';
}
// Открытие по кастомному событию
window.addEventListener('open-modal', (e: Event) => {
const customEvent = e as CustomEvent<string>;
if (customEvent.detail === 'search-modal') {
openModal();
}
});
// Закрытие по крестику
closeBtn?.addEventListener('click', closeModal);
// Закрытие по клику вне модального окна
modal?.addEventListener('click', (e) => {
if (e.target === modal) {
closeModal();
}
});
// Закрытие по Escape
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && modal?.classList.contains('active')) {
closeModal();
}
});
// Обработка отправки формы
form?.addEventListener('submit', (e) => {
e.preventDefault();
const query = (searchInput as HTMLInputElement).value.trim();
if (query) {
// Перенаправление на страницу поиска с параметром
window.location.href = `/blog/search?q=${encodeURIComponent(query)}`;
closeModal();
}
});
})();
</script>
<style>
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.active {
opacity: 1;
visibility: visible;
}
.modal-container {
background: #ffffff;
border-radius: 16px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 600px;
width: 90%;
max-height: 90vh;
overflow-y: auto;
position: relative;
transform: translateY(-20px) scale(0.95);
transition: transform 0.3s ease;
}
.modal-overlay.active .modal-container {
transform: translateY(0) scale(1);
}
.modal-close {
position: absolute;
top: 16px;
right: 16px;
background: transparent;
border: none;
cursor: pointer;
padding: 8px;
border-radius: 8px;
color: #535e6c;
transition: background 0.2s ease, color 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
}
.modal-close:hover {
background: #f0f2f5;
color: #1e3050;
}
.modal-content {
padding: 40px 32px 32px;
}
.modal-title {
font-size: 1.5rem;
font-weight: 700;
color: #1e3050;
margin: 0 0 12px;
text-align: center;
}
.modal-description {
color: #535e6c;
font-size: 0.95rem;
text-align: center;
margin: 0 0 28px;
line-height: 1.5;
}
.search-form {
display: flex;
flex-direction: column;
gap: 20px;
}
.search-input-wrapper {
position: relative;
display: flex;
align-items: center;
}
.search-icon {
position: absolute;
left: 16px;
color: #9ca3af;
pointer-events: none;
}
.search-input {
width: 100%;
padding: 14px 16px 14px 48px;
border: 2px solid #e0e4e8;
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
outline: none;
}
.search-input:focus {
border-color: #1e3050;
box-shadow: 0 0 0 3px rgba(30, 48, 80, 0.1);
}
.search-input::placeholder {
color: #9ca3af;
}
.search-submit {
background: linear-gradient(180deg, #eac26e 0%, #ce9f40 100%);
color: #ffffff;
border: none;
padding: 14px 24px;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 12px rgba(234, 194, 110, 0.3);
}
.search-submit:hover {
box-shadow: 0 6px 20px rgba(234, 194, 110, 0.5);
transform: translateY(-2px);
}
.search-submit:active {
transform: translateY(0);
}
@media (max-width: 480px) {
.modal-content {
padding: 32px 24px 24px;
}
.modal-title {
font-size: 1.25rem;
}
}
</style>

View file

@ -0,0 +1,55 @@
---
// Компонент иконки поиска (лупа)
---
<button class="search-icon-btn" id="search-icon-btn" data-modal-target="search-modal" aria-label="Поиск статей">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
</button>
<script>
(function() {
const btn = document.getElementById('search-icon-btn');
btn?.addEventListener('click', () => {
window.dispatchEvent(new CustomEvent('open-modal', {
detail: 'search-modal'
}));
});
})();
</script>
<style>
.search-icon-btn {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #ffffff;
padding: 0.75rem;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.search-icon-btn:hover {
background: rgba(255, 255, 255, 0.15);
border-color: rgba(234, 194, 110, 0.5);
color: #eac26e;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(234, 194, 110, 0.2);
}
.search-icon-btn:active {
transform: translateY(0);
}
@media (max-width: 768px) {
.search-icon-btn {
padding: 0.6rem;
}
}
</style>

View file

@ -1,9 +1,9 @@
---
const sectionsLinks = [
{ label: 'Главная', href: '/' },
{ label: 'Услуги', href: '/services' },
{ label: 'Блог', href: '#' },
{ label: 'Кейсы', href: '/cases' },
{ label: 'Блог', href: '/blog' },
{ label: 'Контакты', href: '/contacts' },
];
@ -18,6 +18,9 @@ const infoLinks = [
{ label: 'Условия использования', href: '/terms' },
{ label: 'Возврат средств', href: '#' },
];
const currentYear = new Date().getFullYear().toString();
---
<footer class="footer">
@ -78,7 +81,7 @@ const infoLinks = [
<!-- Нижняя часть футера (Копирайт) -->
<div class="footer-bottom">
<p class="copyright">© 2026 Автоюрист086. Все права защищены.</p>
<p class="copyright">© {currentYear} Автоюрист086.ru Все права защищены.</p>
<ul class="footer-bottom-links">
{legalLinks.map(link => (
<li><a href={link.href}>{link.label}</a></li>