Skip to content

Commit 79c2fdd

Browse files
authored
Merge pull request #2514 from tf/logo-list-size-speed
Logo list size and speed
2 parents 2f4f817 + a2a638e commit 79c2fdd

16 files changed

Lines changed: 391 additions & 9 deletions

File tree

‎entry_types/scrolled/config/locales/de.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ de:
781781
general: Video
782782
logoList:
783783
attributes:
784+
logoHeight:
785+
label: Logo-Höhe
786+
marqueeSpeed:
787+
label: Geschwindigkeit
784788
marquee:
785789
label: Endlos scrollen
786790
inline_help: |-
@@ -1569,6 +1573,12 @@ de:
15691573
md: M
15701574
lg: L
15711575
xl: XL
1576+
logoListLogoHeight:
1577+
xs: XS
1578+
sm: S
1579+
md: M
1580+
lg: L
1581+
xl: XL
15721582
content_element_text_inline_file_rights_attributes:
15731583
showTextInlineFileRightsBackdrop:
15741584
label: "Abblendung hinter Rechteangabe"

‎entry_types/scrolled/config/locales/en.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ en:
766766
general: Video
767767
logoList:
768768
attributes:
769+
logoHeight:
770+
label: Logo height
771+
marqueeSpeed:
772+
label: Speed
769773
marquee:
770774
label: Scroll continuously
771775
inline_help: |-
@@ -1551,6 +1555,12 @@ en:
15511555
md: M
15521556
lg: L
15531557
xl: XL
1558+
logoListLogoHeight:
1559+
xs: XS
1560+
sm: S
1561+
md: M
1562+
lg: L
1563+
xl: XL
15541564
content_element_text_inline_file_rights_attributes:
15551565
showTextInlineFileRightsBackdrop:
15561566
label: "Backdrop behind inline file rights"

‎entry_types/scrolled/lib/pageflow_scrolled/plugin.rb‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,32 @@ def configure(config)
7272
)
7373
)
7474

