escape html prolly added
This commit is contained in:
parent
6dd363fa4a
commit
d5ea4d06f4
3 changed files with 64 additions and 60 deletions
|
@ -19,9 +19,10 @@ const generateEmailContent = (data: Record<string, string>) => {
|
||||||
const stringData = Object.entries(data).reduce(
|
const stringData = Object.entries(data).reduce(
|
||||||
(str, [key, val]) =>
|
(str, [key, val]) =>
|
||||||
str +
|
str +
|
||||||
`${CONTACT_MESSAGE_FIELDS[key] || escapeHtml(key)}: \n${escapeHtml(
|
`${CONTACT_MESSAGE_FIELDS[key] || key}: ${val.replace(
|
||||||
val
|
/\n/g,
|
||||||
)} \n\n`,
|
"<br/>"
|
||||||
|
)} <br/><br/>`,
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import { stats } from "@/constants";
|
import { stats } from "@/constants";
|
||||||
import NumTicker from "../widgets/num-tick";
|
import NumberTicker from "../widgets/num-tick";
|
||||||
|
|
||||||
const Statistics = () => {
|
const Statistics = () => {
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-8">
|
<div className="grid grid-cols-2 lg:grid-cols-4 gap-8">
|
||||||
{stats.map(({ title, count }) => (
|
{stats.map(({ title, count }) => (
|
||||||
<div key={title} className="space-y-2 text-center">
|
<div key={title} className="space-y-2 text-center">
|
||||||
<h2 className="text-3xl sm:text-4xl font-bold">
|
<h2 className="text-3xl sm:text-4xl font-bold">
|
||||||
{count}
|
<NumberTicker value={count} />
|
||||||
{/* <NumTicker value={count} /> */}
|
</h2>
|
||||||
</h2>
|
<p className="text-xl text-muted-foreground">{title}</p>
|
||||||
<p className="text-xl text-muted-foreground">{title}</p>
|
</div>
|
||||||
</div>
|
))}
|
||||||
))}
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
);
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Statistics;
|
export default Statistics;
|
||||||
|
|
|
@ -1,51 +1,55 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useInView, useMotionValue, useSpring } from "framer-motion";
|
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
|
import { useInView, useMotionValue, useSpring } from "framer-motion";
|
||||||
|
|
||||||
export default function NumTicker({
|
import { cn } from "@/lib/utils";
|
||||||
value,
|
|
||||||
direction = "up",
|
export default function NumberTicker({
|
||||||
delay = 0,
|
value,
|
||||||
className,
|
direction = "up",
|
||||||
|
delay = 0,
|
||||||
|
className,
|
||||||
}: {
|
}: {
|
||||||
value: number;
|
value: number;
|
||||||
direction?: "up" | "down";
|
direction?: "up" | "down";
|
||||||
className?: string;
|
className?: string;
|
||||||
delay?: number;
|
delay?: number; // delay in s
|
||||||
}) {
|
}) {
|
||||||
const ref = useRef<HTMLSpanElement>(null);
|
const ref = useRef<HTMLSpanElement>(null);
|
||||||
const motionValue = useMotionValue(direction === "down" ? value : 0);
|
const motionValue = useMotionValue(direction === "down" ? value : 0);
|
||||||
const springValue = useSpring(motionValue, {
|
const springValue = useSpring(motionValue, {
|
||||||
damping: 60,
|
damping: 60,
|
||||||
stiffness: 100,
|
stiffness: 100,
|
||||||
});
|
});
|
||||||
|
const isInView = useInView(ref, { once: true, margin: "0px" });
|
||||||
|
|
||||||
const isInView = useInView(ref, { once: true, margin: "0px" });
|
useEffect(() => {
|
||||||
|
isInView &&
|
||||||
|
setTimeout(() => {
|
||||||
|
motionValue.set(direction === "down" ? 0 : value);
|
||||||
|
}, delay * 1000);
|
||||||
|
}, [motionValue, isInView, delay, value, direction]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(
|
||||||
isInView &&
|
() =>
|
||||||
setTimeout(() => {
|
springValue.on("change", (latest) => {
|
||||||
motionValue.set(direction === "down" ? value : 0);
|
if (ref.current) {
|
||||||
}, delay * 1000);
|
ref.current.textContent = Intl.NumberFormat("en-US").format(
|
||||||
}, [motionValue, isInView, delay, value, direction]);
|
latest.toFixed(0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
[springValue]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(
|
return (
|
||||||
() =>
|
<span
|
||||||
springValue.on("change", (latest) => {
|
className={cn(
|
||||||
if (ref.current) {
|
"inline-block tabular-nums text-black dark:text-white tracking-wider",
|
||||||
ref.current.textContent = Intl.NumberFormat("en-US").format(
|
className
|
||||||
latest.toFixed(0)
|
)}
|
||||||
);
|
ref={ref}
|
||||||
}
|
/>
|
||||||
}),
|
);
|
||||||
[springValue]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span
|
|
||||||
className={`inline-block tabular-nums text-black dark:text-white ${className}`}
|
|
||||||
ref={ref}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue