Skip to content

Commit e0f5060

Browse files
committed
feat: stats seection suffix
1 parent ff3d809 commit e0f5060

6 files changed

Lines changed: 14160 additions & 10 deletions

File tree

src/blocks/StatsBlock.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export const StatsBlock: Block = {
8585
defaultValue: true,
8686
},
8787
{
88-
name: "showPlus",
89-
label: "Show plus",
90-
type: "checkbox",
91-
defaultValue: false,
88+
name: "suffix",
89+
label: "Suffix",
90+
type: "text",
91+
localized: true,
9292
},
9393
],
9494
},

src/components/sections/StatsSection.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ function getCompactNumber(number: number) {
2222
return { value: Math.round(number), suffix: "" }
2323
}
2424

25-
function StatNumber({ number, animate, showPlus }: { number: number; animate: boolean; showPlus: boolean }) {
25+
function StatNumber({ number, animate, suffix }: { number: number; animate: boolean; suffix?: string | null }) {
2626
const ref = useRef<HTMLDivElement>(null)
2727
const isInView = useInView(ref, { once: true, amount: 0.5 })
2828
const compactNumber = getCompactNumber(number)
29-
const suffix = `${compactNumber.suffix}${showPlus ? "+" : ""}`
29+
const displaySuffix = `${compactNumber.suffix}${suffix?.trim() ?? ""}`
3030

3131
return (
3232
<div ref={ref} className="text-5xl font-semibold tabular-nums text-white md:text-6xl">
3333
<NumberFlow
3434
value={animate && !isInView ? 0 : compactNumber.value}
35-
suffix={!animate || isInView ? suffix : ""}
35+
suffix={!animate || isInView ? displaySuffix : ""}
3636
animated={animate}
3737
transformTiming={{ duration: 1200, easing: "ease-out" }}
3838
/>
@@ -68,7 +68,7 @@ export function StatsSection({ content }: StatsSectionProps) {
6868
duration={0.4}
6969
key={item.id ?? index}
7070
>
71-
<StatNumber number={item.number} animate={item.enableNumberFlow !== false} showPlus={item.showPlus === true} />
71+
<StatNumber number={item.number} animate={item.enableNumberFlow !== false} suffix={item.suffix} />
7272
<p className="text-lg font-medium text-secondary">{item.description}</p>
7373
</StaggerItem>
7474
))}

0 commit comments

Comments
 (0)