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

This commit is contained in:
Web-serfer 2026-04-21 20:04:13 +05:00
parent ddc0a26635
commit 189768971d
7 changed files with 549 additions and 589 deletions

View file

@ -72,41 +72,28 @@ const formatDate = (dateStr: string) => {
<!-- Блок голосования -->
<div class="voting-section" data-review-id={reviewId}>
<p class="voting-question">Полезен ли этот отзыв?</p>
<div class="voting-buttons">
<button
type="button"
class="vote-btn vote-btn-up"
data-vote="like"
aria-label="Полезно"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="reaction-icon">
<path d="M7 10v12"></path>
<path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"></path>
</svg>
<span class="vote-label">Да</span>
</button>
<button
type="button"
class="vote-btn vote-btn-down"
data-vote="dislike"
aria-label="Бесполезно"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="reaction-icon">
<path d="M17 14V2"></path>
<path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"></path>
</svg>
<span class="vote-label">Нет</span>
</button>
</div>
<div class="voting-stats">
<span class="votes-count">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
<path d="M2 10.5a1.5 1.5 0 113 0v6a1.5 1.5 0 01-3 0v-6zM6 10.333v5.43a2 2 0 001.106 1.79l.05.025A4 4 0 008.943 18h5.416a2 2 0 001.962-1.608l1.2-6A2 2 0 0015.56 8H12V4a2 2 0 00-2-2 1 1 0 00-1 1v.667a4 4 0 01-.8 2.4L6.8 7.933a4 4 0 00-.8 2.4z" />
</svg>
<span class="votes-number">{votesCount}</span>
</span>
</div>
<button
type="button"
class="vote-btn vote-btn-up"
data-vote="likes"
aria-label="Полезно"
>
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
<path d="M2 10.5a1.5 1.5 0 113 0v6a1.5 1.5 0 01-3 0v-6zM6 10.333v5.43a2 2 0 001.106 1.79l.05.025A4 4 0 008.943 18h5.416a2 2 0 001.962-1.608l1.2-6A2 2 0 0015.56 8H12V4a2 2 0 00-2-2 1 1 0 00-1 1v.667a4 4 0 01-.8 2.4L6.8 7.933a4 4 0 00-.8 2.4z" />
</svg>
<span class="votes-number">{votesCount}</span>
</button>
<button
type="button"
class="vote-btn vote-btn-down"
data-vote="dislikes"
aria-label="Бесполезно"
>
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
<path d="M18 9.5a1.5 1.5 0 11-3 0v-6a1.5 1.5 0 013 0v6zM14 9.667v-5.43a2 2 0 00-1.106-1.79l-.05-.025A4 4 0 0011.057 2H5.64a2 2 0 00-1.962 1.608l-1.2 6A2 2 0 004.44 12H8v4a2 2 0 002 2 1 1 0 001-1v-.667a4 4 0 01.8-2.4l1.4-2.4a4 4 0 00.8-2.4z"/>
</svg>
<span class="votes-number dislikes-count">0</span>
</button>
</div>
</article>
@ -211,70 +198,43 @@ const formatDate = (dateStr: string) => {
.voting-section {
margin-top: auto;
padding-top: 1.5rem;
padding-top: 1.25rem;
border-top: 1px solid #e2e8f0;
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.voting-question {
color: #475569;
font-size: 0.875rem;
font-weight: 600;
margin: 0;
}
.voting-auth-note {
color: #dc2626 !important;
font-size: 0.7rem !important;
font-style: italic;
margin: 0;
}
.voting-buttons {
display: flex;
gap: 0.75rem;
align-items: center;
gap: 1rem;
justify-content: center;
}
.vote-btn {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.5rem 0.875rem;
border: 2px solid #e2e8f0;
gap: 0.5rem;
padding: 0.625rem 1rem;
border: 1px solid #e2e8f0;
border-radius: 0.5rem;
background: #ffffff;
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.875rem;
font-weight: 600;
font-weight: 500;
color: #64748b;
}
.vote-btn svg {
width: 1.25rem;
height: 1.25rem;
width: 1.125rem;
height: 1.125rem;
}
.reaction-icon {
width: 1.25rem;
height: 1.25rem;
.vote-btn:hover {
border-color: #1e3050;
color: #1e3050;
background: #f8fafc;
}
.vote-btn-up:hover,
.vote-btn-up.active {
border-color: #22c55e;
color: #22c55e;
background: rgba(34, 197, 94, 0.1);
}
.vote-btn-down:hover,
.vote-btn-down.active {
border-color: #ef4444;
color: #ef4444;
background: rgba(239, 68, 68, 0.1);
.vote-btn.active {
background: #1e3050;
border-color: #1e3050;
color: #ffffff;
}
.vote-btn:disabled {
@ -302,27 +262,6 @@ const formatDate = (dateStr: string) => {
}
}
.voting-stars {
display: flex;
align-items: center;
}
.voting-stats {
display: flex;
align-items: center;
gap: 1rem;
margin-top: 0.5rem;
}
.votes-count {
display: inline-flex;
align-items: center;
gap: 0.375rem;
color: #64748b;
font-size: 0.875rem;
font-weight: 500;
}
.icon {
width: 1.125rem;
height: 1.125rem;
@ -492,13 +431,12 @@ const formatDate = (dateStr: string) => {
return;
}
const data = await response.json();
buttons.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
const votesNumber = section.querySelector('.votes-number');
if (votesNumber && typeof data.likes === 'number') {
votesNumber.textContent = data.likes.toString();
const resData = await response.json();
const btnCountEl = btn.querySelector('.votes-number');
if (btnCountEl) {
const isLike = voteType === 'likes';
const newCount = isLike ? (resData.likes || 0) : (resData.dislikes || 0);
btnCountEl.textContent = String(newCount);
}
} catch (err) {
console.error('[ReviewCard] Vote failed:', err);
@ -541,17 +479,21 @@ const formatDate = (dateStr: string) => {
return;
}
if (!response.ok) {
if (!response.ok) {
const errorText = await response.text();
console.error('[Vote JS] Error:', errorText);
return;
}
const data = await response.json();
buttons.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
const votesNumber = section.querySelector('.votes-number');
if (votesNumber && typeof data.likes === 'number') {
votesNumber.textContent = data.likes.toString();
const resData = await response.json();
console.log('[Vote JS] Response:', resData);
const btnCountEl = btn.querySelector('.votes-number');
if (btnCountEl) {
const isLike = voteType === 'likes';
const newCount = isLike ? (resData.likes || 0) : (resData.dislikes || 0);
btnCountEl.textContent = String(newCount);
console.log('[Vote JS] Set count to:', newCount);
}
} catch (err) {
console.error('[ReviewCard] Vote failed:', err);