Skip to content

Commit 53e9f96

Browse files
authored
fix(DHIS2-19023): use react-markdown for rendering descriptions (#584)
* fix(DHIS2-19023): use react-markdown for rendering descriptions * fix: update styles for 'latest updates' to match AppHub
1 parent 99bae99 commit 53e9f96

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
import PropTypes from 'prop-types'
12
import React from 'react'
3+
import ReactMarkdown from 'react-markdown'
24
import styles from './Description.module.css'
35

46
export const Description = ({ description }) => {
5-
const lines = description.split('\n')
6-
return lines.map((line, index) => {
7-
if (!line.trim()) {
8-
return <br key={index} />
9-
}
10-
return (
11-
<p key={index} className={styles.paragraph}>
12-
{line}
13-
</p>
14-
)
15-
})
7+
return (
8+
<div className={styles.description}>
9+
<ReactMarkdown>{description}</ReactMarkdown>
10+
</div>
11+
)
12+
}
13+
14+
Description.propTypes = {
15+
description: PropTypes.string,
1616
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
.paragraph {
1+
.description {
22
margin-top: 0;
33
margin-bottom: var(--spacers-dp8);
4+
line-height: 1.4rem;
5+
font-size: 0.875em;
6+
}
7+
8+
.description :global(h1) {
9+
font-size: 1.1rem;
10+
}
11+
.description :global(h2),
12+
.description :global(h3),
13+
.description :global(h4) {
14+
font-size: 1rem;
415
}

src/components/AppDetails/LatestUpdates.module.css

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
.latestUpdates {
66
padding: var(--spacers-dp16);
7-
background-color: var(--colors-blue100);
7+
background-color: var(--colors-blue050);
8+
border-radius: 5px;
89
}
910

1011
.latestUpdatesHeader {
@@ -24,12 +25,13 @@
2425
.versionList {
2526
list-style: none;
2627
padding: 0;
27-
font-size: 0.8rem;
28+
font-size: 0.875rem;
2829
}
2930

3031
.latestUpdatesVersionHeading {
31-
font-size: 1.1em;
32-
font-weight: bold;
32+
font-size: 1rem;
33+
font-weight: 700;
34+
margin: 0;
3335
}
3436

3537
.changeSummary :global(ul) {
@@ -38,6 +40,9 @@
3840
}
3941

4042
.changeSummary :global(h3) {
41-
font-size: 0.9em;
42-
margin-bottom: 0.5em;
43+
font-size: 1em;
44+
margin: 0.5rem 0.25rem;
45+
}
46+
.versionList > li:not(:last-of-type) {
47+
margin-block-end: var(--spacers-dp24);
4348
}

0 commit comments

Comments
 (0)