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.

small tweaks + bug fixes

Steven Tey7db193ecf3bb
diff --git a/components/home/demo.tsx b/components/home/demo.tsx
index 09a553701b..3385b9cc47 100644
--- a/components/home/demo.tsx
+++ b/components/home/demo.tsx
@@ -13,6 +13,7 @@ const Demo = () => {
const [saving, setSaving] = useState(false);
const [url, setUrl] = useState("");
const [hashes, setHashes] = useLocalStorage<SimpleLinkProps[]>("hashes", []);
+ const [showDefaultLink, setShowDefaultLink] = useState(true);
return (
<div className="max-w-md w-full mx-auto sm:px-0 px-2.5">
@@ -98,11 +99,16 @@ const Demo = () => {
}}
className="grid gap-2 mt-3"
>
- <LinkCard
- key="github"
- _key="github"
- url={"https://github.com/steven-tey/dub"}
- />
+ {showDefaultLink && (
+ <LinkCard
+ key="github"
+ _key="github"
+ url="https://github.com/steven-tey/dub"
+ hashes={hashes}
+ setHashes={setHashes}
+ setShowDefaultLink={setShowDefaultLink}
+ />
+ )}
{hashes.map(({ key, url }) => (
<LinkCard
key={key}
@@ -112,7 +118,9 @@ const Demo = () => {
setHashes={setHashes}
/>
))}
- {Array.from({ length: 3 - hashes.length }).map((_, i) => (
+ {Array.from({
+ length: showDefaultLink ? 3 - hashes.length : 4 - hashes.length,
+ }).map((_, i) => (
<PlaceholderCard key={i} />
))}
<motion.li
diff --git a/components/home/link-card.tsx b/components/home/link-card.tsx
index 174fb8e1c2..bc793b33e0 100644
--- a/components/home/link-card.tsx
+++ b/components/home/link-card.tsx
@@ -22,11 +22,13 @@ export default function LinkCard({
url,
hashes,
setHashes,
+ setShowDefaultLink,
}: {
_key: string;
url: string;
hashes?: SimpleLinkProps[];
setHashes?: (hashes: SimpleLinkProps[]) => void;
+ setShowDefaultLink?: (showDefaultLink: boolean) => void;
}) {
const apexDomain = getApexDomain(url);
@@ -76,8 +78,8 @@ export default function LinkCard({
}
};
- const sendErrorToast = useDebouncedCallback(
- () => toast.error("Cannot delete default link."),
+ const sendSuccessToast = useDebouncedCallback(
+ () => toast.success("Link deleted."),
100,
);
@@ -88,11 +90,12 @@ export default function LinkCard({
const parentNode = cardElem.current.parentNode;
const deleted = isDelete(childNode, parentNode);
if (deleted) {
+ toast.success("Link deleted.");
+ if (setShowDefaultLink) {
+ setShowDefaultLink(false);
+ }
if (hashes && setHashes) {
setHashes(hashes.filter((hash) => hash.key !== key));
- toast.success("Link deleted.");
- } else {
- sendErrorToast(); // debounce to prevent multiple toasts
}
}
}
diff --git a/components/home/logos.tsx b/components/home/logos.tsx
index 15a3d33da3..b9bb8269b6 100644
--- a/components/home/logos.tsx
+++ b/components/home/logos.tsx
@@ -34,7 +34,7 @@ export default function Logos() {
alt="Lugg"
width={2418}
height={512}
- className="col-span-1 h-10 sm:h-24"
+ className="col-span-1 h-16 sm:h-24"
/>
</div>
</div>
diff --git a/components/home/pricing.tsx b/components/home/pricing.tsx
index 806eafc692..6f64182f27 100644
--- a/components/home/pricing.tsx
+++ b/components/home/pricing.tsx
@@ -124,7 +124,7 @@ const Pricing = () => {
thumbTranslate="translate-x-6"
/>
<p className="text-gray-600">Billed Annually</p>
- <span className="absolute -top-8 sm:-top-2 -right-16 sm:-right-36 rounded-full bg-purple-200 text-purple-700 text-sm px-3 py-1">
+ <span className="absolute -top-8 sm:-top-2 -right-12 sm:-right-36 rounded-full bg-purple-200 text-purple-700 text-sm px-3 py-1">
🎁 2 months FREE
</span>
</div>
diff --git a/lib/hooks/use-local-storage.ts b/lib/hooks/use-local-storage.ts
index bdbd07bb7d..aa3984b597 100644
--- a/lib/hooks/use-local-storage.ts
+++ b/lib/hooks/use-local-storage.ts
@@ -14,7 +14,7 @@ const useLocalStorage = <T>(
}
}, [key]);
- const setValue = (value: any) => {
+ const setValue = (value: T) => {
// Save state
setStoredValue(value);
// Save to localStorage
diff --git a/pages/index.tsx b/pages/index.tsx
index 7a89e16dc0..0f437c81ef 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -51,22 +51,22 @@ export default function Home({ stars }: { stars: number }) {
}
export async function getStaticProps() {
- // const { stargazers_count: stars } = await fetch(
- // "https://api.github.com/repos/steven-tey/dub",
- // {
- // // optional – feel free to remove if you don't want to display star count
- // ...(process.env.GITHUB_OAUTH_TOKEN && {
- // headers: {
- // Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,
- // "Content-Type": "application/json",
- // },
- // }),
- // },
- // ).then((res) => res.json());
+ const { stargazers_count: stars } = await fetch(
+ "https://api.github.com/repos/steven-tey/dub",
+ {
+ // optional – feel free to remove if you don't want to display star count
+ ...(process.env.GITHUB_OAUTH_TOKEN && {
+ headers: {
+ Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,
+ "Content-Type": "application/json",
+ },
+ }),
+ },
+ ).then((res) => res.json());
return {
props: {
- stars: 10000,
+ stars,
},
revalidate: 10,
};