css: replace presentational class selectors with semantic element selectors

Replace 6 CSS class selectors across tfe.css, main.css, and search.css with
semantic element-based selectors, removing the corresponding classes from the
HTML templates entirely.

tfe.css:
- .tfe-meta-list → article dl / article dl > div / article dl dt / article dl dd
- .tfe-media-block → aside figure (+ img, video, embed children)
- .tfe-file-caption → aside figcaption

main.css:
- .card__media → .home-body figure (+ img/video children and hover/motion rules)
- .card__caption → .home-body li > a > p

search.css:
- .repertoire-col > h2 → .repertoire-index section > h2

Template changes:
- tfe.php: removed class= from <dl>, <figure>, and <figcaption>
- index.php: removed class= from <figure> and <p class=card__caption>;
  stripped orphaned card__media from the gradient <div> (only --gradient needed)

No visual change — selectors match the same elements as before since the
semantic HTML was already in place from prior refactoring work.
This commit is contained in:
Pontoporeia
2026-04-01 17:08:12 +02:00
parent 77576e966c
commit cd58bc13e4
6 changed files with 44 additions and 44 deletions

20
TODO.md
View File

@@ -12,12 +12,12 @@
- [ ] **`admin.css`**: Replace `.admin-hint` with `.admin-body form small` — use `<small>` instead of `<p class="admin-hint">` - [ ] **`admin.css`**: Replace `.admin-hint` with `.admin-body form small` — use `<small>` instead of `<p class="admin-hint">`
- [ ] **`admin.css`**: Replace `.admin-table` with `.admin-body table` — only one table per admin page - [ ] **`admin.css`**: Replace `.admin-table` with `.admin-body table` — only one table per admin page
- [ ] **`admin.css`**: Replace `.admin-fieldset` / `.admin-fieldset-legend` with `.admin-body fieldset` / `.admin-body legend` - [ ] **`admin.css`**: Replace `.admin-fieldset` / `.admin-fieldset-legend` with `.admin-body fieldset` / `.admin-body legend`
- [ ] **`main.css`**: Replace `.card__caption` with `.home-body .cards-container li p` or target `li > a > p` directly - [x] **`main.css`**: Replace `.card__caption` with `.home-body .cards-container li p` or target `li > a > p` directly
- [ ] **`main.css`**: Replace `.card__media` with `.home-body figure` — already uses `<figure>` elements - [x] **`main.css`**: Replace `.card__media` with `.home-body figure` — already uses `<figure>` elements
- [ ] **`tfe.css`**: Replace `.tfe-meta-list` selectors with `article dl`, `article dt`, `article dd` — already using `<dl>` inside `<article>` - [x] **`tfe.css`**: Replace `.tfe-meta-list` selectors with `article dl`, `article dt`, `article dd` — already using `<dl>` inside `<article>`
- [ ] **`tfe.css`**: Replace `.tfe-media-block` with `aside figure` — already wrapped in `<figure>` inside `<aside>` - [x] **`tfe.css`**: Replace `.tfe-media-block` with `aside figure` — already wrapped in `<figure>` inside `<aside>`
- [ ] **`tfe.css`**: Replace `.tfe-file-caption` with `aside figcaption` — native `<figcaption>` element - [x] **`tfe.css`**: Replace `.tfe-file-caption` with `aside figcaption` — native `<figcaption>` element
- [ ] **`search.css`**: Replace `.repertoire-col > h2` styling — already targets `section > h2`, can use `.repertoire-index section > h2` - [x] **`search.css`**: Replace `.repertoire-col > h2` styling — already targets `section > h2`, can use `.repertoire-index section > h2`
- [x] **`common.css`**: Replace `.site-search__icon` with `header form[role="search"] svg` - [x] **`common.css`**: Replace `.site-search__icon` with `header form[role="search"] svg`
- [x] **`common.css`**: Replace `.site-search__input` with `header form[role="search"] input` - [x] **`common.css`**: Replace `.site-search__input` with `header form[role="search"] input`
- [x] **`common.css`**: Replace `.site-search` with `header form[role="search"]` - [x] **`common.css`**: Replace `.site-search` with `header form[role="search"]`
@@ -25,10 +25,10 @@
### Template HTML changes to match ### Template HTML changes to match
- [ ] In all admin templates, replace `<p class="admin-hint">` with `<small>` elements - [ ] In all admin templates, replace `<p class="admin-hint">` with `<small>` elements
- [ ] In `tfe.php`, remove `class="tfe-meta-list"` — target via `article dl` - [x] In `tfe.php`, remove `class="tfe-meta-list"` — target via `article dl`
- [ ] In `tfe.php`, remove `class="tfe-media-block"` — target via `aside figure` - [x] In `tfe.php`, remove `class="tfe-media-block"` — target via `aside figure`
- [ ] In `tfe.php`, remove `class="tfe-file-caption"` — target via `aside figcaption` - [x] In `tfe.php`, remove `class="tfe-file-caption"` — target via `aside figcaption`
- [ ] In `index.php`, remove `class="card__caption"` — target via `li > a > p` - [x] In `index.php`, remove `class="card__caption"` — target via `li > a > p`
- [x] In `search-bar.php` and `header.php`, remove `class="site-search"`, `class="site-search__icon"` and `class="site-search__input"` - [x] In `search-bar.php` and `header.php`, remove `class="site-search"`, `class="site-search__icon"` and `class="site-search__input"`
## PHP Components (Reusable Partials/Includes) ## PHP Components (Reusable Partials/Includes)

