Skip to content
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
## 2024-06-25 - Directory Listing Navigation Landmark
**Learning:** Generated directory listings act as navigation regions, and screen readers benefit when the listing is announced separately from the page's main content.
**Action:** Wrap generated directory listing `<ul>` elements in `<nav aria-label="Directory listing">` while keeping the surrounding semantic `<main>` structure.

## 2024-07-04 - Accessible CSS Transitions for Interactive Elements
**Learning:** Adding CSS transitions (`transition: all`) can cause unintended animations and negatively impact performance. Moreover, forced animations can trigger motion sickness for users who prefer reduced motion.
**Action:** When adding hover or focus transitions (e.g., `background-color`, `outline-color`), always specify the exact properties being animated rather than using `all`. Additionally, always include an `@media (prefers-reduced-motion: reduce)` override setting `transition: none` to respect user accessibility preferences.
6 changes: 6 additions & 0 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,19 @@ fun process_dir(curr_dir: File){
text-decoration: none;
color: #0366d6;
border-radius: 4px;
transition: background-color 0.2s, outline-color 0.2s;
}
a:hover, a:focus-visible {
background-color: #f6f8fa;
text-decoration: underline;
outline: 2px solid #0366d6;
outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
a {
transition: none;
}
}
</style>
"""

Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class MainTest {
assertFalse(htmlContent.contains("test.ignore"))
assertTrue(htmlContent.contains("Content-Security-Policy"))
assertTrue(htmlContent.contains("default-src 'none'; style-src 'unsafe-inline';"))
assertTrue(htmlContent.contains("transition: background-color 0.2s, outline-color 0.2s;"))
assertTrue(htmlContent.contains("@media (prefers-reduced-motion: reduce)"))
}

@Test
Expand Down
Loading