2 Commits

Author SHA1 Message Date
f64e9cd5a2 Make category tree items span full parent width (v0.1.9)
All checks were successful
Create Release Package / PHP Lint (push) Successful in 46s
Create Release Package / PHPUnit Tests (push) Successful in 51s
Create Release Package / Build Release (push) Successful in 1m3s
Move <a> elements to be direct children of the list-group so they
naturally fill the full offcanvas/sidebar width. Chevron toggle moved
inside the link with click interception to prevent navigation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 16:02:13 +02:00
1e7f82615b Restyle category tree to idiomatic Bootstrap list-group pattern (v0.1.8)
All checks were successful
Create Release Package / PHP Lint (push) Successful in 48s
Create Release Package / PHPUnit Tests (push) Successful in 56s
Create Release Package / Build Release (push) Successful in 1m4s
Switch from custom link classes to Bootstrap's native list-group-item-action
pattern. Replace bold primary-colored active background with subtle tertiary
background, left accent border, and semibold text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 15:42:35 +02:00
6 changed files with 87 additions and 67 deletions

View File

@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.1.9] - 2026-03-29
### Changed
- **Category tree full-width items** (`category-tree-node.html.twig`): Made `<a>` elements direct children of the `list-group` so they span the full parent/offcanvas width; moved chevron toggle inside the link as a `<span>` with click interception
- **Category tree nav wrapper** (`category-tree.html.twig`): Added `w-100` to nav and list-group containers
## [0.1.8] - 2026-03-29
### Changed
- **Category tree restyled** (`category-tree.html.twig`, `category-tree-node.html.twig`): Switched from custom link classes to Bootstrap's native `list-group-item list-group-item-action` pattern with nested collapse divs for a more idiomatic Bootstrap look
- **Subtler active state** (`wc-bootstrap.css`): Replaced bold primary-colored background with light background (`var(--bs-tertiary-bg)`), left accent border (`3px solid var(--bs-primary)`), and semibold text for a less prominent highlight
## [0.1.7] - 2026-03-29 ## [0.1.7] - 2026-03-29
### Added ### Added

View File

