feat: student name popover preview on /repertoire via htmx

This commit is contained in:
Pontoporeia
2026-04-24 13:13:26 +02:00
parent ede53746ba
commit 53c3127140
6 changed files with 127 additions and 69 deletions

View File

@@ -345,65 +345,110 @@
.student-popover {
position: absolute;
z-index: 200;
width: 320px;
width: 300px;
background: var(--bg-primary, #fff);
border: 1px solid var(--border-primary, #ddd);
box-shadow: 0 4px 18px rgba(0,0,0,.12);
box-shadow: 0 4px 20px rgba(0,0,0,.13);
border-radius: 4px;
overflow: hidden;
pointer-events: auto;
max-height: 80vh;
overflow-y: auto;
}
.student-popover[hidden] {
display: none;
}
.student-popover__iframe {
/* ---- Student card (inside popover) ---- */
.student-card {
display: block;
width: 100%;
height: 400px;
border: none;
}
.student-preview__iframe {
display: block;
width: 100%;
height: 400px;
border: none;
}
.student-preview__name {
font-weight: 600;
font-size: var(--step--1);
padding: var(--space-xs) var(--space-s) var(--space-3xs);
margin: 0;
text-decoration: none;
color: inherit;
transition: background 0.12s;
border-bottom: 1px solid var(--border-primary, #eee);
}
.student-preview__list {
list-style: none;
margin: 0;
padding: var(--space-3xs) 0;
}
.student-preview__list li {
border-bottom: 1px solid var(--border-primary, #eee);
}
.student-preview__list li:last-child {
.student-card:last-child {
border-bottom: none;
}
.student-preview__link {
display: block;
padding: var(--space-2xs) var(--space-s);
font-size: var(--step--1);
color: var(--text-primary);
text-decoration: none;
transition: background 0.12s, color 0.12s;
.student-card:hover {
background: var(--bg-secondary, #f5f5f5);
}
.student-preview__link:hover {
background: var(--accent-primary, #0055ff);
color: #fff;
.student-card__banner {
width: 100%;
height: 120px;
background-size: cover;
background-position: center;
}
.student-card__banner--gradient {
background-image: none;
background: linear-gradient(
180deg,
rgba(60, 133, 108, 1) 0%,
rgba(96, 236, 180, 1) 33%,
rgba(227, 144, 255, 1) 66%,
rgba(149, 87, 181, 1) 100%
);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: var(--space-s);
text-align: center;
box-sizing: border-box;
}
.student-card__gradient-author {
color: var(--accent-foreground);
font-size: var(--step--2);
opacity: 0.85;
margin-bottom: 0.25rem;
display: block;
}
.student-card__gradient-title {
color: var(--accent-foreground);
font-size: var(--step--1);
font-weight: 600;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.student-card__body {
padding: var(--space-xs) var(--space-s) var(--space-s);
}
.student-card__meta {
margin: 0 0 var(--space-3xs);
font-size: var(--step--2);
color: var(--text-secondary, #888);
letter-spacing: 0.03em;
}
.student-card__title {
margin: 0 0 var(--space-3xs);
font-size: var(--step--1);
font-weight: 600;
line-height: 1.3;
color: var(--text-primary);
}
.student-card__subtitle {
margin: 0 0 var(--space-3xs);
font-size: var(--step--2);
color: var(--text-secondary, #888);
font-style: italic;
}
.student-card__synopsis {
margin: var(--space-3xs) 0 0;
font-size: var(--step--2);
color: var(--text-secondary, #888);
line-height: 1.5;
}

View File

@@ -461,13 +461,13 @@ class Database {
*/
public function getThesesByAuthorName(string $name): array {
$stmt = $this->pdo->prepare(
"SELECT t.id, t.title
FROM theses t
JOIN thesis_authors ta ON ta.thesis_id = t.id
"SELECT vp.id, vp.title, vp.subtitle, vp.year, vp.synopsis,
vp.orientation, vp.finality_type, vp.banner_path, vp.authors
FROM v_theses_public vp
JOIN thesis_authors ta ON ta.thesis_id = vp.id
JOIN authors a ON a.id = ta.author_id
WHERE t.is_published = 1
AND a.name = ?
ORDER BY t.year DESC, t.title ASC"
WHERE a.name = ?
ORDER BY vp.year DESC, vp.title ASC"
);
$stmt->execute([$name]);
return $stmt->fetchAll();

View File

@@ -1 +0,0 @@
[1776449542]

Binary file not shown.

Binary file not shown.

View File

@@ -1,28 +1,42 @@
<?php
/**
* Partial: student popover preview.
* Partial: student popover preview card(s).
*
* Expected variables:
* $theses array rows of [id => int, title => string]
* $theses array rows from Database::getThesesByAuthorName()
* $name string student name
*/
foreach ($theses as $t):
$synopsis = $t['synopsis'] ?? '';
// Truncate synopsis to ~160 chars
if (mb_strlen($synopsis) > 160) {
$synopsis = mb_substr($synopsis, 0, 157) . '…';
}
$meta = array_filter([
$t['year'] ?? null,
$t['orientation'] ?? null,
$t['finality_type'] ?? null,
]);
?>
<?php if (count($theses) === 1): ?>
<iframe
src="/tfe?id=<?= (int)$theses[0]['id'] ?>"
class="student-preview__iframe"
loading="lazy"
title="Aperçu — <?= htmlspecialchars($name) ?>"
></iframe>
<?php else: ?>
<p class="student-preview__name"><?= htmlspecialchars($name) ?></p>
<ul class="student-preview__list">
<?php foreach ($theses as $t): ?>
<li>
<a href="/tfe?id=<?= (int)$t['id'] ?>" class="student-preview__link">
<?= htmlspecialchars($t['title']) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<a href="/tfe?id=<?= (int)$t['id'] ?>" class="student-card">
<?php if (!empty($t['banner_path'])): ?>
<div class="student-card__banner" style="background-image:url('<?= htmlspecialchars($t['banner_path']) ?>')"></div>
<?php else: ?>
<div class="student-card__banner student-card__banner--gradient">
<span class="student-card__gradient-author"><?= htmlspecialchars($t['authors'] ?? '') ?></span>
<span class="student-card__gradient-title"><?= htmlspecialchars($t['title']) ?></span>
</div>
<?php endif; ?>
<div class="student-card__body">
<p class="student-card__meta"><?= htmlspecialchars(implode(' · ', $meta)) ?></p>
<h3 class="student-card__title"><?= htmlspecialchars($t['title']) ?></h3>
<?php if (!empty($t['subtitle'])): ?>
<p class="student-card__subtitle"><?= htmlspecialchars($t['subtitle']) ?></p>
<?php endif; ?>
<?php if ($synopsis !== ''): ?>
<p class="student-card__synopsis"><?= htmlspecialchars($synopsis) ?></p>
<?php endif; ?>
</div>
</a>
<?php endforeach; ?>