View File

@@ -57,8 +57,8 @@
flex: 1; flex: 1;
} }
/* card__media is a <figure> (with image) or <div> (gradient placeholder) */ /* Media wrapper: <figure> for real images/video, <div class="card__media--gradient"> for placeholders */
.card__media { .home-body figure {
width: 100%; width: 100%;
aspect-ratio: 4/3; aspect-ratio: 4/3;
overflow: hidden; overflow: hidden;
@@ -67,8 +67,8 @@
margin: 0; /* reset <figure> default margin */ margin: 0; /* reset <figure> default margin */
} }
.card__media img, .home-body figure img,
.card__media video { .home-body figure video {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
@@ -76,8 +76,8 @@
transition: transform 0.3s ease; transition: transform 0.3s ease;
} }
.card:hover .card__media img, .card:hover figure img,
.card:hover .card__media video { .card:hover figure video {
transform: scale(1.02); transform: scale(1.02);
} }
@@ -127,8 +127,8 @@
font-style: italic; font-style: italic;
} }
/* Card caption — <p> directly inside the <a>, below the media */ /* Card caption — <p> directly inside the card <a> link, below the media */
.card__caption { .home-body li > a > p {
padding: 0.55rem 0.5rem 0.65rem; padding: 0.55rem 0.5rem 0.65rem;
font-size: 0.88rem; font-size: 0.88rem;
line-height: 1.35; line-height: 1.35;
@@ -226,12 +226,12 @@
/* Suppress card hover scale for users who prefer reduced motion */ /* Suppress card hover scale for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.card__media img, .home-body figure img,
.card__media video { .home-body figure video {
transition: none; transition: none;
} }
.card:hover .card__media img, .card:hover figure img,
.card:hover .card__media video { .card:hover figure video {
transform: none; transform: none;
} }
.card__media--gradient { .card__media--gradient {

View File

@@ -52,7 +52,7 @@
border-right: none; border-right: none;
} }
.repertoire-col > h2 { .repertoire-index section > h2 {
font-size: 0.72rem; font-size: 0.72rem;
letter-spacing: 0.1em; letter-spacing: 0.1em;
text-transform: uppercase; text-transform: uppercase;

View File

@@ -58,8 +58,8 @@
letter-spacing: -0.01em; letter-spacing: -0.01em;
} }
/* Metadata description list */ /* Metadata description list — target <dl> directly inside article > header */
.tfe-meta-list { article dl {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.45rem; gap: 0.45rem;
@@ -69,25 +69,25 @@
} }
/* Each dt/dd pair grouped in a <div> inside <dl> */ /* Each dt/dd pair grouped in a <div> inside <dl> */
.tfe-meta-list > div { article dl > div {
display: flex; display: flex;
gap: 0.4rem; gap: 0.4rem;
flex-wrap: wrap; flex-wrap: wrap;
} }
.tfe-meta-list dt { article dl dt {
color: var(--black); color: var(--black);
font-weight: 400; font-weight: 400;
flex-shrink: 0; flex-shrink: 0;
} }
.tfe-meta-list dd { article dl dd {
color: var(--black); color: var(--black);
font-weight: 700; font-weight: 700;
margin: 0; margin: 0;
} }
.tfe-meta-list dd a { article dl dd a {
color: inherit; color: inherit;
text-decoration: underline; text-decoration: underline;
text-underline-offset: 2px; text-underline-offset: 2px;
@@ -117,35 +117,35 @@
gap: 1.5rem; gap: 1.5rem;
} }
/* Each file display unit */ /* Each file display unit — target <figure> directly inside <aside> */
.tfe-media-block { aside figure {
overflow: hidden; overflow: hidden;
margin: 0; margin: 0;
} }
.tfe-media-block img { aside figure img {
width: 100%; width: 100%;
height: auto; height: auto;
display: block; display: block;
} }
.tfe-media-block embed, aside figure embed,
.tfe-media-block video { aside figure video {
width: 100%; width: 100%;
display: block; display: block;
border: none; border: none;
} }
.tfe-media-block video { aside figure video {
max-height: 500px; max-height: 500px;
} }
.tfe-media-block embed { aside figure embed {
height: clamp(300px, 80vh, 700px); height: clamp(300px, 80vh, 700px);
} }
/* figcaption under media */ /* figcaption under media — target <figcaption> inside <aside> */
.tfe-file-caption { aside figcaption {
font-size: 0.8rem; font-size: 0.8rem;
color: var(--text-muted); color: var(--text-muted);
margin: 0.3rem 0 0; margin: 0.3rem 0 0;

View File

@@ -99,7 +99,7 @@ $bodyClass = 'home-body';
// 3. Fall through to gradient // 3. Fall through to gradient
?> ?>
<?php if ($thumb): ?> <?php if ($thumb): ?>
<figure class="card__media"> <figure>
<img src="/media.php?path=<?= urlencode($thumb) ?>" <img src="/media.php?path=<?= urlencode($thumb) ?>"
alt="Couverture — <?= htmlspecialchars($item['title']) ?> par <?= htmlspecialchars($item['authors'] ?? '') ?>" alt="Couverture — <?= htmlspecialchars($item['title']) ?> par <?= htmlspecialchars($item['authors'] ?? '') ?>"
loading="lazy"> loading="lazy">
@@ -109,14 +109,14 @@ $bodyClass = 'home-body';
$hue = ($item['id'] * 47 + 160) % 360; $hue = ($item['id'] * 47 + 160) % 360;
$hue2 = ($hue + 40) % 360; $hue2 = ($hue + 40) % 360;
?> ?>
<div class="card__media card__media--gradient" <div class="card__media--gradient"
style="background:linear-gradient(135deg,hsl(<?= $hue ?>,55%,40%),hsl(<?= $hue2 ?>,50%,28%));" style="background:linear-gradient(135deg,hsl(<?= $hue ?>,55%,40%),hsl(<?= $hue2 ?>,50%,28%));"
aria-hidden="true"> aria-hidden="true">
<span class="card__gradient-author"><?= htmlspecialchars($item['authors'] ?? '') ?></span> <span class="card__gradient-author"><?= htmlspecialchars($item['authors'] ?? '') ?></span>
<span class="card__gradient-title"><?= htmlspecialchars($item['title']) ?></span> <span class="card__gradient-title"><?= htmlspecialchars($item['title']) ?></span>
</div> </div>
<?php endif; ?> <?php endif; ?>
<p class="card__caption"><?= htmlspecialchars($item["authors"] ?? '') ?><?php if (!empty($item['authors']) && !empty($item['title'])): ?> <?php endif; ?><?= htmlspecialchars($item["title"]) ?></p> <p><?= htmlspecialchars($item["authors"] ?? '') ?><?php if (!empty($item['authors']) && !empty($item['title'])): ?> <?php endif; ?><?= htmlspecialchars($item["title"]) ?></p>
</a> </a>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>

View File

@@ -79,7 +79,7 @@ $bodyClass = 'tfe-body';
<p class="tfe-author"><?= htmlspecialchars($data['authors'] ?? 'Auteur inconnu') ?></p> <p class="tfe-author"><?= htmlspecialchars($data['authors'] ?? 'Auteur inconnu') ?></p>
<dl class="tfe-meta-list"> <dl>
<?php if (!empty($data['orientation'])): ?> <?php if (!empty($data['orientation'])): ?>
<div> <div>
<dt>Orientation :</dt> <dt>Orientation :</dt>
@@ -204,7 +204,7 @@ $bodyClass = 'tfe-body';
<?php elseif (!empty($data['files'])): ?> <?php elseif (!empty($data['files'])): ?>
<?php foreach ($data['files'] as $file): ?> <?php foreach ($data['files'] as $file): ?>
<?php $ext = strtolower(pathinfo($file['file_path'], PATHINFO_EXTENSION)); ?> <?php $ext = strtolower(pathinfo($file['file_path'], PATHINFO_EXTENSION)); ?>
<figure class="tfe-media-block"> <figure>
<?php if ($ext === 'pdf'): ?> <?php if ($ext === 'pdf'): ?>
<embed src="/media.php?path=<?= urlencode($file['file_path']) ?>" <embed src="/media.php?path=<?= urlencode($file['file_path']) ?>"
type="application/pdf" width="100%" height="700px"> type="application/pdf" width="100%" height="700px">
@@ -226,7 +226,7 @@ $bodyClass = 'tfe-body';
</video> </video>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($file['description'])): ?> <?php if (!empty($file['description'])): ?>
<figcaption class="tfe-file-caption"><?= htmlspecialchars($file['description']) ?></figcaption> <figcaption><?= htmlspecialchars($file['description']) ?></figcaption>
<?php endif; ?> <?php endif; ?>
</figure> </figure>
<?php endforeach; ?> <?php endforeach; ?>