Skip to content

Commit

Permalink
✨ deemphasise label text in parens
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 13, 2025
1 parent c533a28 commit 46f8024
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/@ourworldindata/grapher/src/axis/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,24 @@ abstract class AbstractAxis {
this.axisManager?.detailsOrderedByReference,
}

// extract text in parens at the end of the label
const [_m, labelText, labelTextInParens] =
this.label.trim().match(/^(.*?)(\([^()]*\))?$/) ?? []

const displayUnit = this.formatColumn?.displayUnit
if (displayUnit) {
if (displayUnit || labelTextInParens) {
const secondaryText = displayUnit
? `(${displayUnit})`
: labelTextInParens
return MarkdownTextWrap.fromFragments({
main: { text: this.label, bold: true },
secondary: { text: `(${displayUnit})` },
main: { text: labelText.trim(), bold: true },
secondary: { text: secondaryText },
newLine: "avoid-wrap",
textWrapProps,
})
} else {
return new MarkdownTextWrap({
text: this.label,
text: labelText.trim(),
fontWeight: 700,
...textWrapProps,
})
Expand Down

0 comments on commit 46f8024

Please sign in to comment.