Skip to content

Commit

Permalink
fix: time and divider
Browse files Browse the repository at this point in the history
  • Loading branch information
clmntsnr committed Dec 9, 2024
1 parent d13a793 commit 7819c92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/primitives/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export type DividerProps = Component<
>;

export default function Divider({ vertical = false, horizontal = true, look, className, ...props }: DividerProps) {
if (horizontal) return <div className={mergeClass(dividerStyles({ look }), className)} {...props} />;
if (horizontal && !vertical) return <div className={mergeClass(dividerStyles({ look }), className)} {...props} />;

return (
<div className={mergeClass(dividerStyles({ look, vertical: vertical ?? !horizontal }), className)} {...props} />
<div className={mergeClass(dividerStyles({ look, vertical: true }), className)} {...props} />
);
}
12 changes: 7 additions & 5 deletions src/components/primitives/Time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ import { useMemo } from "react";

export type TimeProps = {
timestamp: number | bigint;
prefix?: string;
relative?: "hours" | "day" | "auto";
};

export default function Time({ timestamp }: TimeProps) {
export default function Time({ timestamp, prefix }: TimeProps) {
const time = useMemo(() => {
const then = moment(Number(timestamp)).fromNow();

return then
.replace("in ", (prefix && `${prefix} `) ?? "in ")
.replace("/ minute| minutes/g", "m")
.replace(/\ba\b/, "1")
.replace(/ seconds| second/g, "s")
.replace(/ hours| hour/g, "h")
.replace(/ days| day/g, "d")
.replace(/ months| month/g, "d");
}, [timestamp]);
.replace(/ hours| hour/g, "hours")
.replace(/ days| day/g, " days")
.replace(/ months| month/g, " months");
}, [timestamp, prefix]);

return time;
}

0 comments on commit 7819c92

Please sign in to comment.