Skip to content

Commit 685126b

Browse files
authored
Merge pull request #2341 from tf/paddings
Improve edit section paddings view
2 parents d0e01f7 + 7b69050 commit 685126b

24 files changed

Lines changed: 2984 additions & 627 deletions

app/assets/stylesheets/pageflow/ui/properties.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
--ui-selection-color-lighter: hsla(197, 69%, 76%, 0.3);
2929
--ui-selection-color-lightest: hsla(197, 69%, 76%, 0.1);
3030

31+
--ui-warning-color: #ff7400;
32+
3133
--ui-error-color: #ff4d6d;
3234
--ui-error-color-light: hsla(349, 100%, 65%, 0.6);
3335
--ui-error-color-lighter: hsla(349, 100%, 65%, 0.3);

entry_types/scrolled/config/locales/de.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ de:
11501150
reset: Zurücksetzen
11511151
save: Speichern
11521152
edit_section:
1153+
motif_area_info_text: Markiere den wichtigsten Teil des Hintergrunds, der beim Erreichen des Abschnitts sichtbar und nicht von anderen Elementen überdeckt sein soll.
11531154
attributes:
11541155
appearance:
11551156
inline_help: Diese Einstellung legt fest wie die scrollenden Vordergrund-Ebene vom Hintergrund abgehoben werden soll. Bei der Einstellung "Karte" wird der Vordergrund mit einer Fläche mit abgerundeten Ecken hinterlegt, bei "Schatten" mit einem hellen oder dunklen Farbverlauf.
@@ -1286,6 +1287,8 @@ de:
12861287
side_by_side: "Darstellung des oberen Abstands, wenn der Inhalt neben dem Motivbereich Platz findet"
12871288
top_padding: "Darstellung des oberen Abstands"
12881289
bottom_padding: "Darstellung des unteren Abstands"
1290+
section_paddings_input:
1291+
motif: Motiv
12891292
select_link_destination:
12901293
cancel: Abbrechen
12911294
create: Erstellen
@@ -1305,6 +1308,9 @@ de:
13051308
edit_motif_area_input:
13061309
select: Motivbereich auswählen
13071310
edit: Motivbereich bearbeiten
1311+
warn: Noch kein Motivbereich ausgewählt
1312+
ignore_image: Für dieses Bild ignorieren
1313+
ignore_video: Für dieses Video ignorieren
13081314
backdrop_content_element_input:
13091315
add: Neues Element
13101316
unset: Nicht mehr als Hintergrund verwenden
@@ -1373,8 +1379,6 @@ de:
13731379
remove: "Stil entfernen"
13741380
crop_types:
13751381
circle: Kreis
1376-
section_paddings_input:
1377-
auto: (Automatisch)
13781382
edit_section_paddings:
13791383
tabs:
13801384
sectionPaddings: Innenabstände
@@ -1387,7 +1391,7 @@ de:
13871391
exposeMotifArea:
13881392
label: Abstand oben
13891393
values:
1390-
'true': Automatisch anpassen, um das Motiv im Hintergrund freizustellen
1394+
'true': Automatisch anpassen, um ein Motiv im Hintergrund freizustellen
13911395
'false': Manuell festlegen
13921396
sideBySideVisualization:
13931397
label: Nebeneinander
@@ -1692,7 +1696,6 @@ de:
16921696
add_caption: Beschriftung hinzufügen
16931697
add_content_element: Neues Element hinzufügen
16941698
cancel: Abbrechen
1695-
default_padding: Standard
16961699
drag_content_element: Ziehen, um Element zu verschieben
16971700
padding_suppressed_before_full_width: Abstand unterdrückt vor vollbreitem Element
16981701
padding_suppressed_after_full_width: Abstand unterdrückt nach vollbreitem Element

