Skip to content

Commit c919136

Browse files
michaelclaessonSebastian Thulin
andauthored
feat: drawer menu level indention and new toggler (#1368)
* Support for indenting drawer menu on each level and having plus/minus toggle instead of caret * fix: move indentation & icons to a separate panel (vertical). * fix: use select field to provide setting for indentation of vertical nav menus * fix: set defaults * fix: correct icon * fix: remove hardcoded modifier. Add reactive icon for toggle button. * fix: use a switch can be used due to new param in component. * fix: set a resonable default value. * fix: rename tab menu. * chore: update styleguide * chore: add swedish translations. --------- Co-authored-by: Sebastian Thulin <sebastian.thulin@helsingborg.se>
1 parent 4d63e8b commit c919136

9 files changed

Lines changed: 3903 additions & 3322 deletions

File tree

languages/sv_SE.mo

13.7 KB
Binary file not shown.

languages/sv_SE.po

Lines changed: 3766 additions & 3260 deletions
Large diffs are not rendered by default.

library/Api/Navigation/ChildrenRender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response
3636
$parentId = !empty($params['pageId']) ? $params['pageId'] : null;
3737
$viewPath = !empty($params['viewPath']) ? $params['viewPath'] : false;
3838
$identifier = !empty($params['identifier']) ? $params['identifier'] : '';
39-
$depth = !empty($params['depth']) ? $params['depth'] : '0';
39+
$depth = !empty($params['depth']) ? $params['depth'] : '1';
4040
$lang = TranslatedLabels::getLang();
4141

4242
if (!empty($parentId)) {

library/Controller/Navigation/Decorators/Menu/PageTreeAppendMenuItemsFetchUrl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public function getMenu(): array
4141

4242
$homeUrl = $this->wpService->applyFilters('Municipio/homeUrl', $this->wpService->escUrl($this->wpService->getHomeUrl()));
4343

44+
$depth = isset($_GET['depth']) ? intval($_GET['depth']) + 1 : 2;
45+
4446
foreach ($menu['items'] as &$menuItem) {
4547
$fetchUrl = $homeUrl
4648
. '/wp-json/municipio/v1/navigation/children/render'
47-
. '?' . 'pageId=' . $menuItem['id'] . '&viewPath=' . 'partials.navigation.'
49+
. '?' . 'pageId=' . $menuItem['id'] . '&depth=' . $depth . '&viewPath=' . 'partials.navigation.'
4850
. $targetMenuIdentifiers[$identifier] . '&identifier='
4951
. $targetMenuIdentifiers[$identifier];
5052

library/Customizer/PanelsRegistry.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ public static function registerNavMenusPanel()
459459
->setID('municipio_customizer_section_header_panel_tab_menu')
460460
->setTitle(esc_html__('Tab menu', 'municipio'))
461461
->setFieldsCallback(fn() => new \Municipio\Customizer\Sections\Menu\Tabmenu('municipio_customizer_section_header_panel_tab_menu'))
462+
)->addSection(
463+
KirkiPanelSection::create()
464+
->setID('municipio_customizer_section_vertical')
465+
->setTitle(esc_html__('General: Menu Settings (vertical)', 'municipio'))
466+
->setFieldsCallback(fn() => new \Municipio\Customizer\Sections\Menu\Vertical('municipio_customizer_section_vertical'))
462467
)
463468
->register();
464469
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Municipio\Customizer\Sections\Menu;
4+
5+
use Municipio\Customizer\KirkiField;
6+
7+
class Vertical
8+
{
9+
public const SECTION_ID = "municipio_customizer_section_vertical";
10+
11+
public function __construct(string $sectionID)
12+
{
13+
14+
KirkiField::addField([
15+
'type' => 'select',
16+
'settings' => 'vertical_menu_sublevel_trigger_icon',
17+
'label' => esc_html__('Submenu expand icon', 'municipio'),
18+
'description' => esc_html__('The icon that will indicate that a submenu can be expanded', 'municipio'),
19+
'section' => $sectionID,
20+
'default' => 'expand_more',
21+
'priority' => 10,
22+
'choices' => [
23+
'expand_more' => esc_html__('Directional Caret', 'municipio'), //Standard material icon class
24+
'toggleAriaPressedPlusMinus' => esc_html__('Plus/Minus', 'municipio'), //Custom svg
25+
],
26+
'output' => [
27+
[
28+
'type' => 'component_data',
29+
'dataKey' => 'expandIcon',
30+
'context' => [
31+
[
32+
'context' => 'component.nav',
33+
'operator' => '==',
34+
]
35+
]
36+
]
37+
],
38+
]);
39+
40+
KirkiField::addField([
41+
'type' => 'switch',
42+
'settings' => 'vetical_menu_indent_sublevels',
43+
'label' => esc_html__('Indent each level', 'municipio'),
44+
'description' => esc_html__('Submenus will indent one step for every level down', 'municipio'),
45+
'section' => $sectionID,
46+
'default' => false,
47+
'choices' => [
48+
true => esc_html__('Enabled', 'municipio'),
49+
false => esc_html__('Disabled', 'municipio'),
50+
],
51+
'priority' => 10,
52+
'output' => [
53+
[
54+
'type' => 'component_data',
55+
'dataKey' => 'indentSubLevels',
56+
'context' => [
57+
[
58+
'context' => 'component.nav',
59+
'operator' => '==',
60+
]
61+
]
62+
]
63+
],
64+
]);
65+
}
66+
}

package-lock.json

Lines changed: 57 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/v3/partials/navigation/drawer.blade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'color' => $customizer->headerTriggerButtonColor,
66
'style' => $customizer->headerTriggerButtonType,
77
'size' => $customizer->headerTriggerButtonSize,
8-
'icon' => 'menu',
8+
'icon' => 'toggleAriaPressedHamburgerClose',
99
'context' => ['site.header.menutrigger', 'site.header.casual.menutrigger'],
1010
'classList' => ['mobile-menu-trigger', 'u-order--10', 's-header-button'],
1111
'text' => $lang->menu,
@@ -64,7 +64,8 @@
6464
'direction' => 'vertical',
6565
'includeToggle' => true,
6666
'height' => 'sm',
67-
'expandLabel' => $lang->expand
67+
'expandLabel' => $lang->expand,
68+
'context' => 'site.mobile-menu'
6869
])
6970
@endnav
7071
@endslot

views/v3/partials/navigation/mobile.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
'includeToggle' => true,
77
'classList' => $classList,
88
'depth' => $depth ?? 1,
9-
'expandLabel' => $lang->expand
9+
'expandLabel' => $lang->expand,
10+
'context' => 'site.mobile-menu'
1011
])
1112
@endnav
1213
@else

0 commit comments

Comments
 (0)