Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6279: Multilevel popup menu #897

Merged
merged 23 commits into from
Sep 26, 2023
Merged

IBX-6279: Multilevel popup menu #897

merged 23 commits into from
Sep 26, 2023

Conversation

tischsoic
Copy link
Contributor

Question Answer
Tickets https://issues.ibexa.co/browse/IBX-6279
Bug fix? no
New feature? yes/no
BC breaks? no
Tests pass? yes
Doc needed? yes
License GPL-2.0

MultilevelPopupMenu

This is a new component which is context-like menu.

twig example

Result

Screenshot 2023-08-23 at 21 54 23

Code

{{ include('@ibexadesign/ui/component/multilevel_popup_menu/multilevel_popup_menu.html.twig', {
    groups: [
        {
            id: 'default',
            items: [
                {
                    label: 'Label 1',
                    action_attr: { href: path('logout') },
                    sublabel: 'default',
                },
                {
                    label: 'Label 2',
                },
            ],
        },
        {
            id: 'second',
            items: [
                {
                    label: 'Label 3.1',
                },
                {
                    label: 'Label 3.2',
                    sublabel: 'default',
                    branch: {
                        groups: [
                            {
                                id: 'default',
                                items: [
                                    {
                                        label: 'SubLabel 1',
                                        branch: {
                                            groups: [
                                                {
                                                    id: 'group1',
                                                    items: [
                                                        {
                                                            label: 'SubSubLabel 1',
                                                        },
                                                        {
                                                            label: 'SubSubLabel 2',
                                                        },
                                                    ],
                                                },
                                            ],
                                        }
                                    },
                                    {
                                        label: 'SubLabel 2',
                                        branch: {
                                            groups: [
                                                {
                                                    id: 'group2',
                                                    items: [
                                                        {
                                                            label: 'SubSubLabel 1',
                                                        },
                                                        {
                                                            label: 'SubSubLabel 2',
                                                        },
                                                    ],
                                                },
                                            ],
                                        }
                                    },
                                ]
                            }
                        ]
                    },
                },
                {
                    label: 'Label 4',
                },
            ]
        }
    ],
}) }}

JS

TODO

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@@ -8,7 +8,7 @@
border-top-left-radius: $ibexa-border-radius;
border-top-right-radius: $ibexa-border-radius;
transition: all $ibexa-admin-transition-duration $ibexa-admin-transition, border-bottom-width 0;
z-index: 2;
z-index: 1050;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tischsoic tischsoic marked this pull request as ready for review September 8, 2023 08:25
}
}
}
&--no-absolute {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of no-absolute -> initial-pos or static-pos

}
}

isOurBranch(branch) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does Our mean in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether this branch belongs to this menu.

src/bundle/Resources/public/scss/_split-button.scss Outdated Show resolved Hide resolved

&__split {
display: none;
width: calculateRem(0.5px);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use half pixels? I think there were some problems between browsers/systems using it, but I'm not sure now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR I've done this for the retina to look better and AFAIK we use half pixels.
Actually, it will be served to the browser in rem where we use non-integer values all the time.

display: none;
position: absolute;
right: calculateRem(8px);
top: calc(50% - calculateRem(16px) / 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that does not work and you have to use ${calculateRem(xxx) inside calc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works

content: '';
border-top: calculateRem(1px) solid $ibexa-color-light;
display: flex;
width: calc(100% - calculateRem(16px));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works

@Gengar-i Gengar-i self-requested a review September 8, 2023 13:24
@@ -21,40 +25,109 @@
},
onAdapted: (visibleItems, hiddenItems) => {
const hiddenButtonsIds = [...hiddenItems].map((item) => item.querySelector('.ibexa-btn').id);
const topBranchItems = multilevelPopupMenu.getBranchItems(topBranch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is branch item like all of the items in current menu?
what is topBranchItems then? ParentItems of currentBranch?
Maybe parentBranchItems?
Or only like pinned items on top?

Copy link
Contributor Author

@tischsoic tischsoic Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I don't understand these questions, could you be more specific/precise? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just dont understand what is topBranch items :D

const relatedMainBtnId = mainBtn.id;
const mainBtnLabel = mainBtn.querySelector('.ibexa-btn__label').textContent;
const {
alternativeMainBtnLabel: mainBtnAlternativeLabel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it bc you are already using this name in scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted this name to be more consistent with names in the upper scope.

@@ -0,0 +1,385 @@
(function (global, doc, ibexa, Popper) {
class MultilevelPopupMenu {
constructor(config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about destructuring config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to not destructure configs in our codebase so that it is more clear in the constructor which thing comes from it.

return newBranchElement;
}

// eslint-disable-next-line no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u explain why we need this here?
Cannot we just pass instead of arguments data and this variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguments is better in a case e.g. this class is overwritten.


branchElement.classList.toggle('ibexa-popup-menu--hidden', !shouldBeExpanded);

if (branchElement === topBranch) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should work

@tischsoic tischsoic force-pushed the multilevel-popup-menu branch 2 times, most recently from b9de87f to 040945a Compare September 11, 2023 11:11
),
];
const popupMenuElement = adaptedItemsContainer.querySelector('.ibexa-context-menu__item--more .ibexa-multilevel-popup-menu');
const showPopupButton = adaptedItemsContainer.querySelector('.ibexa-btn--more');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes you use btn (relatedBtn) and sometimes button (showPopupButton) in your variable names, I think it would be good to stick to one version

alternativeToggleLabel,
} = menuButton.dataset;
const subitemsBtns = [...splitBtn.branchElement.querySelectorAll('.ibexa-popup-menu__item-content')];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}
}

.ibexa-main-menu-popup &__group-name {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
.ibexa-main-menu-popup &__group-name {
&__group-name {

or

Suggested change
.ibexa-main-menu-popup &__group-name {
& &__group-name {

@tischsoic tischsoic force-pushed the multilevel-popup-menu branch from 040945a to b23ad56 Compare September 20, 2023 12:44
@dew326 dew326 merged commit 659fa4f into main Sep 26, 2023
8 of 12 checks passed
@dew326 dew326 deleted the multilevel-popup-menu branch September 26, 2023 13:46
@sonarcloud
Copy link

sonarcloud bot commented Sep 26, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 28 Code Smells

No Coverage information No Coverage information
12.5% 12.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants