Refactor components

Created on 13 November 2023, about 1 year ago
Updated 15 November 2023, about 1 year ago

Problem/Motivation

1. Complex and monolithic javascript. The same functions are performed from several places independently.
2. Functional CSS contains many cascades and unreasonable increases in specificity, which makes it very difficult to maintain and extend.
3. aria attributes for menu links and buttons do not work when the URL is active.
4. We clone the submenu item in its folded state. Which is bad for both a11y and support.
5. We have a toolbar-link element which in fact does not exist without a parent menu and also has its logic spread out over several places.
6. The script for the menu and popover is the same, although they don’t have much in common

Proposed resolution

I divided the code into small and very simple components. CSS and JS which consists of one level. This is achieved by using customEvents. Similar to what we did in the wrapper script.

1. Tooltip. Which is added https://www.drupal.org/project/navigation/issues/3393067 ✨ Added tooltip component. Needs review
2. Main button https://www.drupal.org/project/navigation/issues/3393216 ✨ Split Navigation Button Component. Fixed

3. Simple menu with simple styles.
The script contains only the functionality of opening a child menu and a trigger in case of an active link.

4. Popover with simple styles and script. Where most of the logic from the previous script lies.

5. toolbar-link has been removed because it is not needed. It doesn't exist outside of the menu.

Small improvements that have been added:

1. Added font size for toolbar-button, reduced specificity of display properties
2. used aria-expanded and aria-controls to display the visibility and state of menu arrows.
3. Used currentColor for menu item icons and hover elements. This made it possible to set the color of states from one place

This is a continuation of the work from here https://www.drupal.org/project/navigation/issues/3386927#comment-15280734 πŸ“Œ Refactor CSS Needs work
There you can see the motivation and logic in more detail.

The MR turned out to be quite large. But this is a minimally significant MR because everything is very strongly connected and confused in the current implementation.
Everything works as it always did, but the code has become much simpler and more predictable

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡·πŸ‡ΈSerbia finnsky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024