fix: update sub-products in footer

This commit is contained in:
mohamad
2026-05-20 16:21:04 +03:30
parent 24dd24e1c9
commit 4875d8b6c3
5 changed files with 128 additions and 13 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
from apps.products.models import MainProduct from apps.products.models import MainProduct, SubProduct
def navigation(request): def navigation(request):
@@ -7,4 +7,13 @@ def navigation(request):
.prefetch_related("sub_products") .prefetch_related("sub_products")
.order_by("order", "name") .order_by("order", "name")
) )
return {"nav_main_products": main_products} all_sub_products = list(
SubProduct.objects.filter(is_active=True).order_by("order", "name")[:5]
)
footer_sub_products = all_sub_products[:4]
footer_sub_products_has_more = len(all_sub_products) == 5
return {
"nav_main_products": main_products,
"footer_sub_products": footer_sub_products,
"footer_sub_products_has_more": footer_sub_products_has_more,
}
+51 -3
View File
@@ -1263,7 +1263,7 @@ a.citation-count-badge:hover {
.article-citation-item { .article-citation-item {
display: flex; display: flex;
align-items: baseline; align-items: flex-start;
gap: 0.5rem; gap: 0.5rem;
font-size: 0.8rem; font-size: 0.8rem;
color: var(--text-secondary); color: var(--text-secondary);
@@ -1284,16 +1284,64 @@ a.citation-count-badge:hover {
flex: 1; flex: 1;
} }
.citation-link { .citation-actions {
flex-shrink: 0; flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.65rem;
}
.citation-link,
.citation-copy {
color: var(--accent-blue-light); color: var(--accent-blue-light);
opacity: 0.75; opacity: 0.75;
transition: opacity 0.2s; transition: opacity 0.2s;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
} }
.citation-link:hover { .citation-copy {
position: relative;
padding: 0;
border: none;
background: none;
cursor: pointer;
font: inherit;
}
.citation-link:hover,
.citation-copy:hover {
opacity: 1;
}
.citation-copy-feedback {
position: absolute;
left: 50%;
top: calc(100% + 0.2rem);
transform: translateX(-50%);
font-size: 0.62rem;
font-weight: 600;
letter-spacing: 0.02em;
color: var(--accent-blue-light);
white-space: nowrap;
pointer-events: none;
}
.citation-copy-icon-done {
display: none;
}
.citation-copy.is-copied .citation-copy-icon {
display: none;
}
.citation-copy.is-copied .citation-copy-icon-done {
display: flex;
}
.citation-copy.is-copied {
opacity: 1; opacity: 1;
} }
+43
View File
@@ -9,6 +9,7 @@ const SELECTORS = {
faqQuestion: '.faq-question', faqQuestion: '.faq-question',
faqAnswer: '.faq-answer', faqAnswer: '.faq-answer',
fadeInElements: '.fade-in', fadeInElements: '.fade-in',
citationCopy: '.citation-copy',
}; };
function initNavbarScroll() { function initNavbarScroll() {
@@ -190,6 +191,47 @@ function initReadMore() {
}); });
} }
function initCitationCopy() {
const copyButtons = document.querySelectorAll(SELECTORS.citationCopy);
if (!copyButtons.length) return;
copyButtons.forEach((btn) => {
const url = btn.getAttribute('data-citation-url');
const feedback = btn.querySelector('.citation-copy-feedback');
if (!url || !feedback) return;
let resetTimer = null;
btn.addEventListener('click', async () => {
clearTimeout(resetTimer);
try {
await navigator.clipboard.writeText(url);
} catch {
const textarea = document.createElement('textarea');
textarea.value = url;
textarea.setAttribute('readonly', '');
textarea.style.position = 'fixed';
textarea.style.left = '-9999px';
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
feedback.hidden = false;
btn.classList.add('is-copied');
btn.setAttribute('aria-label', 'Link copied');
resetTimer = setTimeout(() => {
feedback.hidden = true;
btn.classList.remove('is-copied');
btn.setAttribute('aria-label', 'Copy citation link');
}, 2000);
});
});
}
function init() { function init() {
initNavbarScroll(); initNavbarScroll();
initMobileMenu(); initMobileMenu();
@@ -197,6 +239,7 @@ function init() {
initFAQAccordion(); initFAQAccordion();
initIntersectionObserver(); initIntersectionObserver();
initReadMore(); initReadMore();
initCitationCopy();
} }
if (document.readyState === 'loading') { if (document.readyState === 'loading') {
+6 -3
View File
@@ -34,13 +34,16 @@
</ul> </ul>
</div> </div>
{% if nav_main_products %} {% if footer_sub_products %}
<div class="footer-links-col"> <div class="footer-links-col">
<h3 class="footer-heading">Products</h3> <h3 class="footer-heading">Products</h3>
<ul class="footer-links" role="list"> <ul class="footer-links" role="list">
{% for product in nav_main_products %} {% for sub in footer_sub_products %}
<li><a href="{{ product.get_absolute_url }}">{{ product.name }}</a></li> <li><a href="{{ sub.get_absolute_url }}">{{ sub.name }}</a></li>
{% endfor %} {% endfor %}
{% if footer_sub_products_has_more %}
<li><a href="/products/radiuma/">more</a></li>
{% endif %}
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
+12
View File
@@ -177,11 +177,23 @@
<li class="article-citation-item"> <li class="article-citation-item">
<span class="citation-text">{{ citation.text }}</span> <span class="citation-text">{{ citation.text }}</span>
{% if citation.url %} {% if citation.url %}
<span class="citation-actions">
<a href="{{ citation.url }}" class="citation-link" target="_blank" rel="noopener noreferrer" aria-label="Open citation source"> <a href="{{ citation.url }}" class="citation-link" target="_blank" rel="noopener noreferrer" aria-label="Open citation source">
<svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true"> <svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path d="M7 3H3a1 1 0 00-1 1v9a1 1 0 001 1h9a1 1 0 001-1V9M10 2h4m0 0v4m0-4L7 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> <path d="M7 3H3a1 1 0 00-1 1v9a1 1 0 001 1h9a1 1 0 001-1V9M10 2h4m0 0v4m0-4L7 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg> </svg>
</a> </a>
<button type="button" class="citation-copy" data-citation-url="{{ citation.url }}" aria-label="Copy citation link">
<svg class="citation-copy-icon" width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<rect x="5" y="5" width="8" height="8" rx="1" stroke="currentColor" stroke-width="1.5"/>
<path d="M3 11V3a1 1 0 011-1h8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
<svg class="citation-copy-icon-done" width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path d="M3.5 8.5L6.5 11.5L12.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="citation-copy-feedback" aria-live="polite" hidden>Copied!</span>
</button>
</span>
{% endif %} {% endif %}
</li> </li>
{% endfor %} {% endfor %}