From 231f5a195dbc1b825f5f9d180a00df92ec2c2637 Mon Sep 17 00:00:00 2001 From: interlope Date: Mon, 1 Jun 2026 23:21:31 +0200 Subject: [PATCH] feat: enhance theme functionality and add social sharing metadata - Added new UI strings for theme toggle, copy functionality, and navigation. - Implemented dynamic theme color for mobile browsers based on user selection. - Introduced Open Graph and Twitter Card metadata for improved social sharing. - Added JSON-LD structured data for articles to enhance SEO. - Created a new JavaScript file for theme behavior, including theme picker, reading progress bar, back-to-top button, and image lightbox functionality. - Enhanced code blocks with copy-to-clipboard buttons and improved tabbed code block functionality. - Implemented a random navigation order feature and a table of contents generator for articles. --- css/style.css | 159 +++++++++++ index.php | 493 ++-------------------------------- js/blowdit.js | 670 ++++++++++++++++++++++++++++++++++++++++++++++ languages/en.json | 13 +- php/head.php | 121 +++++++++ 5 files changed, 989 insertions(+), 467 deletions(-) create mode 100644 js/blowdit.js diff --git a/css/style.css b/css/style.css index 0247aac..1fae253 100644 --- a/css/style.css +++ b/css/style.css @@ -1539,6 +1539,165 @@ footer.footer-modern a:hover { text-decoration: none; } +/* ======================================== + SKIP-TO-CONTENT LINK (keyboard / a11y) + ======================================== */ +.skip-link { + position: fixed; + top: -120px; + left: 1rem; + z-index: 3000; + padding: 0.6rem 1rem; + background: var(--accent); + color: var(--accent-contrast); + border-radius: var(--radius-sm); + font-weight: 600; + text-decoration: none; + box-shadow: var(--shadow-md); + transition: top 0.15s ease; +} + +.skip-link:focus { + top: 1rem; + color: var(--accent-contrast); + text-decoration: none; + outline: 2px solid var(--accent-contrast); + outline-offset: 2px; +} + +/* The skip target shouldn't paint a focus ring when jumped to */ +#main-content:focus { + outline: none; +} + +/* ======================================== + READING PROGRESS BAR + ======================================== */ +.reading-progress { + position: fixed; + top: 0; + left: 0; + right: 0; + height: 3px; + z-index: 1040; /* above the fixed-top navbar (Bootstrap z-index 1030) */ + background: transparent; + pointer-events: none; +} + +.reading-progress-fill { + height: 100%; + width: 0; + background: var(--accent); + transition: width 0.05s linear; +} + +/* ======================================== + BACK-TO-TOP BUTTON + ======================================== */ +.back-to-top { + position: fixed; + bottom: 1.5rem; + right: 1.5rem; + z-index: 1035; + width: 44px; + height: 44px; + padding: 0; + border: none; + border-radius: 50%; + background: var(--accent); + color: var(--accent-contrast); + font-size: 1.25rem; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + box-shadow: var(--shadow-md); + opacity: 0; + visibility: hidden; + transform: translateY(10px); + transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s, background 0.15s ease; +} + +.back-to-top.is-visible { + opacity: 1; + visibility: visible; + transform: translateY(0); + transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0s, background 0.15s ease; +} + +.back-to-top:hover { + background: var(--accent-hover); +} + +/* ======================================== + COPY-TO-CLIPBOARD ON CODE BLOCKS + ======================================== */ +.code-block { + position: relative; +} + +.code-copy { + position: absolute; + top: 0.5rem; + right: 0.5rem; + z-index: 2; + width: 32px; + height: 32px; + padding: 0; + display: inline-flex; + align-items: center; + justify-content: center; + border: 1px solid var(--border-color); + border-radius: var(--radius-sm); + background: var(--bg-subtle); + color: var(--text-secondary); + cursor: pointer; + opacity: 0; + transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease; +} + +.code-block:hover .code-copy, +.code-copy:focus { + opacity: 1; +} + +.code-copy:hover { + color: var(--text-primary); + border-color: var(--accent); +} + +.code-copy.is-copied { + opacity: 1; + color: var(--accent-contrast); + background: var(--accent); + border-color: var(--accent); +} + +.code-copy i { + font-size: 0.95rem; + line-height: 1; +} + +/* Touch devices have no hover — keep the button discoverable */ +@media (hover: none) { + .code-copy { opacity: 0.7; } +} + +/* ======================================== + GPU HINTS — promote animated layers ahead of time + ======================================== */ +.lightbox-overlay img, +.carousel-slide img { + will-change: transform; +} + +/* Respect users who prefer reduced motion */ +@media (prefers-reduced-motion: reduce) { + .reading-progress-fill { transition: none; } + .back-to-top, + .back-to-top.is-visible { transform: none; } +} + /* ======================================== RESPONSIVE ======================================== */ diff --git a/index.php b/index.php index 66938c3..894a723 100644 --- a/index.php +++ b/index.php @@ -27,6 +27,9 @@ > + + + @@ -105,7 +108,7 @@ ?> -
+
@@ -157,473 +160,31 @@ echo Theme::jsBootstrap(); ?> - + - - - - - - - - - - - - - - - + + diff --git a/js/blowdit.js b/js/blowdit.js new file mode 100644 index 0000000..d38543d --- /dev/null +++ b/js/blowdit.js @@ -0,0 +1,670 @@ +/* ============================================================ + BLOWDIT — theme behaviour + Deferred, cacheable bundle of all client-side enhancements. + Loaded with ' . "\n"; + } +?> +