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 { .student-popover {
position: absolute; position: absolute;
z-index: 200; z-index: 200;
width: 320px; width: 300px;
background: var(--bg-primary, #fff); background: var(--bg-primary, #fff);
border: 1px solid var(--border-primary, #ddd); 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; border-radius: 4px;
overflow: hidden; overflow: hidden;
pointer-events: auto; pointer-events: auto;
max-height: 80vh;
overflow-y: auto;
} }
.student-popover[hidden] { .student-popover[hidden] {
display: none; display: none;
} }
.student-popover__iframe { /* ---- Student card (inside popover) ---- */
.student-card {
display: block; display: block;
width: 100%; text-decoration: none;
height: 400px; color: inherit;
border: none; transition: background 0.12s;
}
.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;
border-bottom: 1px solid var(--border-primary, #eee); border-bottom: 1px solid var(--border-primary, #eee);
} }
.student-preview__list { .student-card:last-child {
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 {
border-bottom: none; border-bottom: none;
} }
.student-preview__link { .student-card:hover {
display: block; background: var(--bg-secondary, #f5f5f5);
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-preview__link:hover { .student-card__banner {
background: var(--accent-primary, #0055ff); width: 100%;
color: #fff; 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 { public function getThesesByAuthorName(string $name): array {
$stmt = $this->pdo->prepare( $stmt = $this->pdo->prepare(
"SELECT t.id, t.title "SELECT vp.id, vp.title, vp.subtitle, vp.year, vp.synopsis,
FROM theses t vp.orientation, vp.finality_type, vp.banner_path, vp.authors
JOIN thesis_authors ta ON ta.thesis_id = t.id FROM v_theses_public vp
JOIN thesis_authors ta ON ta.thesis_id = vp.id
JOIN authors a ON a.id = ta.author_id JOIN authors a ON a.id = ta.author_id
WHERE t.is_published = 1 WHERE a.name = ?
AND a.name = ? ORDER BY vp.year DESC, vp.title ASC"
ORDER BY t.year DESC, t.title ASC"
); );
$stmt->execute([$name]); $stmt->execute([$name]);
return $stmt->fetchAll(); return $stmt->fetchAll();

View File

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

Binary file not shown.

Binary file not shown.

View File

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