Skip to content

Commit e39b11a

Browse files
authored
Merge pull request #17 from troychaplin/fix/no-wrap
Fixed issue with single nav item, added new style controls
2 parents 6b82231 + 73e1ad3 commit e39b11a

20 files changed

Lines changed: 3366 additions & 170 deletions

CHANGELOG.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
Prefix the change with one of these keywords:
9+
10+
- _Added_: for new features.
11+
- _Changed_: for changes in existing functionality.
12+
- _Deprecated_: for soon-to-be removed features.
13+
- _Removed_: for now removed features.
14+
- _Fixed_: for any bug fixes.
15+
- _Security_: in case of vulnerabilities.
16+
17+
## [Unreleased]
18+
19+
- _Added_: Editor preview of the More button that reflects label, colors, and padding settings
20+
- _Added_: Transform to convert Priority Plus Navigation back to standard Navigation block
21+
- _Added_: Mobile collapse option to collapse all items into the toggle button at the mobile breakpoint (enabled by default)
22+
- _Added_: Button border controls (color, width, style) with per-side support in new "Priority Plus Button Border" panel
23+
- _Added_: Button border radius control with per-corner support
24+
- _Changed_: All items can now move into the dropdown when space is insufficient, removing the forced minimum of one visible item
25+
- _Fixed_: Navigation items and More button no longer wrap to a second line
26+
- _Fixed_: Initial page load now correctly calculates overflow and shows the More button
27+
- _Fixed_: Items correctly restore from mobile collapse when resizing to desktop
28+
- _Fixed_: More button chevron icon spacing — offset SVG internal padding so the arrow sits flush with the button's right edge (frontend and editor)
29+
30+
## [1.0.0]
31+
32+
### Core
33+
34+
- _Added_: Priority Plus Navigation as a block variation of the core Navigation block
35+
- _Added_: Automatic overflow detection using ResizeObserver to show/hide items based on available space
36+
- _Added_: Dynamic "More" dropdown that collects overflow navigation items
37+
- _Added_: Support for multiple Priority Plus Navigation instances on the same page
38+
- _Added_: Width caching and requestAnimationFrame for performant resize calculations
39+
40+
### Editor Controls
41+
42+
- _Added_: Customizable "More" button label
43+
- _Added_: Button color controls for text, background, and hover states
44+
- _Added_: Button padding controls with theme spacing size support
45+
- _Added_: Dropdown customizer modal with live preview
46+
- _Added_: Dropdown menu color controls (background, item text, hover states)
47+
- _Added_: Dropdown border controls with per-side support, radius, and box shadow
48+
- _Added_: Dropdown item padding and separator styling
49+
- _Added_: Submenu color controls (background, text, hover states)
50+
- _Added_: Submenu indentation control for nested menu levels
51+
- _Added_: Reset to defaults for all dropdown styles
52+
53+
### Submenu & Accordion Support
54+
55+
- _Added_: Accordion pattern for nested submenus within the dropdown
56+
- _Added_: Click mode (full button toggle) and arrow mode (separate toggle button) based on core submenu settings
57+
- _Added_: Keyboard navigation with Escape key to close dropdowns and accordions
58+
- _Added_: Full ARIA support for accordion expand/collapse states
59+
60+
### Overlay Menu Compatibility
61+
62+
- _Added_: Automatic detection of WordPress overlay/hamburger menu state
63+
- _Added_: Priority Plus disables when hamburger menu is active, re-enables on desktop
64+
- _Changed_: "Always" overlay option is prevented and auto-converted to "Mobile" with editor notice
65+
66+
### Theme Integration
67+
68+
- _Added_: theme.json support via `settings.custom.priorityPlusNavigation.dropdown` path
69+
- _Added_: CSS custom properties for all styling options
70+
- _Added_: WordPress preset value support (spacing sizes, colors)
71+
- _Added_: Block-level overrides that take precedence over theme.json defaults

build/priority-plus-nav-editor-rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => '37d504951cbec98b7de6');
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => '34a9021994af185b8fdb');

build/priority-plus-nav-editor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/priority-plus-nav-editor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '874dfb5c427f37e2a56b');
1+
<?php return array('dependencies' => array(), 'version' => '276687636cd44ad78f29');