75+
c.themes.register_options_transform(
76+
ThemeOptionsDefaultScale.new(
77+
prefix: 'logo_list_logo_height',
78+
values: {
79+
'xs' => '2rem',
80+
'sm' => '2.5rem',
81+
'md' => '3rem',
82+
'lg' => '4rem',
83+
'xl' => '5rem'
84+
}
85+
)
86+
)
87+
88+
c.themes.register_options_transform(
89+
ThemeOptionsDefaultScale.new(
90+
prefix: 'logo_list_marquee_speed',
91+
values: {
92+
'xs' => '0.5',
93+
'sm' => '0.75',
94+
'md' => '1',
95+
'lg' => '1.5',
96+
'xl' => '2'
97+
}
98+
)
99+
)
100+
75101
c.themes.register_default_options(
76102
properties: {
77103
root: {
@@ -81,6 +107,8 @@ def configure(config)
81107
'content_element_box_shadow_style_default' =>
82108
'0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15)',
83109
'box_shadow_clip_margin_bottom' => '3rem',
110+
'logo_list_logo_height' => '3rem',
111+
'logo_list_marquee_speed' => '1',
84112
'outline_color' => '#a0a0a080'
85113
},
86114
cards_appearance_section: {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
3+
import {LogoList} from 'contentElements/logoList/LogoList';
4+
5+
import {renderInContentElement} from 'pageflow-scrolled/testHelpers';
6+
import '@testing-library/jest-dom/extend-expect'
7+
8+
describe('LogoList logo height', () => {
9+
const seed = {
10+
imageFileUrlTemplates: {medium: ':id_partition/medium/image.webp'},
11+
imageFiles: [{id: 1, permaId: 100}]
12+
};
13+
14+
const items = [{id: 1, image: 100}];
15+
16+
function renderLogoList(configuration) {
17+
const result = renderInContentElement(
18+
<LogoList configuration={configuration} contentElementId={1} />,
19+
{seed}
20+
);
21+
22+
result.simulateScrollPosition('near viewport');
23+
24+
return result;
25+
}
26+
27+
it('uses theme scale property for logo height', () => {
28+
const {container} = renderLogoList({items, logoHeight: 'lg'});
29+
30+
expect(container.querySelector('ul'))
31+
.toHaveStyle('--logo-height: var(--theme-logo-list-logo-height-lg)');
32+
});
33+
34+
it('does not set logo height by default', () => {
35+
const {container} = renderLogoList({items});
36+
37+
expect(container.querySelector('ul').style.getPropertyValue('--logo-height'))
38+
.toBe('');
39+
});
40+
});

‎entry_types/scrolled/package/spec/contentElements/logoList/LogoList/features/marquee-spec.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ describe('LogoList marquee', () => {
4949
.toHaveStyle('--logo-count: 2');
5050
});
5151

52+
it('uses theme scale property for marquee speed', () => {
53+
const {container} = renderLogoList({items, marquee: true, marqueeSpeed: 'xl'});
54+
55+
expect(container.querySelector(`.${styles.marquee}`))
56+
.toHaveStyle('--marquee-speed: var(--theme-logo-list-marquee-speed-xl)');
57+
});
58+
59+
it('does not set marquee speed by default', () => {
60+
const {container} = renderLogoList({items, marquee: true});
61+
62+
expect(container.querySelector(`.${styles.marquee}`)
63+
.style.getPropertyValue('--marquee-speed')).toBe('');
64+
});
65+
5266
it('scrolls focused logo into view', () => {
5367
const {container} = renderLogoList({
5468
items,
@@ -98,6 +112,25 @@ describe('LogoList marquee', () => {
98112
expect(marquee.scrollLeft).toBe(100);
99113
});
100114

115+
it('renders marquee while selected in editor during preview', () => {
116+
const {container, triggerEditorCommand} =
117+
renderLogoList({items, marquee: true}, {inlineEditing: {isSelected: true}});
118+
119+
triggerEditorCommand({type: 'START_MARQUEE_PREVIEW'});
120+
121+
expect(container.querySelector(`.${styles.marquee}`)).not.toBeNull();
122+
});
123+
124+
it('renders static list again when preview stops', () => {
125+
const {container, triggerEditorCommand} =
126+
renderLogoList({items, marquee: true}, {inlineEditing: {isSelected: true}});
127+
128+
triggerEditorCommand({type: 'START_MARQUEE_PREVIEW'});
129+
triggerEditorCommand({type: 'STOP_MARQUEE_PREVIEW'});
130+
131+
expect(container.querySelector(`.${styles.marquee}`)).toBeNull();
132+
});
133+
101134
it('renders static list while selected in editor', () => {
102135
const {container} = renderLogoList({items, marquee: true},
103136
{inlineEditing: {isSelected: true}});
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import 'contentElements/logoList/editor';
2+
3+
import {SliderInput} from 'pageflow/testHelpers';
4+
import {renderContentElementConfigurationEditor, useEditorGlobals} from 'support';
5+
6+
describe('logoList configuration editor', () => {
7+
const {createEntry} = useEditorGlobals();
8+
9+
const marqueeSpeedScale = {
10+
'logoListMarqueeSpeed-sm': '0.75',
11+
'logoListMarqueeSpeed-md': '1'
12+
};
13+
14+
function render({configuration = {}, themeProperties = {}, themeTranslations} = {}) {
15+
const entry = createEntry({
16+
themeOptions: {properties: {root: themeProperties}},
17+
themeTranslations,
18+
contentElements: [{id: 1, typeName: 'logoList', configuration}]
19+
});
20+
const contentElement = entry.contentElements.get(1);
21+
const postCommand = jest.fn();
22+
contentElement.on('postCommand', postCommand);
23+
24+
const configurationEditor = renderContentElementConfigurationEditor({
25+
entry,
26+
contentElement
27+
});
28+
29+
return {configurationEditor, postCommand};
30+
}
31+
32+
it('displays logo height input if theme defines scale', () => {
33+
const {configurationEditor} = render({
34+
themeProperties: {'logoListLogoHeight-sm': '2rem', 'logoListLogoHeight-md': '3rem'}
35+
});
36+
37+
expect(configurationEditor.inputPropertyNames()).toContain('logoHeight');
38+
});
39+
40+
it('hides logo height input if theme does not define scale', () => {
41+
const {configurationEditor} = render();
42+
43+
expect(configurationEditor.inputPropertyNames()).not.toContain('logoHeight');
44+
});
45+
46+
it('displays marquee speed input if marquee is enabled', () => {
47+
const {configurationEditor} = render({
48+
configuration: {marquee: true},
49+
themeProperties: marqueeSpeedScale
50+
});
51+
52+
expect(configurationEditor.visibleInputPropertyNames()).toContain('marqueeSpeed');
53+
});
54+
55+
it('hides marquee speed input if marquee is disabled', () => {
56+
const {configurationEditor} = render({themeProperties: marqueeSpeedScale});
57+
58+
expect(configurationEditor.visibleInputPropertyNames()).not.toContain('marqueeSpeed');
59+
});
60+
61+
it('labels marquee speed steps with multipliers', () => {
62+
const {configurationEditor} = render({
63+
configuration: {marquee: true, marqueeSpeed: 'lg'},
64+
themeProperties: {...marqueeSpeedScale, 'logoListMarqueeSpeed-lg': '1.5'}
65+
});
66+
67+
expect(SliderInput.findByPropertyName('marqueeSpeed', {inView: configurationEditor})
68+
.displayedValue()).toEqual('1.5×');
69+
});
70+
71+
it('prefers translated marquee speed labels', () => {
72+
const {configurationEditor} = render({
73+
configuration: {marquee: true, marqueeSpeed: 'md'},
74+
themeProperties: marqueeSpeedScale,
75+
themeTranslations: {scales: {logoListMarqueeSpeed: {md: 'Normal'}}}
76+
});
77+
78+
expect(SliderInput.findByPropertyName('marqueeSpeed', {inView: configurationEditor})
79+
.displayedValue()).toEqual('Normal');
80+
});
81+
82+
it('hides marquee speed input if theme does not define scale', () => {
83+
const {configurationEditor} = render({configuration: {marquee: true}});
84+
85+
expect(configurationEditor.inputPropertyNames()).not.toContain('marqueeSpeed');
86+
});
87+
88+
it('starts marquee preview when sliding speed slider', () => {
89+
const {configurationEditor, postCommand} = render({
90+
configuration: {marquee: true},
91+
themeProperties: marqueeSpeedScale
92+
});
93+
94+
SliderInput.findByPropertyName('marqueeSpeed', {inView: configurationEditor})
95+
.startSliding();
96+
97+
expect(postCommand).toHaveBeenCalledWith(1, {type: 'START_MARQUEE_PREVIEW'});
98+
});
99+
100+
it('stops marquee preview when releasing speed slider', () => {
101+
const {configurationEditor, postCommand} = render({
102+
configuration: {marquee: true},
103+
themeProperties: marqueeSpeedScale
104+
});
105+
106+
SliderInput.findByPropertyName('marqueeSpeed', {inView: configurationEditor})
107+
.stopSliding();
108+
109+
expect(postCommand).toHaveBeenCalledWith(1, {type: 'STOP_MARQUEE_PREVIEW'});
110+
});
111+
});

‎entry_types/scrolled/package/spec/editor/models/ScrolledEntry/getScale-spec.js‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ describe('ScrolledEntry', () => {
5353
expect(scale.texts).toEqual(['Small', 'Medium', 'Large']);
5454
});
5555

56+
it('returns css values of scale steps', () => {
57+
const entry = factories.entry(
58+
ScrolledEntry,
59+
{},
60+
{
61+
entryTypeSeed: normalizeSeed({
62+
themeOptions: {
63+
properties: {
64+
root: {
65+
'contentElementMargin-sm': '0.5rem',
66+
'contentElementMargin-md': '1rem'
67+
}
68+
}
69+
}
70+
})
71+
}
72+
);
73+
74+
const scale = entry.getScale('contentElementMargin');
75+
76+
expect(scale.cssValues).toEqual(['0.5rem', '1rem']);
77+
});
78+
5679
describe('defaultValue', () => {
5780
it('is undefined when no default is set', () => {
5881
const entry = factories.entry(
@@ -205,6 +228,32 @@ describe('ScrolledEntry', () => {
205228

206229
expect(scale.defaultValue).toBeUndefined();
207230
});
231+
232+
it('supports passing default property name', () => {
233+
const entry = factories.entry(
234+
ScrolledEntry,
235+
{},
236+
{
237+
entryTypeSeed: normalizeSeed({
238+
themeOptions: {
239+
properties: {
240+
root: {
241+
'someScale-sm': '2rem',
242+
'someScale-md': '3rem',
243+
'someScaleDefault': '3rem'
244+
}
245+
}
246+
}
247+
})
248+
}
249+
);
250+
251+
const scale = entry.getScale('someScale', {
252+
defaultValuePropertyName: 'someScaleDefault'
253+
});
254+
255+
expect(scale.defaultValue).toEqual('md');
256+
});
208257
});
209258
});
210259
});

0 commit comments

Comments
 (0)