Skip to content

Commit

Permalink
feat(data-page): add expandable with additional information
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Nov 16, 2023
1 parent 790e56c commit 5bb2071
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/@ourworldindata/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export {
sumTextWrapHeights,
} from "./MarkdownTextWrap/MarkdownTextWrap.js"

export { SimpleMarkdownText } from "./SimpleMarkdownText.js"
export {
SimpleMarkdownText,
HtmlOrSimpleMarkdownText,
} from "./SimpleMarkdownText.js"
export {
getLinkType,
getUrlTarget,
Expand Down
2 changes: 1 addition & 1 deletion site/DataPageContent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
}
}

.key-info__learn-more + .key-info__description-from-producer {
.key-info__key-description + .key-info__expandable-descriptions {
margin-top: 24px;
}

Expand Down
35 changes: 28 additions & 7 deletions site/DataPageV2Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
makeUnit,
makeUnitConversionFactor,
makeLinks,
HtmlOrSimpleMarkdownText,
} from "@ourworldindata/components"
import ReactDOM from "react-dom"
import { GrapherWithFallback } from "./GrapherWithFallback.js"
Expand Down Expand Up @@ -260,7 +261,8 @@ export const DataPageV2Content = ({
/>
<div className="wrapper grid grid-cols-12">
{hasDescriptionKey ||
datapageData.descriptionFromProducer ? (
datapageData.descriptionFromProducer ||
datapageData.source?.additionalInfo ? (
<>
<h2
id="about-this-data"
Expand All @@ -272,7 +274,7 @@ export const DataPageV2Content = ({
<div className="col-start-1 span-cols-8 span-lg-cols-7 span-sm-cols-12">
<div className="key-info__content">
{hasDescriptionKey && (
<>
<div className="key-info__key-description">
{datapageData.descriptionKey
.length === 1 ? (
<SimpleMarkdownText
Expand Down Expand Up @@ -309,10 +311,11 @@ export const DataPageV2Content = ({
/>
</a>
)}
</>
</div>
)}
{datapageData.descriptionFromProducer && (
<div className="key-info__description-from-producer">

<div className="key-info__expandable-descriptions">
{datapageData.descriptionFromProducer && (
<ExpandableToggle
label={
datapageData.attributionShort
Expand All @@ -328,9 +331,27 @@ export const DataPageV2Content = ({
/>
</div>
}
isStacked={
!!datapageData
.source
?.additionalInfo
}
/>
</div>
)}
)}
{datapageData.source
?.additionalInfo && (
<ExpandableToggle
label="Additional information about this data"
content={
<div className="expandable-info-blocks__content">
<HtmlOrSimpleMarkdownText
text={datapageData.source?.additionalInfo.trim()}
/>
</div>
}
/>
)}
</div>
</div>
</div>
<div className="key-info__right span-cols-4 span-lg-cols-5 span-sm-cols-12">
Expand Down

0 comments on commit 5bb2071

Please sign in to comment.