Skip to content

Commit

Permalink
✨ round homepage key-indicator-collection chart count down to nearest…
Browse files Browse the repository at this point in the history
… hundred
  • Loading branch information
ikesau committed Mar 29, 2024
1 parent fcfa522 commit ef97db3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/@ourworldindata/utils/src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1831,3 +1831,7 @@ export function cartesian<T>(matrix: T[][]): T[][] {
[[]]
)
}

export function roundDownToNearestHundred(value: number): number {
return Math.floor(value / 100) * 100
}
1 change: 1 addition & 0 deletions packages/@ourworldindata/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export {
checkIsDataInsight,
checkIsAuthor,
cartesian,
roundDownToNearestHundred,
} from "./Util.js"

export {
Expand Down
9 changes: 7 additions & 2 deletions site/gdocs/components/KeyIndicatorCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
EnrichedBlockKeyIndicator,
GrapherTabOption,
} from "@ourworldindata/types"
import { Url, urlToSlug } from "@ourworldindata/utils"
import {
Url,
urlToSlug,
roundDownToNearestHundred,
} from "@ourworldindata/utils"

import { useLinkedChart, useLinkedIndicator } from "../utils.js"
import KeyIndicator from "./KeyIndicator.js"
Expand Down Expand Up @@ -56,7 +60,8 @@ export default function KeyIndicatorCollection({
{homepageMetadata?.chartCount ? (
<p className="body-2-regular">
Featured data from our collection of more than{" "}
{homepageMetadata?.chartCount} interactive charts.
{roundDownToNearestHundred(homepageMetadata.chartCount)}{" "}
interactive charts.
</p>
) : (
<p className="body-2-regular">
Expand Down

0 comments on commit ef97db3

Please sign in to comment.