Skip to content

Commit e35e3b6

Browse files
committed
Add remaining vertical space option for sections
Allow positioning content at top, bottom, or centered when section content does not fill the full viewport height. Only available when "Use Full Viewport-Height" is enabled. REDMINE-21191
1 parent 00256b6 commit e35e3b6

File tree

7 files changed

+101
-2
lines changed

7 files changed

+101
-2
lines changed

entry_types/scrolled/config/locales/de.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,14 @@ de:
13831383
label: Abstand oben (Hochkant)
13841384
portraitPaddingBottom:
13851385
label: Abstand unten (Hochkant)
1386+
remainingVerticalSpace:
1387+
label: Verbleibender vertikaler Raum
1388+
inline_help: Bestimmt, wo der Inhalt positioniert wird, wenn er nicht die gesamte Höhe des Abschnitts ausfüllt.
1389+
inline_help_disabled: Nur verfügbar, wenn "Volle Viewport-Höhe" in den Abschnittseinstellungen aktiviert ist.
1390+
values:
1391+
around: Um den Inhalt
1392+
above: Über dem Inhalt
1393+
below: Unter dem Inhalt
13861394
typography_sizes:
13871395
xl: Sehr groß
13881396
lg: Groß

entry_types/scrolled/config/locales/en.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,14 @@ en:
13661366
label: Top padding (Portrait)
13671367
portraitPaddingBottom:
13681368
label: Bottom padding (Portrait)
1369+
remainingVerticalSpace:
1370+
label: Remaining vertical space
1371+
inline_help: Controls where content is positioned when it does not fill the full height of the section.
1372+
inline_help_disabled: Only available when "Use Full Viewport-Height" is enabled in section settings.
1373+
values:
1374+
around: Around content
1375+
above: Above content
1376+
below: Below content
13691377
typography_sizes:
13701378
xl: Very large
13711379
lg: Large

entry_types/scrolled/package/spec/frontend/features/sectionPadding-spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,51 @@ describe('section padding', () => {
129129
'--foreground-padding-bottom': 'var(--theme-section-padding-bottom-md)',
130130
});
131131
});
132+
133+
it('centers content vertically by default', () => {
134+
const {getSectionByPermaId} = renderEntry({
135+
seed: {
136+
sections: [{id: 5, permaId: 6}],
137+
contentElements: [{sectionId: 5}]
138+
}
139+
});
140+
141+
const section = getSectionByPermaId(6);
142+
expect(section.hasRemainingSpaceAbove()).toBe(false);
143+
expect(section.hasRemainingSpaceBelow()).toBe(false);
144+
});
145+
146+
it('supports remaining vertical space above content', () => {
147+
const {getSectionByPermaId} = renderEntry({
148+
seed: {
149+
sections: [{
150+
id: 5,
151+
permaId: 6,
152+
configuration: {remainingVerticalSpace: 'above'}
153+
}],
154+
contentElements: [{sectionId: 5}]
155+
}
156+
});
157+
158+
const section = getSectionByPermaId(6);
159+
expect(section.hasRemainingSpaceAbove()).toBe(true);
160+
expect(section.hasRemainingSpaceBelow()).toBe(false);
161+
});
162+
163+
it('supports remaining vertical space below content', () => {
164+
const {getSectionByPermaId} = renderEntry({
165+
seed: {
166+
sections: [{
167+
id: 5,
168+
permaId: 6,
169+
configuration: {remainingVerticalSpace: 'below'}
170+
}],
171+
contentElements: [{sectionId: 5}]
172+
}
173+
});
174+
175+
const section = getSectionByPermaId(6);
176+
expect(section.hasRemainingSpaceAbove()).toBe(false);
177+
expect(section.hasRemainingSpaceBelow()).toBe(true);
178+
});
132179
});

entry_types/scrolled/package/spec/support/pageObjects.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ function createSectionPageObject(el) {
200200
return foreground.classList.contains(foregroundStyles.paddingBottom);
201201
},
202202

203+
hasRemainingSpaceAbove() {
204+
return foreground.classList.contains(foregroundStyles.spaceAbove);
205+
},
206+
207+
hasRemainingSpaceBelow() {
208+
return foreground.classList.contains(foregroundStyles.spaceBelow);
209+
},
210+
203211
hasFadedOutForeground() {
204212
return foreground.classList.contains(sharedTransitionStyles.fadedOut);
205213
},

entry_types/scrolled/package/src/editor/views/EditSectionPaddingsView.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import I18n from 'i18n-js';
22

33
import {EditConfigurationView, SeparatorView} from 'pageflow/editor';
4-
import {SliderInputView, RadioButtonGroupInputView, CheckBoxInputView} from 'pageflow/ui';
4+
import {SliderInputView, RadioButtonGroupInputView, CheckBoxInputView, SelectInputView} from 'pageflow/ui';
55

66
import {SectionPaddingVisualizationView} from './inputs/SectionPaddingVisualizationView';
77
import {EditMotifAreaInputView} from './inputs/EditMotifAreaInputView';
@@ -189,6 +189,16 @@ function paddingInputs(tab, options) {
189189
onInteractionStart: scrollToSectionEnd,
190190
...disabledOptions
191191
});
192+
193+
tab.view(SeparatorView);
194+
195+
tab.input('remainingVerticalSpace', SelectInputView, {
196+
values: ['around', 'above', 'below'],
197+
defaultValue: 'around',
198+
disabledBinding: 'fullHeight',
199+
disabled: fullHeight => !fullHeight,
200+
...disabledOptions
201+
});
192202
}
193203

194204
const motifAreaBinding = ['backdropType'];

entry_types/scrolled/package/src/frontend/Foreground.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ function className(props, forcePadding) {
2424
props.transitionStyles.foreground,
2525
props.transitionStyles[`foreground-${props.state}`],
2626
{[styles.paddingBottom]: props.paddingBottom || forcePadding},
27-
styles[`${props.heightMode}Height`]
27+
styles[`${props.heightMode}Height`],
28+
styles[spaceClassName(props.section?.remainingVerticalSpace)]
2829
)
2930
}
31+
32+
function spaceClassName(remainingVerticalSpace) {
33+
if (remainingVerticalSpace === 'above') {
34+
return 'spaceAbove';
35+
}
36+
else if (remainingVerticalSpace === 'below') {
37+
return 'spaceBelow';
38+
}
39+
}

entry_types/scrolled/package/src/frontend/Foreground.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
min-height: 100vh;
2222
}
2323

24+
.spaceAbove {
25+
justify-content: flex-end;
26+
}
27+
28+
.spaceBelow {
29+
justify-content: flex-start;
30+
}
31+
2432
.paddingBottom {
2533
padding-bottom: var(--foreground-padding-bottom, 3em);
2634
}

0 commit comments

Comments
 (0)