entry_types/scrolled/config/locales/en.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ en:
11341134
reset: Reset
11351135
save: Save
11361136
edit_section:
1137+
motif_area_info_text: Mark the most important part of the backdrop that should be visible and unobstructed when reaching the section.
11371138
attributes:
11381139
appearance:
11391140
inline_help: This setting controls how the scrolling foreground should get dimmed to increase contrast from the background. The option "Cards" adds a box with rounded corners to the foreground, with "Shadow" you can add a light or dark shadow to increase readability.
@@ -1270,6 +1271,8 @@ en:
12701271
side_by_side: "Visualization of top padding when content fits next to the motif area"
12711272
top_padding: "Visualization of top padding"
12721273
bottom_padding: "Visualization of bottom padding"
1274+
section_paddings_input:
1275+
motif: Motif
12731276
select_link_destination:
12741277
cancel: Cancel
12751278
create: Create
@@ -1289,6 +1292,9 @@ en:
12891292
edit_motif_area_input:
12901293
select: Select motif area
12911294
edit: Edit motif area
1295+
warn: No motif area selected
1296+
ignore_image: Ignore for this image
1297+
ignore_video: Ignore for this video
12921298
backdrop_content_element_input:
12931299
add: New element
12941300
unset: No longer use as backdrop
@@ -1357,8 +1363,6 @@ en:
13571363
remove: "Remove style"
13581364
crop_types:
13591365
circle: Circle
1360-
section_paddings_input:
1361-
auto: (Auto)
13621366
edit_section_paddings:
13631367
tabs:
13641368
sectionPaddings: Paddings
@@ -1522,7 +1526,6 @@ en:
15221526
add_caption: Add caption
15231527
add_content_element: Add new element
15241528
cancel: Cancel
1525-
default_padding: Default
15261529
drag_content_element: Drag to move element
15271530
padding_suppressed_before_full_width: Padding suppressed before full width element
15281531
padding_suppressed_after_full_width: Padding suppressed after full width element

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

Lines changed: 161 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {normalizeSeed} from 'support';
44

