|
@@ -1,5 +1,6 @@
|
|
|
"use client";
|
|
|
import useCountDown from "@/hooks/useCountdown";
|
|
|
+import clsx from "clsx";
|
|
|
|
|
|
const TimeLeft = ({
|
|
|
endTime,
|
|
@@ -7,12 +8,14 @@ const TimeLeft = ({
|
|
|
itemStyle = {},
|
|
|
splitStyle = {},
|
|
|
onEnd,
|
|
|
+ autoHeight = false,
|
|
|
}: {
|
|
|
endTime: number;
|
|
|
itemBgColor?: string;
|
|
|
itemStyle?: React.CSSProperties;
|
|
|
splitStyle?: React.CSSProperties;
|
|
|
onEnd?: Function;
|
|
|
+ autoHeight?: boolean;
|
|
|
}) => {
|
|
|
const [countdown, time] = useCountDown({
|
|
|
leftTime: endTime * 1000,
|
|
@@ -26,48 +29,61 @@ const TimeLeft = ({
|
|
|
return (
|
|
|
<div className={"flex text-[0.1389rem]"}>
|
|
|
<div className={"text-center"}>
|
|
|
- <div className={"flex items-center text-[#fff]"}>
|
|
|
+ <div className={"flex items-center leading-[1] text-[#fff]"}>
|
|
|
<div
|
|
|
- className={
|
|
|
- `flex items-center justify-center rounded-[0.0347rem]` +
|
|
|
- " h-[0.2083rem] w-[0.2083rem]"
|
|
|
- }
|
|
|
+ className={clsx(
|
|
|
+ `flex items-center justify-center rounded-[0.0347rem]`,
|
|
|
+ "w-[0.2083rem]",
|
|
|
+ { "h-[0.2083rem]": !autoHeight }
|
|
|
+ )}
|
|
|
style={{ backgroundColor: itemBgColor, ...itemStyle }}
|
|
|
>
|
|
|
{`${time.days}`.padStart(2, "0")}
|
|
|
</div>
|
|
|
- <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
|
|
|
+ <div
|
|
|
+ className={"lex mx-[0.0247rem] items-center justify-center"}
|
|
|
+ style={{ ...splitStyle }}
|
|
|
+ >
|
|
|
:
|
|
|
- </span>
|
|
|
+ </div>
|
|
|
<div
|
|
|
- className={
|
|
|
- `flex items-center justify-center rounded-[0.0347rem]` +
|
|
|
- " h-[0.2083rem] w-[0.2083rem]"
|
|
|
- }
|
|
|
+ className={clsx(
|
|
|
+ `flex items-center justify-center rounded-[0.0347rem]`,
|
|
|
+ "w-[0.2083rem]",
|
|
|
+ { "h-[0.2083rem]": !autoHeight }
|
|
|
+ )}
|
|
|
style={{ backgroundColor: itemBgColor, ...itemStyle }}
|
|
|
>
|
|
|
{`${time.hours}`.padStart(2, "0")}
|
|
|
</div>
|
|
|
- <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
|
|
|
+ <div
|
|
|
+ className={"lex mx-[0.0247rem] items-center justify-center"}
|
|
|
+ style={{ ...splitStyle }}
|
|
|
+ >
|
|
|
:
|
|
|
- </span>
|
|
|
+ </div>
|
|
|
<div
|
|
|
- className={
|
|
|
- `flex items-center justify-center rounded-[0.0347rem]` +
|
|
|
- " h-[0.2083rem] w-[0.2083rem]"
|
|
|
- }
|
|
|
+ className={clsx(
|
|
|
+ `flex items-center justify-center rounded-[0.0347rem]`,
|
|
|
+ "w-[0.2083rem]",
|
|
|
+ { "h-[0.2083rem]": !autoHeight }
|
|
|
+ )}
|
|
|
style={{ backgroundColor: itemBgColor, ...itemStyle }}
|
|
|
>
|
|
|
{`${time.minutes}`.padStart(2, "0")}
|
|
|
</div>
|
|
|
- <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
|
|
|
+ <div
|
|
|
+ className={"lex mx-[0.0247rem] items-center justify-center"}
|
|
|
+ style={{ ...splitStyle }}
|
|
|
+ >
|
|
|
:
|
|
|
- </span>
|
|
|
+ </div>
|
|
|
<div
|
|
|
- className={
|
|
|
- `flex items-center justify-center rounded-[0.0347rem]` +
|
|
|
- " h-[0.2083rem] w-[0.2083rem]"
|
|
|
- }
|
|
|
+ className={clsx(
|
|
|
+ `flex items-center justify-center rounded-[0.0347rem]`,
|
|
|
+ "w-[0.2083rem]",
|
|
|
+ { "h-[0.2083rem]": !autoHeight }
|
|
|
+ )}
|
|
|
style={{ backgroundColor: itemBgColor, ...itemStyle }}
|
|
|
>
|
|
|
{`${time.seconds}`.padStart(2, "0")}
|