Skip to content

Commit 3db912d

Browse files
Sereza7michitux
andauthored
XWIKI-23286: Panel toggles and handles inconsistencies (#4140)
* Changed the nature of the hint for panel toggles. * Added controls on the standalone edition sheet. * Made sure everything that worked with rightPanels also works with editPanels. * Fixed the unexpected side margins in mobile mode. * Prevented resetting preferences for panel width when passing by a page without panels. * Updated the comment to be clearer * Fixed codestyle --------- Co-authored-by: Michael Hamann <michael@content-space.de>
1 parent 8625fe4 commit 3db912d

File tree

3 files changed

+55
-21
lines changed
  • xwiki-platform-core
    • xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo
    • xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates

3 files changed

+55
-21
lines changed

xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/flamingo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,19 @@ require(['jquery', 'jquery-ui'], function($) {
190190
return valueIsSimilarToDefault(document.body.style.getPropertyValue('--panel-column-' + side + '-width'), side);
191191
};
192192
let updateLocalStorageValueForSide = function (side) {
193+
// If the panel is not here, do not take any action on local storage.
194+
// The user cannot act on or view the width preference, it should not be updated.
195+
if ($('#' + side + 'Panels').length === 0) return;
193196
// We only update the local storage when the last value is different enough from the default value.
194197
// This is important to keep this as long as we don't have a proper UI to reset the panel column size.
195198
// IMO it makes sense to keep it even when we eventually have this reset UI.
196199
if (!currentValueIsSimilarToDefault(side)) {
197200
localStorage.setItem(localStoragePrefix + side,
198201
document.body.style.getPropertyValue('--panel-column-' + side + '-width'));
199202
} else {
200-
// If the values are similar, we remove whatever was stored in the localStorage.
203+
// If the values are similar and the panel is actually here, we remove whatever was stored in the localStorage.
204+
// The panels are not in the DOM if: it's deactivated for everyone by admins or this page layout doesn't contain
205+
// panels.
201206
localStorage.removeItem(localStoragePrefix + side);
202207
}
203208
};

xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/less/layout.less

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636
& #leftPanels {
3737
order: 1;
3838
width: ~"var(--panel-column-left-width)";
39-
padding-right: ~"calc(var(--grid-gutter-width) / 2)";
4039
}
4140

42-
& #rightPanels, & #editPanels {
41+
& #rightPanels {
4342
order: 3;
4443
width: ~"var(--panel-column-right-width)";
45-
padding-left: ~"calc(var(--grid-gutter-width) / 2)";
4644
}
4745

4846
/* Depending on the admin parameters, we want to change the default size. */
@@ -62,10 +60,15 @@
6260
/* The functionality to hide the panel takes precedence over the panel size defaults.
6361
This ruleset should come after the rules for .panel-left-width-<WIDTH> */
6462
&.hideleft {
65-
-/**/-panel-column-left-width: 0;
66-
67-
& #leftPanels {
68-
display: none;
63+
/* When the screen is small enough, we keep panels shown.
64+
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
65+
ie. this media query does not short-circuit the admin preference. */
66+
@media (min-width: @screen-md-min) {
67+
-/**/-panel-column-left-width: 0;
68+
69+
& #leftPanels {
70+
display: none;
71+
}
6972
}
7073
}
7174

@@ -80,19 +83,29 @@
8083
/* The functionality to hide the panel takes precedence over the panel size defaults.
8184
This ruleset should come after the rules for .panel-right-width-<WIDTH> */
8285
&.hideright {
83-
-/**/-panel-column-right-width: 0;
84-
85-
& #rightPanels {
86-
display: none;
86+
/* When the screen is small enough, we keep panels shown.
87+
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
88+
ie. this media query does not short-circuit the admin preference. */
89+
@media (min-width: @screen-md-min) {
90+
-/**/-panel-column-right-width: 0;
91+
92+
& #rightPanels {
93+
display: none;
94+
}
8795
}
8896
}
8997

9098
&.hidelefthideright {
91-
-/**/-panel-column-left-width: 0;
92-
-/**/-panel-column-right-width: 0;
93-
94-
& #leftPanels, & #rightPanels {
95-
display: none;
99+
/* When the screen is small enough, we keep panels shown.
100+
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
101+
ie. this media query does not short-circuit the admin preference. */
102+
@media (min-width: @screen-md-min) {
103+
-/**/-panel-column-left-width: 0;
104+
-/**/-panel-column-right-width: 0;
105+
106+
& #leftPanels, & #rightPanels {
107+
display: none;
108+
}
96109
}
97110
}
98111

@@ -162,8 +175,7 @@
162175
resize: vertical;
163176
}
164177

165-
.main, #editcolumn,
166-
#leftPanels, #rightPanels, #editPanels {
178+
.main, #editcolumn, #leftPanels, #rightPanels {
167179
position: relative;
168180
padding-top: (@grid-gutter-width / 2);
169181
padding-bottom: (@grid-gutter-width / 2);
@@ -213,6 +225,15 @@ again or the page is reloaded (because the toggler is hidden until then). */
213225
#rightPanelsToggle:hover, #rightPanelsToggle:focus {
214226
opacity: 1;
215227
}
228+
229+
/* When the display is large enough, we add padding on the outer sides of the panel columns. */
230+
#leftPanels {
231+
padding-right: ~"calc(var(--grid-gutter-width) / 2)";
232+
}
233+
234+
#rightPanels {
235+
padding-left: ~"calc(var(--grid-gutter-width) / 2)";
236+
}
216237
}
217238

218239
body#body #rightPanelsToggle {

xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/editpanels.vm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@
3535
#set ($editorPanels = $editorPanelsHistory)
3636
#end
3737
#if ($!editorPanels != '')
38+
## Similar to the toggle defined in rightpanels.vm
39+
<button id="rightPanelsToggle" class="btn btn-default"
40+
title="$escapetool.xml($services.localization.render('panels.column.right.toggle.hint'))" type="button">
41+
$services.icon.renderHTML('caret-right')
42+
<span class="sr-only">$services.localization.render('panels.column.right.toggle.hint')</span>
43+
</button>
3844
#set ($editorPanels = $editorPanels.split(','))
39-
<div id="editPanels" class="panels editor">
45+
<div id="rightPanels" class="panels editor">
4046

4147
## Convert the list of panels to panel (UIExtension) IDs
4248
#set ($panelIDList = [])
@@ -57,7 +63,9 @@
5763
$services.rendering.render($panelUIExtension.execute(), "xhtml/1.0")
5864
#end
5965
#end
60-
66+
## Similar to the resize handle defined in rightpanels.vm
67+
<span role="button" tabindex="0" class="ui-resizable-handle ui-resizable-w"
68+
title="$escapetool.xml($services.localization.render('panels.column.right.resizeHandle.hint'))"></span>
6169
</div>
6270
#end
6371
#end

0 commit comments

Comments
 (0)