@@ -345,10 +345,31 @@ The child theme inherits from `wp-bootstrap` via WordPress `Template: wp-bootstr
## Version History ## Version History
Current version: **v0.1.7** Current version: **v0.1.9**
## Session History ## Session History
### 2026-03-29 — v0.1.9 Category Tree Full-Width Items
**Scope:** Made category tree items span the full parent/offcanvas width.
**Files modified (3):**
- `templates/global/category-tree.html.twig` — Added `w-100` to nav and list-group containers
- `templates/global/category-tree-node.html.twig` — Made `<a>` elements direct children of the list-group; moved chevron toggle inside the link as a `<span>` with `event.preventDefault()` click interception
- `style.css` — Version bump 0.1.8 → 0.1.9
### 2026-03-29 — v0.1.8 Restyle Category Tree to Idiomatic Bootstrap
**Scope:** Restyled the category tree sidebar to use Bootstrap's native `list-group-item-action` pattern with subtler active highlighting.
**Files modified (4):**
- `templates/global/category-tree.html.twig` — Switched to `list-group-item list-group-item-action` links in a `list-group-flush` container
- `templates/global/category-tree-node.html.twig` — Replaced nested `<ul>` lists with `<div>` wrappers and Bootstrap `collapse` divs; level indentation via inline `padding-left`
- `assets/css/wc-bootstrap.css` — Replaced primary-colored active background with subtle tertiary background, left accent border, and semibold text; removed unused `.category-tree-link` rules
- `style.css` — Version bump 0.1.7 → 0.1.8
### 2026-03-29 — v0.1.7 Add Product Category Tree Sidebar ### 2026-03-29 — v0.1.7 Add Product Category Tree Sidebar
**Scope:** Added a hierarchical product category tree sidebar to archive/shop and single product pages, with collapsible sub-levels up to 3 levels deep. **Scope:** Added a hierarchical product category tree sidebar to archive/shop and single product pages, with collapsible sub-levels up to 3 levels deep.

View File

@@ -648,6 +648,7 @@ header.sticky-top.is-stuck {
/* ========================================================================== /* ==========================================================================
Category Tree Sidebar Category Tree Sidebar
Hierarchical product category navigation with collapsible sub-levels. Hierarchical product category navigation with collapsible sub-levels.
Uses Bootstrap list-group-item-action with subtle active styling.
========================================================================== */ ========================================================================== */
.category-tree { .category-tree {
@@ -658,24 +659,17 @@ header.sticky-top.is-stuck {
background-color: transparent; background-color: transparent;
} }
.category-tree-link { /* Subtle active state: fw-semibold + left accent border instead of
color: var(--bs-body-color); full primary background, keeping the look understated. */
transition: background-color 0.15s ease, color 0.15s ease; .category-tree .list-group-item.active {
}
.category-tree-link:hover {
background-color: var(--bs-tertiary-bg); background-color: var(--bs-tertiary-bg);
color: var(--bs-body-color); color: var(--bs-body-color);
border-left: 3px solid var(--bs-primary);
font-weight: 600;
} }
.category-tree-link.active { .category-tree .list-group-item.active small {
background-color: var(--bs-primary); color: var(--bs-body-secondary) !important;
color: #fff;
}
.category-tree-link.active .badge {
background-color: rgba(255, 255, 255, 0.2) !important;
color: #fff !important;
} }
/* Rotate chevron icon when collapsed/expanded */ /* Rotate chevron icon when collapsed/expanded */
@@ -686,8 +680,3 @@ header.sticky-top.is-stuck {
.category-tree-toggle[aria-expanded="false"] .bi { .category-tree-toggle[aria-expanded="false"] .bi {
transform: rotate(-90deg); transform: rotate(-90deg);
} }
/* Nested list indentation */
.category-tree .list-group-flush .list-group-flush {
padding-left: 0.75rem;
}

View File

@@ -7,7 +7,7 @@ Description: A Bootstrap 5 child theme for WP Bootstrap that overrides all WooCo
Requires at least: 6.7 Requires at least: 6.7
Tested up to: 6.7 Tested up to: 6.7
Requires PHP: 8.3 Requires PHP: 8.3
Version: 0.1.7 Version: 0.1.9
License: GNU General Public License v2 or later License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
Template: wp-bootstrap Template: wp-bootstrap

View File

@@ -1,8 +1,8 @@
{# {#
# Single Category Tree Node (recursive) # Single Category Tree Node (recursive)
# #
# Renders one category with optional collapsible children. # Renders one category as a list-group-item-action link with optional
# Included recursively by category-tree.html.twig. # collapsible nested children. Included recursively.
# #
# Expected context: # Expected context:
# node - Category node from wc_bootstrap_get_category_tree() # node - Category node from wc_bootstrap_get_category_tree()
@@ -12,35 +12,33 @@
# @since 0.1.7 # @since 0.1.7
#} #}
<li class="list-group-item px-0 py-1 border-0"> {% set has_children = node.children is not empty %}
<div class="d-flex align-items-center"> {% set is_open = node.is_active or node.is_ancestor %}
<a href="{{ node.url }}"
class="category-tree-link d-block text-decoration-none py-1 px-2 rounded flex-grow-1{% if node.is_active %} active fw-semibold{% endif %}"
{% if node.is_active %}aria-current="page"{% endif %}>
<span class="ps-{{ (level - 1) * 2 }}">
{{ node.name }}
</span>
<span class="badge bg-body-secondary text-body-secondary rounded-pill ms-1 small">{{ node.count }}</span>
</a>
{% if node.children is not empty %}
<button class="btn btn-sm btn-link text-body-secondary p-0 ms-1 category-tree-toggle"
type="button"
data-bs-toggle="collapse"
data-bs-target="#cat-{{ node.term_id }}"
aria-expanded="{{ node.is_active or node.is_ancestor ? 'true' : 'false' }}"
aria-controls="cat-{{ node.term_id }}"
aria-label="{{ __('Toggle subcategories', 'wc-bootstrap') }}">
<i class="bi bi-chevron-down small" aria-hidden="true"></i>
</button>
{% endif %}
</div>
{% if node.children is not empty %} <a href="{{ node.url }}"
<ul class="list-group list-group-flush collapse{{ node.is_active or node.is_ancestor ? ' show' : '' }}" class="list-group-item list-group-item-action border-0 py-1 d-flex align-items-center{% if node.is_active %} active{% endif %}"
id="cat-{{ node.term_id }}"> style="padding-left: {{ 0.75 + (level - 1) * 1 }}rem;"
{% for child in node.children %} {% if node.is_active %}aria-current="page"{% endif %}>
{% include 'global/category-tree-node.html.twig' with { node: child, level: level + 1 } only %} <span class="flex-grow-1">{{ node.name }}</span>
{% endfor %} <small class="text-body-secondary ms-1">({{ node.count }})</small>
</ul> {% if has_children %}
<span class="category-tree-toggle ms-1"
role="button"
data-bs-toggle="collapse"
data-bs-target="#cat-{{ node.term_id }}"
aria-expanded="{{ is_open ? 'true' : 'false' }}"
aria-controls="cat-{{ node.term_id }}"
aria-label="{{ __('Toggle subcategories', 'wc-bootstrap') }}"
onclick="event.preventDefault(); event.stopPropagation();">
<i class="bi bi-chevron-down small" aria-hidden="true"></i>
</span>
{% endif %} {% endif %}
</li> </a>
{% if has_children %}
<div class="collapse{{ is_open ? ' show' : '' }}" id="cat-{{ node.term_id }}">
{% for child in node.children %}
{% include 'global/category-tree-node.html.twig' with { node: child, level: level + 1 } only %}
{% endfor %}
</div>
{% endif %}

View File

@@ -1,34 +1,32 @@
{# {#
# Product Category Tree (Bootstrap 5) # Product Category Tree (Bootstrap 5)
# #
# Renders a hierarchical product category navigation with collapsible # Renders a hierarchical product category navigation using Bootstrap
# sub-levels, up to 3 levels deep. Uses Bootstrap 5 list-group and # list-group with nested sub-lists and action links.
# collapse components for responsive tree navigation.
# #
# Expected context: # Expected context:
# categories - Hierarchical array from wc_bootstrap_get_category_tree() # categories - Hierarchical array from wc_bootstrap_get_category_tree()
# shop_url - URL to the main shop page # shop_url - URL to the main shop page
# current_cat - Term ID of the currently viewed category (0 = shop page)
# #
# @package WcBootstrap # @package WcBootstrap
# @since 0.1.7 # @since 0.1.7
#} #}
{% if categories is not empty %} {% if categories is not empty %}
<nav aria-label="{{ __('Product categories', 'wc-bootstrap') }}"> <nav class="category-tree w-100" aria-label="{{ __('Product categories', 'wc-bootstrap') }}">
<h3 class="sidebar-heading h6 text-uppercase fw-semibold"> <h3 class="sidebar-heading h6 text-uppercase fw-semibold">
{{ __('Categories', 'wc-bootstrap') }} {{ __('Categories', 'wc-bootstrap') }}
</h3> </h3>
<ul class="list-group list-group-flush category-tree"> <div class="list-group list-group-flush w-100">
<li class="list-group-item px-0 py-1"> <a href="{{ shop_url }}"
<a href="{{ shop_url }}" class="list-group-item list-group-item-action border-0 py-1{% if current_cat == 0 %} active{% endif %}">
class="category-tree-link d-block text-decoration-none py-1 px-2 rounded{% if current_cat == 0 %} active fw-semibold{% endif %}"> {{ __('All products', 'wc-bootstrap') }}
{{ __('All products', 'wc-bootstrap') }} </a>
</a>
</li>
{% for cat in categories %} {% for cat in categories %}
{% include 'global/category-tree-node.html.twig' with { node: cat, level: 1 } only %} {% include 'global/category-tree-node.html.twig' with { node: cat, level: 1 } only %}
{% endfor %} {% endfor %}
</ul> </div>
</nav> </nav>
{% endif %} {% endif %}