Skip to content

Commit e4e2b11

Browse files
authored
Merge pull request #2214 from tf/justified-center-ragged-list
Fix indentation of justified lists in center ragged sections
2 parents 97cddcf + ef2cb40 commit e4e2b11

File tree

5 files changed

+79
-31
lines changed

5 files changed

+79
-31
lines changed

entry_types/scrolled/package/spec/frontend/EditableText-spec.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22

33
import {EditableText} from 'frontend';
44

5+
import styles from 'frontend/EditableText.module.css';
6+
57
import {render} from '@testing-library/react';
68
import {renderInEntry} from 'support';
79
import '@testing-library/jest-dom/extend-expect'
@@ -398,23 +400,7 @@ describe('EditableText', () => {
398400

399401
const {container} = render(<EditableText value={value} />);
400402

401-
expect(container.querySelector('p[style]')).toHaveStyle('text-align: justify;');
402-
});
403-
404-
it('can render both color and text align', () => {
405-
const value = [{
406-
type: 'paragraph',
407-
textAlign: 'justify',
408-
color: '#000',
409-
children: [
410-
{text: 'Some text'}
411-
]
412-
}];
413-
414-
const {container} = render(<EditableText value={value} />);
415-
416-
expect(container.querySelector('p[style]')).toHaveStyle('text-align: justify;');
417-
expect(container.querySelector('p[style]')).toHaveStyle('color: rgb(0, 0, 0);');
403+
expect(container.querySelector('p')).toHaveClass(styles.justify);
418404
});
419405

420406
it('uses body scaleCategory by default', () => {

entry_types/scrolled/package/src/contentElements/textBlock/TextBlock.module.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@
120120
text-align: center;
121121
}
122122

123-
.layout-centerRagged ol,
124-
.layout-centerRagged ul {
125-
padding-left: 0;
126-
list-style-position: inside;
123+
.layout-centerRagged {
124+
--editable-text-list-style-position: inside;
127125
}

entry_types/scrolled/package/src/contentElements/textBlock/stories.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,53 @@ storiesOfContentElement(module, {
153153
textAlign: 'justify',
154154
children: [
155155
{text: 'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'},
156+
{
157+
type: 'bulleted-list',
158+
children: [
159+
{
160+
type: 'list-item',
161+
children: [
162+
{text: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'}
163+
]
164+
}
165+
]
166+
}
167+
]
168+
}
169+
]
170+
}
171+
},
172+
{
173+
name: 'Text align justify - Center Ragged',
174+
sectionConfiguration: {
175+
layout: 'centerRagged'
176+
},
177+
configuration: {
178+
value: [
179+
{
180+
type: 'heading',
181+
textAlign: 'justify',
182+
children: [
183+
{text: 'Heading'}
184+
]
185+
},
186+
{
187+
type: 'paragraph',
188+
textAlign: 'justify',
189+
children: [
190+
{text: 'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'}
191+
]
192+
},
193+
{
194+
type: 'bulleted-list',
195+
textAlign: 'justify',
196+
children: [
197+
{
198+
type: 'list-item',
199+
children: [
200+
{text: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'}
201+
]
202+
}
156203
]
157204
}
158205
]

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,38 @@ export function renderElement({attributes, children, element}) {
5555
camelize(element.type),
5656
element.size].join('-');
5757

58-
const className = classNames(variantClassName, sizeClassName);
58+
const className = classNames(
59+
variantClassName,
60+
sizeClassName,
61+
{[styles.justify]: element.textAlign === 'justify'}
62+
);
5963

60-
const styles = {
61-
...(element.color && {color: paletteColor(element.color)}),
62-
...(element.textAlign && {textAlign: element.textAlign})
64+
const inlineStyles = {
65+
...(element.color && {color: paletteColor(element.color)})
6366
};
6467

6568
switch (element.type) {
6669
case 'block-quote':
6770
return (
6871
<blockquote {...attributes}
6972
className={className}
70-
style={styles}>
73+
style={inlineStyles}>
7174
{children}
7275
</blockquote>
7376
);
7477
case 'bulleted-list':
7578
return (
7679
<ul {...attributes}
7780
className={className}
78-
style={styles}>
81+
style={inlineStyles}>
7982
{children}
8083
</ul>
8184
);
8285
case 'numbered-list':
8386
return (
8487
<ol {...attributes}
8588
className={className}
86-
style={styles}>
89+
style={inlineStyles}>
8790
{children}
8891
</ol>
8992
);
@@ -96,7 +99,7 @@ export function renderElement({attributes, children, element}) {
9699
<Heading key={key}
97100
attributes={otherAttributes}
98101
className={className}
99-
styles={styles}>
102+
inlineStyles={inlineStyles}>
100103
{children}
101104
</Heading>
102105
);
@@ -106,14 +109,14 @@ export function renderElement({attributes, children, element}) {
106109
return (
107110
<p {...attributes}
108111
className={className}
109-
style={styles}>
112+
style={inlineStyles}>
110113
{children}
111114
</p>
112115
);
113116
}
114117
}
115118

116-
function Heading({attributes, className, styles: inlineStyles, children}) {
119+
function Heading({attributes, className, inlineStyles, children}) {
117120
const darkBackground = useDarkBackground();
118121

119122
return (

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
white-space: pre-line;
99
}
1010

11+
.root ul,
12+
.root ol {
13+
list-style-position: var(--editable-text-list-style-position);
14+
}
15+
16+
.justify {
17+
text-align: justify;
18+
}
19+
20+
ul.justify,
21+
ol.justify {
22+
list-style-position: outside;
23+
}
24+
1125
.light {
1226
color: lightContentTextColor;
1327
}

0 commit comments

Comments
 (0)