Skip to content

XWIKI-22485: Livedata option dropdown has no grouping semantics #3662

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

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@
.divider {
.nav-divider(@dropdown-divider-bg);
}

// Dividers within the dropdown with an improved semantic representation
li:has(> ul) + li:has(> ul) {
border-top: solid 1px @dropdown-divider-bg;
padding-top: ((@line-height-computed / 2) - 1);
}
li:has(> ul):has(+ li > ul) {
margin-bottom: ((@line-height-computed / 2) - 1);
}

// Links within the dropdown menu
> li > a {
// Links within the dropdown menu and submenus
> li > a, > li > ul > li > a {
display: block;
padding: 3px 20px;
clear: both;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ function initWrapper() {

// Since the <li> elements does not have distinguishing attributes, we look for the layout items by looking at the
// elements located after the second separator (class dropdown-header).
// The lis passed here are both group lis and item lis. Group lis contain a title and their own item lis.
function findSecondDropdownHeaderIndex(lis) {
var dropdownHeadersCptr = 0;
var liIdx = 0;
for (; liIdx < lis.length; liIdx++) {
const li = lis.at(liIdx);
if (li.classes().includes('dropdown-header')) {
if (li.findAll('.dropdown-header').length > 0) {
dropdownHeadersCptr++;
}
if (dropdownHeadersCptr >= 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,42 @@
<ul class="dropdown-menu dropdown-menu-right">

<!-- Actions -->
<li class="dropdown-header">{{ $t('livedata.dropdownMenu.actions') }}</li>

<li>
<!-- Refresh -->
<a href="#" @click.prevent="logic.updateEntries()" class="livedata-action-refresh">
<XWikiIcon :icon-descriptor="{name: 'repeat'}" />
{{ $t('livedata.action.refresh') }}
</a>
</li>

<li><span class="dropdown-header">{{ $t('livedata.dropdownMenu.actions') }}</span><ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT of indenting the new ul block?

Copy link
Contributor Author

@Sereza7 Sereza7 Nov 27, 2024

Choose a reason for hiding this comment

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

Done in 53d85de 👍
I indented only once for the <li><ul> blocks though.

In order to avoid making code review more difficult for barely any reason, I try to not add indentation at first on code blocks where it looks okayish without it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Go ahead with the right formatting.

<li>
<!-- Refresh -->
<a href="#" @click.prevent="logic.updateEntries()" class="livedata-action-refresh">
<XWikiIcon :icon-descriptor="{name: 'repeat'}" />
{{ $t('livedata.action.refresh') }}
</a>
</li>
</ul></li>

<!-- Layouts -->
<li role="separator" class="divider"></li>

<li class="dropdown-header">{{ $t('livedata.dropdownMenu.layouts') }}</li>

<!-- Layout options -->
<li
v-for="layout in data.meta.layouts"
:key="layout.id"
:class="{
'disabled': isCurrentLayout(layout.id),
}"
>
<a href="#" @click.prevent="changeLayout(layout.id)">
<XWikiIcon :icon-descriptor="layout.icon"></XWikiIcon>
{{ layout.name }}
</a>
</li>
<li><span class="dropdown-header">{{ $t('livedata.dropdownMenu.layouts') }}</span><ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@Sereza7 Sereza7 Nov 27, 2024

Choose a reason for hiding this comment

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

Done in 53d85de 👍
Note that I updated all three uls

<!-- Layout options -->
<li
v-for="layout in data.meta.layouts"
:key="layout.id"
:class="{
'disabled': isCurrentLayout(layout.id),
}"
>
<a href="#" @click.prevent="changeLayout(layout.id)">
<XWikiIcon :icon-descriptor="layout.icon"></XWikiIcon>
{{ layout.name }}
</a>
</li>
</ul></li>

<!-- Panels -->
<li role="separator" class="divider"></li>

<li class="dropdown-header">{{ $t('livedata.dropdownMenu.panels') }}</li>

<li v-for="panel in logic.panels" :key="panel.id">
<a href="#" @click.prevent="logic.uniqueArrayToggle(logic.openedPanels, panel.id)">
<XWikiIcon :icon-descriptor="{name: panel.icon}"/>
{{ panel.name }}
</a>
</li>
<li><span class="dropdown-header">{{ $t('livedata.dropdownMenu.panels') }}</span><ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

that part could be indented 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.

Addressed in 3cb1436 👍

<li v-for="panel in logic.panels" :key="panel.id">
<a href="#" @click.prevent="logic.uniqueArrayToggle(logic.openedPanels, panel.id)">
<XWikiIcon :icon-descriptor="{name: panel.icon}"/>
{{ panel.name }}
</a>
</li>
</ul></li>

</ul>

Expand Down Expand Up @@ -130,7 +125,7 @@ export default {
<style>

.livedata-dropdown-menu {
// Similar to .flat-buttons()
/* Similar to .flat-buttons() */
.btn-default {
background-color: @breadcrumb-bg;
background-image: none;
Expand All @@ -143,6 +138,12 @@ export default {
.btn-default:hover, .btn-default:active, .btn-default:focus, .open .dropdown-toggle {
border-color: darken(@dropdown-divider-bg, 10%);
}

/* Style each section of the dropdown */
ul.dropdown-menu > li > ul {
list-style: none;
padding-left: 0;
}
}

.livedata-dropdown-menu .btn-default span {
Expand Down