55
describe('ScrolledEntry', () => {
66
describe('#getScale', () => {
7-
it('returns empty arrays by default', () => {
7+
it('returns scale with empty values by default', () => {
88
const entry = factories.entry(
99
ScrolledEntry,
1010
{},
@@ -13,14 +13,13 @@ describe('ScrolledEntry', () => {
1313
}
1414
);
1515

16-
const [values, texts, cssValues] = entry.getScale('contentElementMargin');
16+
const scale = entry.getScale('contentElementMargin');
1717

18-
expect(values).toEqual([]);
19-
expect(texts).toEqual([]);
20-
expect(cssValues).toEqual([]);
18+
expect(scale.values).toEqual([]);
19+
expect(scale.texts).toEqual([]);
2120
});
2221

23-
it('returns values, texts, and cssValues based on theme custom properties', () => {
22+
it('returns scale with values and texts based on theme custom properties', () => {
2423
const entry = factories.entry(
2524
ScrolledEntry,
2625
{},
@@ -48,12 +47,164 @@ describe('ScrolledEntry', () => {
4847
}
4948
);
5049

51-
const [values, texts, cssValues] = entry.getScale('contentElementMargin');
50+
const scale = entry.getScale('contentElementMargin');
5251

53-
expect(values).toEqual(['sm', 'md', 'lg']);
54-
expect(texts).toEqual(['Small', 'Medium', 'Large']);
55-
expect(cssValues).toEqual(['0.5rem', '1rem', '1.5rem']);
52+
expect(scale.values).toEqual(['sm', 'md', 'lg']);
53+
expect(scale.texts).toEqual(['Small', 'Medium', 'Large']);
5654
});
5755

56+
describe('defaultValue', () => {
57+
it('is undefined when no default is set', () => {
58+
const entry = factories.entry(
59+
ScrolledEntry,
60+
{},
61+
{
62+
entryTypeSeed: normalizeSeed({
63+
themeOptions: {
64+
properties: {
65+
root: {
66+
'sectionPaddingTop-sm': '10vh',
67+
'sectionPaddingTop-md': '20vh',
68+
'sectionPaddingTop-lg': '30vh'
69+
}
70+
}
71+
}
72+
})
73+
}
74+
);
75+
76+
const scale = entry.getScale('sectionPaddingTop');
77+
78+
expect(scale.defaultValue).toBeUndefined();
79+
});
80+
81+
it('is undefined when scale has no mapped default property name', () => {
82+
const entry = factories.entry(
83+
ScrolledEntry,
84+
{},
85+
{
86+
entryTypeSeed: normalizeSeed({
87+
themeOptions: {
88+
properties: {
89+
root: {
90+
'contentElementMargin-sm': '0.5rem',
91+
'contentElementMargin-md': '1rem'
92+
}
93+
}
94+
}
95+
})
96+
}
97+
);
98+
99+
const scale = entry.getScale('contentElementMargin');
100+
101+
expect(scale.defaultValue).toBeUndefined();
102+
});
103+
104+
it('returns default value from root scope', () => {
105+
const entry = factories.entry(
106+
ScrolledEntry,
107+
{},
108+
{
109+
entryTypeSeed: normalizeSeed({
110+
themeOptions: {
111+
properties: {
112+
root: {
113+
'sectionPaddingTop-sm': '10vh',
114+
'sectionPaddingTop-md': '20vh',
115+
'sectionPaddingTop-lg': '30vh',
116+
'sectionDefaultPaddingTop': '20vh'
117+
}
118+
}
119+
}
120+
})
121+
}
122+
);
123+
124+
const scale = entry.getScale('sectionPaddingTop');
125+
126+
expect(scale.defaultValue).toEqual('md');
127+
});
128+
129+
it('returns default value from specific scope', () => {
130+
const entry = factories.entry(
131+
ScrolledEntry,
132+
{},
133+
{
134+
entryTypeSeed: normalizeSeed({
135+
themeOptions: {
136+
properties: {
137+
root: {
138+
'sectionPaddingTop-sm': '10vh',
139+
'sectionPaddingTop-md': '20vh',
140+
'sectionPaddingTop-lg': '30vh',
141+
'sectionDefaultPaddingTop': '20vh'
142+
},
143+
'section-cards': {
144+
'sectionDefaultPaddingTop': '30vh'
145+
}
146+
}
147+
}
148+
})
149+
}
150+
);
151+
152+
const scale = entry.getScale('sectionPaddingTop', {scope: 'section-cards'});
153+
154+
expect(scale.defaultValue).toEqual('lg');
155+
});
156+
157+
it('falls back to root scope when specific scope does not have property', () => {
158+
const entry = factories.entry(
159+
ScrolledEntry,
160+
{},
161+
{
162+
entryTypeSeed: normalizeSeed({
163+
themeOptions: {
164+
properties: {
165+
root: {
166+
'sectionPaddingTop-sm': '10vh',
167+
'sectionPaddingTop-md': '20vh',
168+
'sectionPaddingTop-lg': '30vh',
169+
'sectionDefaultPaddingTop': '20vh'
170+
},
171+
'section-cards': {
172+
'someOtherProperty': 'value'
173+
}
174+
}
175+
}
176+
})
177+
}
178+
);
179+
180+
const scale = entry.getScale('sectionPaddingTop', {scope: 'section-cards'});
181+
182+
expect(scale.defaultValue).toEqual('md');
183+
});
184+
185+
it('is undefined when default css value is not in scale', () => {
186+
const entry = factories.entry(
187+
ScrolledEntry,
188+
{},
189+
{
190+
entryTypeSeed: normalizeSeed({
191+
themeOptions: {
192+
properties: {
193+
root: {
194+
'sectionPaddingTop-sm': '10vh',
195+
'sectionPaddingTop-md': '20vh',
196+
'sectionDefaultPaddingTop': '15vh'
197+
}
198+
}
199+
}
200+
})
201+
}
202+
);
203+
204+
const scale = entry.getScale('sectionPaddingTop');
205+
206+
expect(scale.defaultValue).toBeUndefined();
207+
});
208+
});
58209
});
59210
});

0 commit comments

Comments
 (0)