# Back-to-Top Button Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Add a fixed bottom-right back-to-top button that appears after 33% scroll depth on article/single pages, with slide-up animation, full accessibility, and hacker-theme styling. **Architecture:** A new `back-to-top.html` partial uses inline Alpine.js `x-data` with `@scroll.window` to track scroll depth; the button is conditionally included in `baseof.html` on `.Kind "page"` pages (same condition as reading progress bar). CSS lives in a new `.back-to-top` component class in `main.css`. **Tech Stack:** Hugo partials, Alpine.js 3.x (inline x-data), Tailwind CSS (@apply), Feather Icons (chevron-up inlined SVG) --- ## File Map | Action | File | Responsibility | |---|---|---| | Create | `themes/danix-xyz-hacker/layouts/partials/back-to-top.html` | Button markup + Alpine logic | | Modify | `themes/danix-xyz-hacker/assets/css/main.css` | `.back-to-top` component class | | Modify | `themes/danix-xyz-hacker/layouts/_default/baseof.html` | Include partial on `.Kind "page"` | | Modify | `themes/danix-xyz-hacker/i18n/en.yaml` | `back_to_top` key | | Modify | `themes/danix-xyz-hacker/i18n/it.yaml` | `back_to_top` key (Italian) | --- ### Task 1: Add `.back-to-top` CSS component class **Files:** - Modify: `themes/danix-xyz-hacker/assets/css/main.css` (append inside `@layer components`, after `.toast-container`) - [ ] **Step 1: Open `main.css` and locate the end of `@layer components`** Find the closing `}` of `@layer components`. It ends around line 1165 (after `.tooltip-text`). Add the new class block just before that closing brace. - [ ] **Step 2: Add the `.back-to-top` class** ```css /* Back to top button */ .back-to-top { @apply fixed bottom-6 right-6 z-40 w-11 h-11 rounded-full flex items-center justify-content-center; background: var(--accent); box-shadow: 0 0 12px rgba(168, 85, 247, 0.4); transition: background 200ms ease, box-shadow 200ms ease; color: #fff; } .back-to-top:hover { background: #9333ea; box-shadow: 0 0 20px var(--accent); } .back-to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } ``` - [ ] **Step 3: Rebuild CSS** ```bash cd /home/danix/Programming/GIT/danix.xyz-hacker-theme && npm run build ``` Expected: exits 0, `themes/danix-xyz-hacker/static/css/main.min.css` updated. - [ ] **Step 4: Commit** ```bash git add themes/danix-xyz-hacker/assets/css/main.css themes/danix-xyz-hacker/static/css/main.min.css git commit -m "style: add .back-to-top component class" ``` --- ### Task 2: Create `back-to-top.html` partial **Files:** - Create: `themes/danix-xyz-hacker/layouts/partials/back-to-top.html` - [ ] **Step 1: Create the partial file** ```html