Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data page: About this data (& refactor shared components) #2853

Merged
merged 32 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d25d1f3
refactor(datapage): extract component-specific css
sophiamersmann Oct 25, 2023
85d63a2
feat(datapage): adapt design of the About this data section
sophiamersmann Oct 25, 2023
0255ab3
fix(datapage): prevent style leak
sophiamersmann Oct 25, 2023
4c20d49
fix(datapage): hide empty table cells
sophiamersmann Oct 26, 2023
837bbb4
refactpr(datapage): clean up IndicatorSources component
sophiamersmann Oct 26, 2023
ea2fe24
refactor(datapage): clean up IndicatorProcessing component
sophiamersmann Oct 26, 2023
d9b745e
refactor(datapage): remove article-specific css from shared components
sophiamersmann Oct 26, 2023
91b3a7b
fix: remove debug code
sophiamersmann Oct 26, 2023
c651a98
refactor(datapage): split IndicatorBrief into two components
sophiamersmann Oct 26, 2023
866c2fd
style(datapage): fix small visual glitches
sophiamersmann Oct 26, 2023
3dee2e3
refactor(datapage): move helper functions to utils
sophiamersmann Oct 27, 2023
a85a713
refactor: pass canonical url for datapage links
sophiamersmann Oct 27, 2023
894c0f1
style(datapage): update color of key description text
sophiamersmann Oct 27, 2023
715b22e
style(datapage): improve spacing
sophiamersmann Oct 27, 2023
9902dea
fix(datapage): hide key description if array is empty
sophiamersmann Oct 27, 2023
01dcb3f
enhance(datapage): deduplciate origins
sophiamersmann Oct 27, 2023
45dd5ae
enhance(datapage): show title of data product for a source
sophiamersmann Oct 27, 2023
e09b7da
refactor(datapage): rename IndicatorKeyDescription -> IndicatorDescri…
sophiamersmann Oct 27, 2023
67a90d5
enhance(datapage): deduplicate sources on label only
sophiamersmann Oct 27, 2023
37d1d8b
style(datapage) add icon; fix small visual glitches
sophiamersmann Oct 27, 2023
35f17a3
refactor: move phrase for procssing level into utils folder
sophiamersmann Oct 30, 2023
68561d2
chore: make eslint happy
sophiamersmann Oct 30, 2023
3f2fad1
refactor: use a type union for OwidProcessingLevel
sophiamersmann Oct 30, 2023
73efe52
chore: make eslint happy
sophiamersmann Oct 30, 2023
ddf4596
chore: run prettier
sophiamersmann Oct 30, 2023
c950652
enhance(data-page): improve key data on mobile
sophiamersmann Oct 31, 2023
b07193b
enhance(data-page): show dataPublishedBy instead of the source's name
sophiamersmann Oct 31, 2023
c5d6c2e
enhance(data-page): allow orphan cells in the key data block to take …
sophiamersmann Oct 31, 2023
e0dec57
style(data-page): remove padding of expandable toggle
sophiamersmann Nov 1, 2023
0f0bb52
style(data-page): remove extra space when source description is missing
sophiamersmann Nov 1, 2023
368c346
enhance(data-page): trim text fragments
sophiamersmann Nov 1, 2023
bc6a0b5
chore: remove duplicate functions
sophiamersmann Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions datapage/Datapage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
GdocsContentSource,
DataPageDataV2,
OwidVariableWithSource,
dayjs,
gdocIdRegex,
getETLPathComponents,
getAttributionFragmentsFromVariable,
getLastUpdatedFromVariable,
getNextUpdateFromVariable,
} from "@ourworldindata/utils"
import { ExplorerProgram } from "../explorer/ExplorerProgram.js"
import { Gdoc } from "../db/model/Gdoc/Gdoc.js"
Expand All @@ -20,21 +20,8 @@ export const getDatapageDataV2 = async (
): Promise<DataPageDataV2> => {
{
const processingLevel = variableMetadata.processingLevel ?? "minor"
const version =
getETLPathComponents(variableMetadata.catalogPath ?? "")?.version ??
""
let nextUpdate = undefined
if (variableMetadata.updatePeriodDays) {
const date = dayjs(version)
const nextUpdateDate = date.add(
variableMetadata.updatePeriodDays,
"day"
)
// If the next update date is in the past, we set it to the next month
if (nextUpdateDate.isBefore(dayjs()))
nextUpdate = dayjs().add(1, "month").format("MMMM YYYY")
else nextUpdate = nextUpdateDate.format("MMMM YYYY")
}
const lastUpdated = getLastUpdatedFromVariable(variableMetadata) ?? ""
const nextUpdate = getNextUpdateFromVariable(variableMetadata)
const datapageJson: DataPageDataV2 = {
status: "draft",
title:
Expand All @@ -54,14 +41,15 @@ export const getDatapageDataV2 = async (
descriptionProcessing: variableMetadata.descriptionProcessing,
owidProcessingLevel: processingLevel,
dateRange: variableMetadata.timespan ?? "",
lastUpdated: version,
lastUpdated: lastUpdated,
nextUpdate: nextUpdate,
relatedData: [],
allCharts: [],
relatedResearch: [],
source: variableMetadata.source,
origins: variableMetadata.origins ?? [],
chartConfig: partialGrapherConfig as Record<string, unknown>,
unit: variableMetadata.display?.unit ?? variableMetadata.unit,
}
return datapageJson
}
Expand Down
3 changes: 2 additions & 1 deletion db/model/Variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
OwidVariableId,
retryPromise,
OwidLicense,
OwidProcessingLevel,
} from "@ourworldindata/utils"
import {
GrapherInterface,
Expand Down Expand Up @@ -41,7 +42,7 @@ export interface VariableRow {
catalogPath?: string
dimensions?: Dimensions
schemaVersion?: number
processingLevel?: "minor" | "major"
processingLevel?: OwidProcessingLevel
titlePublic?: string
titleVariant?: string
attributionShort?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.ExpandableToggle {
border-top: 1px solid #d0dae3;
border-bottom: 1px solid #d0dae3;
padding: 0 8px;
}

.ExpandableToggle--stacked {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.indicator-key-description {
.key-info {
background-color: $gray-10;
border-left: 4px solid $blue-10;
padding: 40px;
margin: 0 -40px;

&__title {
@include h5-black-caps;
color: $blue-50;
margin-top: 0;
margin-bottom: 16px;
}

&__content {
@include body-2-regular;
ul {
@include body-2-regular;
margin-left: 16px;

li {
margin-bottom: 1em;

&:last-child {
margin-bottom: 0;
}
}
}
}

&__learn-more {
@include expandable-paragraph__expand-button--full;
margin-top: 24px;
svg {
font-size: 0.75em;
margin-left: 12px;
}
}
}

.expandable-info-blocks {
margin-top: 32px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from "react"
import { faArrowDown } from "@fortawesome/free-solid-svg-icons/faArrowDown"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { ExpandableToggle } from "../ExpandableToggle/ExpandableToggle.js"
import { SimpleMarkdownText } from "../SimpleMarkdownText.js"

interface IndicatorDescriptionsProps {
descriptionShort?: string
descriptionKey?: string[]
descriptionFromProducer?: string
attributionShort?: string
additionalInfo?: string
canonicalUrl?: string
hasFaqEntries: boolean
}

export const IndicatorDescriptions = (props: IndicatorDescriptionsProps) => {
return (
<div className="indicator-key-description">
{props.descriptionKey && props.descriptionKey.length > 0 && (
<div className="key-info">
<h3 className="key-info__title">
What you should know about this data
</h3>
<div className="key-info__content simple-markdown-text">
{props.descriptionKey.length === 1 ? (
<SimpleMarkdownText
text={props.descriptionKey[0].trim()}
/>
) : (
<ul>
{props.descriptionKey.map((text, i) => (
<li key={i}>
<SimpleMarkdownText
text={text.trim()}
/>{" "}
</li>
))}
</ul>
)}
</div>
{props.hasFaqEntries && (
<a
className="key-info__learn-more"
href={(props.canonicalUrl ?? "") + "#faqs"}
>
Learn more in the FAQs
<FontAwesomeIcon icon={faArrowDown} />
</a>
)}
</div>
)}
<div className="expandable-info-blocks">
{props.descriptionFromProducer && (
<ExpandableToggle
label={
props.attributionShort
? `How does the producer of this data - ${props.attributionShort} - describe this data?`
: "How does the producer of this data describe this data?"
}
content={
<div className="simple-markdown-text">
<SimpleMarkdownText
text={props.descriptionFromProducer.trim()}
/>
</div>
}
isExpandedDefault={
!(props.descriptionShort || props.descriptionKey)
}
isStacked={!!props.additionalInfo}
/>
)}
{props.additionalInfo && (
<ExpandableToggle
label="Additional information about this data"
content={
<div className="simple-markdown-text">
<SimpleMarkdownText
text={props.additionalInfo.trim()}
/>
</div>
}
/>
)}
</div>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.indicator-key-data {
@include body-3-medium;

border-top: 1px solid $blue-20;
border-bottom: 1px solid $blue-20;

display: grid;
grid-template-columns: repeat(2, 1fr);

.indicator-key-data-item {
display: flex;
padding: 16px 24px 16px 0;

@include sm-only {
display: block;
}

+ .indicator-key-data-item {
border-top: 1px solid $blue-20;
}

&__title {
flex: 0 0 140px; // using a fixed width here to make sure the content is aligned
margin-right: 24px;
color: $blue-50;

@include sm-only {
margin-right: 0;
}
}

&--span {
grid-column: 1 / -1;
}
}

a {
@include owid-link-90;
color: inherit;
}
}
Loading