You've already forked wp-bootstrap
feat: offcanvas mobile navigation with user avatar and admin bar fix (v1.0.11)
Switch mobile nav from collapse to offcanvas, add logged-in user avatar and My Account link to offcanvas header, move dark mode toggle to offcanvas footer. Fix admin bar overlapping offcanvas via inline CSS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
30
CLAUDE.md
30
CLAUDE.md
@@ -34,7 +34,7 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
|
||||
|
||||
**Note for AI Assistants:** Clean this section after the specific features are done or new releases are made. Effective changes are tracked in `CHANGELOG.md`. Do not add completed versions here - document them in the Session History section at the end of this file.
|
||||
|
||||
Current version is **v1.0.9**. See `PLAN.md` for details.
|
||||
Current version is **v1.0.11**. See `PLAN.md` for details.
|
||||
|
||||
## Technical Stack
|
||||
|
||||
@@ -234,6 +234,34 @@ Build steps (in order):
|
||||
|
||||
## Session History
|
||||
|
||||
### Session 17 — v1.0.11 Offcanvas Navigation & User Context (2026-02-28)
|
||||
|
||||
**Completed:** Switched mobile navigation from Bootstrap collapse to offcanvas, added logged-in user context to the header, and fixed admin bar overlap.
|
||||
|
||||
**What was changed:**
|
||||
|
||||
- **Offcanvas navigation** (`views/base.html.twig`): Default header include switched from `partials/header.html.twig` (collapse) to `partials/header-offcanvas.html.twig` (offcanvas slide-in from right). The offcanvas variant already existed in the theme.
|
||||
- **Offcanvas header with user avatar** (`views/partials/header-offcanvas.html.twig`): When logged in, the offcanvas header shows the user's Gravatar avatar and display name linking to the WooCommerce My Account page. Falls back to the site name when logged out.
|
||||
- **Dark mode toggle repositioned**: Moved from the offcanvas body to the offcanvas footer (`d-lg-none`) on mobile. On desktop (≥lg), the toggle remains visible next to the navbar via a separate `d-none d-lg-block` wrapper.
|
||||
- **User context in ContextBuilder** (`inc/Template/ContextBuilder.php`): New `getUserData()` method providing `user.logged_in`, `user.display_name`, `user.avatar` (rendered `<img>` with `rounded-circle` class), and `user.account_url` (WooCommerce My Account or WP admin profile fallback).
|
||||
- **Admin bar offcanvas overlap fix** (`functions.php`): Inline CSS injected via `wp_add_inline_style()` when `is_admin_bar_showing()` is true. Adds `padding-top: var(--wp-admin--admin-bar--height, 32px)` to `.offcanvas` so the offcanvas content clears the admin bar.
|
||||
|
||||
**Files modified:**
|
||||
|
||||
- `views/base.html.twig` — header include changed to offcanvas variant
|
||||
- `views/partials/header-offcanvas.html.twig` — user avatar header, dark mode toggle in footer
|
||||
- `inc/Template/ContextBuilder.php` — `getUserData()` method, `user` key in context
|
||||
- `functions.php` — admin bar offcanvas padding inline style
|
||||
- `style.css` — version bump to 1.0.11
|
||||
- `CHANGELOG.md` — v1.0.11 entry
|
||||
|
||||
**Key learnings:**
|
||||
|
||||
- Bootstrap offcanvas inside `navbar-expand-lg` uses `position: fixed; top: 0` which is covered by the WordPress admin bar (`z-index: 99999`). Since the offcanvas z-index (1045) is lower, adjusting `top` alone doesn't help visually — `padding-top` on the offcanvas content is the practical fix.
|
||||
- `wp_add_inline_style()` bypasses file-level browser caching, making it more reliable for conditional CSS rules than editing the main stylesheet.
|
||||
- WordPress's `--wp-admin--admin-bar--height` CSS custom property (set on `:root`) adjusts between 32px (desktop) and 46px (mobile ≤782px), making it the ideal value for admin bar offset calculations.
|
||||
- `get_avatar()` accepts an `$args` array where CSS classes can be passed via the `class` key, avoiding post-processing of the HTML output.
|
||||
|
||||
### Session 16 — v1.0.10 Title Double-Encoding Fix (2026-02-25)
|
||||
|
||||
**Completed:** Fixed double-encoding of HTML entities in page titles rendered through Twig.
|
||||
|
||||
Reference in New Issue
Block a user