No need! The traditional Drupal blocks are good enough, no need for custom SSR blocks. From my point of view, any twig/html/dynamic data-needed blocks can be/should be resolved with traditional Drupal blocks. No need for "dynamic blocks" as in the example_blocks submodule.
Great work! Thanks!
lyxuanngoc → created an issue.
lyxuanngoc → created an issue.
You can use the default menu block from Drupal, ensure that you tick the expand-all-children option and add the script below
(function ($, Drupal) { // show #toolbar-administration if exists Drupal.behaviors.sidebarAccordionMenu = { attach: function (context, settings) { if (context !== document) { return; } // append a button to each menu item that has children, after the link $('#block-your-menu .menu-item--expanded').each(function() { // if the element has class menu-item--active-trail, append a - button if ($(this).hasClass('menu-item--active-trail')) { $(this).children('a').after('<button class="expand-collapse">-</button>'); } else { $(this).children('a').after('<button class="expand-collapse">+</button>'); } }); // collapse all child menus by default $('#block-your-menu .menu-item--expanded').not('.menu-item--active-trail').find('ul').hide(); // expand/collapse child menus when the button is clicked $('#block-your-menu .expand-collapse').click(function() { $(this).parent().find('ul').toggle(); $(this).text($(this).text() == '+' ? '-' : '+'); }); } }; } (jQuery, Drupal));