Skip to content

Commit

Permalink
💄 incorporate PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Dec 21, 2023
1 parent 02c3d08 commit ec5ae70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
6 changes: 1 addition & 5 deletions packages/@ourworldindata/core-table/src/CoreTableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,7 @@ export abstract class AbstractCoreColumn<JS_TYPE extends PrimitiveType> {
attributionShort: this.def.presentation?.attributionShort,
titleVariant: this.def.presentation?.titleVariant,
}
: { title: this.display?.name ?? this.name ?? "" }
}

@imemo get nonEmptyDisplayName(): string {
return this.display?.name || this.nonEmptyName
: { title: this.display?.name || this.name || "" }
}

@imemo get datasetId(): number | undefined {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ export class Grapher
// sort y-columns by their display name
const sortedYColumnSlugs = sortBy(
yColumnSlugs,
(slug) => this.inputTable.get(slug).nonEmptyDisplayName
(slug) => this.inputTable.get(slug).titlePublicOrDisplayName
)

const columnSlugs = excludeUndefined([
Expand Down
34 changes: 21 additions & 13 deletions packages/@ourworldindata/grapher/src/dataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,21 +549,29 @@ export class DataTable extends React.Component<{
@computed private get tableCaption(): JSX.Element | null {
if (this.hasDimensionHeaders) return null
const singleDimension = this.displayDimensions[0]
const titleFragments = (singleDimension.display.columnName
.attributionShort ||
singleDimension.display.columnName.titleVariant) && (
<>
<span className="title-fragments">
{joinTitleFragments(
singleDimension.display.columnName.attributionShort,
singleDimension.display.columnName.titleVariant
)}
</span>
</>
)
const separator =
(singleDimension.display.columnName.attributionShort ||
singleDimension.display.columnName.titleVariant) &&
singleDimension.display.unit
? " – "
: " "

return singleDimension ? (
<div className="caption">
{singleDimension.display.columnName.title}{" "}
{(singleDimension.display.columnName.attributionShort ||
singleDimension.display.columnName.titleVariant) && (
<>
<span className="title-fragments">
{joinTitleFragments(
singleDimension.display.columnName
.attributionShort,
singleDimension.display.columnName.titleVariant
)}
</span>{" "}
</>
)}
{singleDimension.display.columnName.title} {titleFragments}
{separator}
{singleDimension.display.unit && (
<span className="unit">{singleDimension.display.unit}</span>
)}
Expand Down

0 comments on commit ec5ae70

Please sign in to comment.