Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improved nav UI, fixed timestamp bug

Steven Tey709c91a61c33
diff --git a/components/app/modals/add-edit-link-modal.tsx b/components/app/modals/add-edit-link-modal.tsx
index adc989ae99..5feb35e9c3 100644
--- a/components/app/modals/add-edit-link-modal.tsx
+++ b/components/app/modals/add-edit-link-modal.tsx
@@ -13,14 +13,12 @@ import { useDebounce } from "use-debounce";
import BlurImage from "@/components/shared/blur-image";
import {
AlertCircleFill,
- Calendar,
ChevronRight,
LoadingCircle,
LoadingDots,
UploadCloud,
} from "@/components/shared/icons";
import Modal from "@/components/shared/modal";
-import Popover from "@/components/shared/popover";
import Tooltip, { TooltipContent } from "@/components/shared/tooltip";
import useProject from "@/lib/swr/use-project";
import useUsage from "@/lib/swr/use-usage";
@@ -50,12 +48,25 @@ function AddEditLinkModal({
key: "",
url: "",
archived: false,
+ expiresAt: null,
+ password: null,
+
+ title: null,
+ description: null,
+ image: null,
+
+ utm_source: null,
+ utm_medium: null,
+ utm_campaign: null,
+ utm_term: null,
+ utm_content: null,
+
clicks: 0,
userId: "",
createdAt: new Date(),
},
);
- const { key, url } = data;
+ const { key, url, expiresAt } = data;
const heroProps = useMemo(() => {
if (props?.url) {
@@ -130,6 +141,12 @@ function AddEditLinkModal({
setShowModal={setShowAddEditLinkModal}
>
<div className="inline-block w-full sm:max-w-md max-h-[calc(100vh-50px)] overflow-scroll align-middle transition-all transform bg-white sm:border sm:border-gray-200 shadow-xl sm:rounded-2xl">
+ {new Date().getTime() > new Date(expiresAt).getTime() && (
+ <span className="absolute top-0 sm:top-5 right-5 bg-amber-500 px-2 py-0.5 text-xs text-white uppercase">
+ Expired
+ </span>
+ )}
+
<div className="flex flex-col justify-center items-center space-y-3 sm:px-16 px-4 pt-8 py-4 border-b border-gray-200">
<BlurImage
src={heroProps.avatar}
@@ -496,9 +513,14 @@ function AdvancedSettings({
<div>
<label
htmlFor="expiresAt"
- className="block text-sm font-medium text-gray-700"
+ className="flex justify-between text-sm font-medium text-gray-700"
>
- Auto-expire Link
+ <p>Auto-expire Link</p>
+ {new Date().getTime() > new Date(expiresAt).getTime() && (
+ <span className="bg-amber-500 px-2 py-0.5 text-xs text-white uppercase">
+ Expired
+ </span>
+ )}
</label>
<input
type="datetime-local"
@@ -510,7 +532,7 @@ function AdvancedSettings({
onChange={(e) => {
setData({ ...data, expiresAt: new Date(e.target.value) });
}}
- className="flex space-x-2 justify-center items-center mt-1 rounded-md shadow-sm border border-gray-300 text-gray-500 hover:border-gray-800 px-5 py-2 w-full focus:outline-none sm:text-sm transition-all"
+ className="flex space-x-2 justify-center items-center mt-1 rounded-md shadow-sm border border-gray-300 text-gray-500 hover:border-gray-800 px-3 py-2 w-full focus:outline-none sm:text-sm transition-all"
/>
</div>
</div>
diff --git a/components/layout/app/nav-tabs.tsx b/components/layout/app/nav-tabs.tsx
index 0d391adb5e..51e1eb4c63 100644
--- a/components/layout/app/nav-tabs.tsx
+++ b/components/layout/app/nav-tabs.tsx
@@ -33,19 +33,19 @@ export default function NavTabs() {
}, [router.query]);
return (
- <div className="flex justify-start space-x-8 items-center h-12 -mb-0.5">
+ <div className="flex justify-start space-x-2 items-center h-12 -mb-0.5">
{tabs.map(({ name, href }) => (
<Link key={href} href={href}>
<a
- className={`px-1 py-3 border-b-2 ${
+ className={`border-b-2 p-1 ${
router.asPath === href
- ? "border-black font-semibold"
- : "border-transparent text-gray-700 hover:text-black"
- } transition-all`}
+ ? "border-black text-black"
+ : "border-transparent text-gray-600 hover:text-black"
+ }`}
>
- <p className="text-sm active:scale-95 transition-all duration-75">
- {name}
- </p>
+ <div className="rounded-md px-3 py-2 hover:bg-gray-100 active:bg-gray-200 transition-all">
+ <p className="text-sm">{name}</p>
+ </div>
</a>
</Link>
))}
diff --git a/components/layout/app/project-select.tsx b/components/layout/app/project-select.tsx
index 1a07acd993..970f63d96e 100644
--- a/components/layout/app/project-select.tsx
+++ b/components/layout/app/project-select.tsx
@@ -51,7 +51,7 @@ export default function ProjectSelect() {
/>
}
>
- <div className="relative cursor-pointer w-60 rounded-lg bg-white hover:bg-gray-100 py-1.5 pl-3 pr-10 text-left focus:outline-none text-sm transition-all duration-75">
+ <div className="relative cursor-pointer w-60 rounded-lg bg-white hover:bg-gray-100 active:bg-gray-200 py-1.5 pl-3 pr-10 text-left focus:outline-none text-sm transition-all duration-75">
<div className="flex justify-start items-center space-x-3">
<BlurImage
src={
diff --git a/lib/types.ts b/lib/types.ts
index ced48cf1a2..62ac88f9b6 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -9,18 +9,18 @@ export interface LinkProps {
key: string;
url: string;
archived: boolean;
- expiresAt?: Date;
- password?: string;
+ expiresAt: Date | null;
+ password: string | null;
- title?: string;
- description?: string;
- image?: string;
+ title: string | null;
+ description: string | null;
+ image: string | null;
- utm_source?: string;
- utm_medium?: string;
- utm_campaign?: string;
- utm_term?: string;
- utm_content?: string;
+ utm_source: string | null;
+ utm_medium: string | null;
+ utm_campaign: string | null;
+ utm_term: string | null;
+ utm_content: string | null;
clicks: number;
userId: string;
diff --git a/lib/utils.ts b/lib/utils.ts
index 8a96be3d86..5d8dbeffcb 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -114,15 +114,8 @@ export const timeAgo = (timestamp: Date): string => {
};
export const getDateTimeLocal = (timestamp?: Date): string => {
- if (!timestamp) {
- const d = new Date();
- return new Date(d.getTime() - d.getTimezoneOffset() * 60000)
- .toISOString()
- .split(":")
- .slice(0, 2)
- .join(":");
- }
- return new Date(timestamp.getTime() - timestamp.getTimezoneOffset() * 60000)
+ const d = timestamp ? new Date(timestamp) : new Date();
+ return new Date(d.getTime() - d.getTimezoneOffset() * 60000)
.toISOString()
.split(":")
.slice(0, 2)