Skip to content

Commit 03a4197

Browse files
committed
changed margins in preview and adjusted paragraph break for listing texts
1 parent 5a665a3 commit 03a4197

File tree

1 file changed

+56
-37
lines changed

1 file changed

+56
-37
lines changed

apps/internal-portal/frontend/src/pages/ListingTextContent/components/ListingPreview.tsx

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@ interface ListingPreviewProps {
1414
rentalObjectCode?: string
1515
}
1616

17+
const renderParagraphs = (
18+
content: string,
19+
baseSx: Record<string, unknown>,
20+
placeholder: string
21+
) => {
22+
if (!content) {
23+
return <Typography sx={baseSx}>{placeholder}</Typography>
24+
}
25+
26+
const paragraphs = content.split('\n')
27+
return (
28+
<>
29+
{paragraphs.map((paragraph, i) => (
30+
<Typography
31+
key={i}
32+
sx={{
33+
...baseSx,
34+
marginBottom: i < paragraphs.length - 1 ? '0.6em' : 0,
35+
}}
36+
>
37+
{paragraph || '\u00A0'}
38+
</Typography>
39+
))}
40+
</>
41+
)
42+
}
43+
1744
export const ListingPreview = ({
1845
blocks,
1946
rentalObjectCode,
@@ -22,23 +49,19 @@ export const ListingPreview = ({
2249
switch (block.type) {
2350
case 'preamble':
2451
return (
25-
<Typography
26-
key={index}
27-
variant="body1"
28-
paragraph
29-
sx={{
30-
width: '100%',
31-
fontSize: '1rem',
32-
fontFamily: 'graphikRegular',
33-
fontWeight: 700,
34-
marginBottom: 4,
35-
lineHeight: 1.6,
36-
whiteSpace: 'pre-line',
37-
'&:first-of-type': { paddingTop: 0 },
38-
}}
39-
>
40-
{block.content || 'Ingress...'}
41-
</Typography>
52+
<Box key={index} sx={{ marginBottom: 1 }}>
53+
{renderParagraphs(
54+
block.content,
55+
{
56+
width: '100%',
57+
fontSize: '1rem',
58+
fontFamily: 'graphikRegular',
59+
fontWeight: 700,
60+
lineHeight: 1.6,
61+
},
62+
'Ingress...'
63+
)}
64+
</Box>
4265
)
4366

4467
case 'headline':
@@ -54,7 +77,7 @@ export const ListingPreview = ({
5477
fontWeight: 700,
5578
textTransform: 'uppercase',
5679
color: '#00a4b3',
57-
marginBottom: 2,
80+
marginBottom: 0.5,
5881
whiteSpace: 'pre-line',
5982
}}
6083
>
@@ -74,7 +97,7 @@ export const ListingPreview = ({
7497
fontFamily: 'bisonBold',
7598
fontWeight: 700,
7699
textTransform: 'uppercase',
77-
marginBottom: 4,
100+
marginBottom: 0.5,
78101
whiteSpace: 'pre-line',
79102
}}
80103
>
@@ -84,22 +107,18 @@ export const ListingPreview = ({
84107

85108
case 'text':
86109
return (
87-
<Typography
88-
key={index}
89-
variant="body1"
90-
paragraph
91-
sx={{
92-
width: '100%',
93-
fontSize: '1rem',
94-
fontFamily: 'graphikRegular',
95-
marginBottom: 4,
96-
lineHeight: 1.7,
97-
whiteSpace: 'pre-line',
98-
'&:first-of-type': { paddingTop: 0 },
99-
}}
100-
>
101-
{block.content || 'Text...'}
102-
</Typography>
110+
<Box key={index} sx={{ marginBottom: 1 }}>
111+
{renderParagraphs(
112+
block.content,
113+
{
114+
width: '100%',
115+
fontSize: '1rem',
116+
fontFamily: 'graphikRegular',
117+
lineHeight: 1.7,
118+
},
119+
'Text...'
120+
)}
121+
</Box>
103122
)
104123

105124
case 'bullet_list':
@@ -115,7 +134,7 @@ export const ListingPreview = ({
115134
width: '100%',
116135
fontSize: '1rem',
117136
fontFamily: 'graphikRegular',
118-
marginBottom: 4,
137+
marginBottom: 1,
119138
paddingLeft: 3,
120139
'&:first-of-type': { paddingTop: 0 },
121140
}}
@@ -143,7 +162,7 @@ export const ListingPreview = ({
143162
width: '100%',
144163
fontSize: '1rem',
145164
fontFamily: 'graphikRegular',
146-
marginBottom: 4,
165+
marginBottom: 1,
147166
paddingLeft: 3,
148167
'&:first-of-type': { paddingTop: 0 },
149168
}}

0 commit comments

Comments
 (0)