build/priority-plus-navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/style-priority-plus-navigation-rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/style-priority-plus-navigation.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/class-block-renderer.php

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,15 @@ private function collect_attributes( array $block ): array {
154154
'toggle_text_color' => $this->get_priority_attr( $block, 'priorityPlusToggleTextColor', '' ),
155155
'toggle_text_color_hover' => $this->get_priority_attr( $block, 'priorityPlusToggleTextColorHover', '' ),
156156
'toggle_padding' => $this->get_priority_attr( $block, 'priorityPlusTogglePadding', array() ),
157+
'toggle_border' => $this->get_priority_attr( $block, 'priorityPlusToggleBorder', array() ),
158+
'toggle_border_radius' => $this->get_priority_attr( $block, 'priorityPlusToggleBorderRadius', '' ),
157159

158160
// Core navigation attribute.
159161
'overlay_menu' => $this->get_priority_attr( $block, 'overlayMenu', 'never' ),
160162

163+
// Mobile collapse.
164+
'mobile_collapse' => $this->get_priority_attr( $block, 'priorityPlusMobileCollapse', true ),
165+
161166
// Menu style attributes.
162167
'menu_background_color' => $this->get_priority_attr( $block, 'priorityPlusMenuBackgroundColor', '' ),
163168
'menu_border' => $this->get_priority_attr( $block, 'priorityPlusMenuBorder', array() ),
@@ -198,10 +203,11 @@ private function inject_priority_attributes( string $block_content, array $attri
198203

199204
// Build data attributes string.
200205
$data_attributes = sprintf(
201-
'$1 data-more-label="%s" data-more-icon="%s" data-overlay-menu="%s"',
206+
'$1 data-more-label="%s" data-more-icon="%s" data-overlay-menu="%s" data-mobile-collapse="%s"',
202207
esc_attr( $attributes['toggle_label'] ),
203208
esc_attr( $attributes['toggle_icon'] ),
204-
esc_attr( $attributes['overlay_menu'] )
209+
esc_attr( $attributes['overlay_menu'] ),
210+
$attributes['mobile_collapse'] ? 'true' : 'false'
205211
);
206212

207213
// Add style attribute if we have any styles.
@@ -303,6 +309,92 @@ private function add_toggle_styles( array $attributes, array $style_parts ): arr
303309
}
304310
}
305311

312+
// Convert toggle border to CSS custom properties.
313+
if ( is_array( $attributes['toggle_border'] ) && ! empty( $attributes['toggle_border'] ) ) {
314+
$style_parts = $this->add_toggle_border_styles( $attributes['toggle_border'], $style_parts );
315+
}
316+
317+
// Convert toggle border radius to CSS.
318+
if ( ! empty( $attributes['toggle_border_radius'] ) ) {
319+
$radius_css = $this->css_converter->border_radius_to_css( $attributes['toggle_border_radius'] );
320+
if ( '' !== $radius_css ) {
321+
$style_parts[] = sprintf(
322+
'--priority-plus-navigation--border-radius: %s',
323+
esc_attr( $radius_css )
324+
);
325+
}
326+
}
327+
328+
return $style_parts;
329+
}
330+
331+
/**
332+
* Add toggle button border CSS custom properties.
333+
*
334+
* Handles both flat format (color, width, style at top level) and
335+
* per-side format (top, right, bottom, left objects).
336+
* Outputs unified --border-color, --border-width, --border-style vars.
337+
*
338+
* @param array $border Border attribute value.
339+
* @param array $style_parts Current style parts array.
340+
* @return array Updated style parts array.
341+
*/
342+
private function add_toggle_border_styles( array $border, array $style_parts ): array {
343+
// Flat format: { color, width, style }.
344+
if ( isset( $border['color'] ) || isset( $border['width'] ) || isset( $border['style'] ) ) {
345+
if ( ! empty( $border['color'] ) ) {
346+
$style_parts[] = sprintf(
347+
'--priority-plus-navigation--border-color: %s',
348+
esc_attr( $border['color'] )
349+
);
350+
}
351+
if ( ! empty( $border['width'] ) ) {
352+
$style_parts[] = sprintf(
353+
'--priority-plus-navigation--border-width: %s',
354+
esc_attr( $border['width'] )
355+
);
356+
}
357+
if ( ! empty( $border['style'] ) ) {
358+
$style_parts[] = sprintf(
359+
'--priority-plus-navigation--border-style: %s',
360+
esc_attr( $border['style'] )
361+
);
362+
}
363+
return $style_parts;
364+
}
365+
366+
// Per-side format: { top: {...}, right: {...}, bottom: {...}, left: {...} }.
367+
$sides = array( 'top', 'right', 'bottom', 'left' );
368+
$colors = array();
369+
$widths = array();
370+
$styles = array();
371+
372+
foreach ( $sides as $side ) {
373+
if ( isset( $border[ $side ] ) && is_array( $border[ $side ] ) ) {
374+
$s = $border[ $side ];
375+
$colors[] = isset( $s['color'] ) ? $s['color'] : 'transparent';
376+
$widths[] = isset( $s['width'] ) ? $s['width'] : '0';
377+
$styles[] = isset( $s['style'] ) ? $s['style'] : 'none';
378+
} else {
379+
$colors[] = 'transparent';
380+
$widths[] = '0';
381+
$styles[] = 'none';
382+
}
383+
}
384+
385+
$style_parts[] = sprintf(
386+
'--priority-plus-navigation--border-color: %s',
387+
esc_attr( implode( ' ', $colors ) )
388+
);
389+
$style_parts[] = sprintf(
390+
'--priority-plus-navigation--border-width: %s',
391+
esc_attr( implode( ' ', $widths ) )
392+
);
393+
$style_parts[] = sprintf(
394+
'--priority-plus-navigation--border-style: %s',
395+
esc_attr( implode( ' ', $styles ) )
396+
);
397+
306398
return $style_parts;
307399
}
308400

0 commit comments

Comments
 (0)