Skip to content

Commit

Permalink
fix: time and divider (#20)
Browse files Browse the repository at this point in the history
* add: control over divider colors + Connected component

* fix: code quality

* fix: time and divider

* lint
  • Loading branch information
clmntsnr authored Dec 9, 2024
1 parent a838d80 commit 4b39ca2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/components/primitives/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ 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} />
);
return <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 4b39ca2

Please sign in to comment.