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.

Wrapped up custom domains, added custom fonts, started working on About page

Steven Tey1968c5a78a82
diff --git a/components/app/custom-domain/edit-domain-modal.tsx b/components/app/custom-domain/edit-domain-modal.tsx
index 40ff463349..85582ba340 100644
--- a/components/app/custom-domain/edit-domain-modal.tsx
+++ b/components/app/custom-domain/edit-domain-modal.tsx
@@ -67,7 +67,7 @@ function EditDomainModalHelper({
onSubmit={async (e) => {
e.preventDefault();
setSaving(true);
- fetch(`/api/projects/${slug}/domains`, {
+ fetch(`/api/projects/${slug}/domains/${domain}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
diff --git a/components/layout/home/dynamic-island.tsx b/components/layout/home/dynamic-island.tsx
new file mode 100644
index 0000000000..e6ab0dca7a
--- /dev/null
+++ b/components/layout/home/dynamic-island.tsx
@@ -0,0 +1,7 @@
+export default function DynamicIsland() {
+ return (
+ <div className="sticky bottom-10 left-0 right-0 mx-auto w-full max-w-md h-16 rounded-full shadow-md flex items-center justify-center">
+ Dynamic Island
+ </div>
+ );
+}
diff --git a/components/layout/home/index.tsx b/components/layout/home/index.tsx
index 9cab9f96c5..0fcfec92f1 100644
--- a/components/layout/home/index.tsx
+++ b/components/layout/home/index.tsx
@@ -1,10 +1,12 @@
import { ReactNode } from "react";
import Meta from "../meta";
+import DynamicIsland from "./dynamic-island";
export default function HomeLayout({ children }: { children: ReactNode }) {
return (
<div>
<Meta />
+ {/* <DynamicIsland /> */}
{children}
</div>
);
diff --git a/pages/about.tsx b/pages/about.tsx
new file mode 100644
index 0000000000..bc0e698262
--- /dev/null
+++ b/pages/about.tsx
@@ -0,0 +1,129 @@
+import HomeLayout from "@/components/layout/home";
+import { useEffect, useRef } from "react";
+import createGlobe from "cobe";
+import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
+
+export default function About() {
+ const canvasRef = useRef<any>();
+ const locationToAngles = (lat: number, long: number) => {
+ return [
+ Math.PI - ((long * Math.PI) / 180 - Math.PI / 2),
+ (lat * Math.PI) / 180,
+ ];
+ };
+ const focusRef = useRef([0, 0]);
+ useEffect(() => {
+ let width = 0;
+ let currentPhi = 0;
+ let currentTheta = 0;
+ const doublePi = Math.PI * 2;
+ const onResize = () =>
+ canvasRef.current && (width = canvasRef.current.offsetWidth);
+ window.addEventListener("resize", onResize);
+ onResize();
+ const globe = createGlobe(canvasRef.current, {
+ devicePixelRatio: 2,
+ width: width * 2,
+ height: width * 2,
+ phi: 0,
+ theta: 0.3,
+ dark: 1,
+ diffuse: 3,
+ mapSamples: 16000,
+ mapBrightness: 1.2,
+ baseColor: [1, 1, 1],
+ markerColor: [251 / 255, 200 / 255, 21 / 255],
+ glowColor: [1.2, 1.2, 1.2],
+ markers: [
+ { location: [37.78, -122.412], size: 0.1 },
+ { location: [52.52, 13.405], size: 0.1 },
+ { location: [35.676, 139.65], size: 0.1 },
+ { location: [-34.6, -58.38], size: 0.1 },
+ ],
+ onRender: (state) => {
+ state.phi = currentPhi;
+ state.theta = currentTheta;
+ const [focusPhi, focusTheta] = focusRef.current;
+ const distPositive = (focusPhi - currentPhi + doublePi) % doublePi;
+ const distNegative = (currentPhi - focusPhi + doublePi) % doublePi;
+ // Control the speed
+ if (distPositive < distNegative) {
+ currentPhi += distPositive * 0.08;
+ } else {
+ currentPhi -= distNegative * 0.08;
+ }
+ currentTheta = currentTheta * 0.92 + focusTheta * 0.08;
+ state.width = width * 2;
+ state.height = width * 2;
+ },
+ });
+ setTimeout(() => (canvasRef.current.style.opacity = "1"));
+ return () => globe.destroy();
+ }, []);
+
+ return (
+ <HomeLayout>
+ <MaxWidthWrapper>
+ <div className="mt-36 text-center">
+ <h1 className="font-display font-semibold text-3xl text-gray-700">
+ Introducing Dub
+ </h1>
+ </div>
+ </MaxWidthWrapper>
+ <div
+ style={{
+ width: "100%",
+ maxWidth: 600,
+ aspectRatio: "1",
+ margin: "auto",
+ position: "relative",
+ }}
+ >
+ <canvas
+ ref={canvasRef}
+ style={{
+ width: "100%",
+ height: "100%",
+ contain: "layout paint size",
+ opacity: 0,
+ transition: "opacity 1s ease",
+ }}
+ />
+ <div
+ className="flex justify-center control-buttons"
+ style={{ gap: ".5rem" }}
+ >
+ Rotate to:
+ <button
+ onClick={() => {
+ focusRef.current = locationToAngles(37.78, -122.412);
+ }}
+ >
+ San Francisco
+ </button>
+ <button
+ onClick={() => {
+ focusRef.current = locationToAngles(52.52, 13.405);
+ }}
+ >
+ Berlin
+ </button>
+ <button
+ onClick={() => {
+ focusRef.current = locationToAngles(35.676, 139.65);
+ }}
+ >
+ Tokyo
+ </button>
+ <button
+ onClick={() => {
+ focusRef.current = locationToAngles(-34.6, -58.38);
+ }}
+ >
+ Buenos Aires
+ </button>
+ </div>
+ </div>
+ </HomeLayout>
+ );
+}
diff --git a/pages/api/projects/[slug]/domains/[domain]/index.ts b/pages/api/projects/[slug]/domains/[domain]/index.ts
new file mode 100644
index 0000000000..31771ba015
--- /dev/null
+++ b/pages/api/projects/[slug]/domains/[domain]/index.ts
@@ -0,0 +1,55 @@
+import { NextApiRequest, NextApiResponse } from "next";
+import prisma from "@/lib/prisma";
+import { withProjectAuth } from "@/lib/auth";
+
+export default withProjectAuth(
+ async (req: NextApiRequest, res: NextApiResponse) => {
+ if (req.method === "PUT") {
+ const { slug, domain } = req.query as { slug: string; domain: string }; // slug is the domain
+ const newDomain = req.body;
+
+ if (domain !== newDomain) {
+ const [removeResponse, addResponse] = await Promise.all([
+ fetch(
+ `https://api.vercel.com/v9/projects/${process.env.VERCEL_PROJECT_ID}/domains/${domain}?teamId=${process.env.VERCEL_TEAM_ID}`,
+ {
+ headers: {
+ Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
+ },
+ method: "DELETE",
+ }
+ ),
+ fetch(
+ `https://api.vercel.com/v9/projects/${process.env.VERCEL_PROJECT_ID}/domains?teamId=${process.env.VERCEL_TEAM_ID}`,
+ {
+ body: `{\n "name": "${newDomain}"\n}`,
+ headers: {
+ Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
+ "Content-Type": "application/json",
+ },
+ method: "POST",
+ }
+ ),
+ ]);
+
+ const response = await prisma.project.update({
+ where: {
+ slug,
+ },
+ data: {
+ domain: newDomain,
+ domainVerified: false,
+ },
+ });
+
+ return res.status(200).json({ removeResponse, addResponse, response });
+ }
+ return res.status(200).json({ message: "Domains are the same" });
+ } else {
+ res.setHeader("Allow", ["PUT"]);
+ return res
+ .status(405)
+ .json({ error: `Method ${req.method} Not Allowed` });
+ }
+ }
+);
diff --git a/pages/api/projects/[slug]/domains/[domain]/verify.ts b/pages/api/projects/[slug]/domains/[domain]/verify.ts
index 5237c3d1a5..3fef1c38c7 100644
--- a/pages/api/projects/[slug]/domains/[domain]/verify.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/verify.ts
@@ -65,8 +65,6 @@ export default withProjectAuth(
status = "Valid Configuration";
}
- console.log(status, configJson, domainJson, verificationResponse);
-
return res.status(200).json({
status,
response: { configJson, domainJson, verificationResponse },
diff --git a/pages/api/projects/[slug]/domains/index.ts b/pages/api/projects/[slug]/domains/index.ts
deleted file mode 100644
index c25e14e0a9..0000000000
--- a/pages/api/projects/[slug]/domains/index.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { NextApiRequest, NextApiResponse } from "next";
-import { redis, editLink } from "@/lib/upstash";
-import { withProjectAuth } from "@/lib/auth";
-
-export default withProjectAuth(
- async (req: NextApiRequest, res: NextApiResponse) => {
- if (req.method === "PUT") {
- const { slug } = req.query as { slug: string }; // slug is the domain
-
- const response = slug;
-
- return res.status(200).json(response);
- } else {
- res.setHeader("Allow", ["PUT"]);
- return res
- .status(405)
- .json({ error: `Method ${req.method} Not Allowed` });
- }
- }
-);
diff --git a/public/static/fonts/Satoshi-Variable.ttf b/public/static/fonts/Satoshi-Variable.ttf
new file mode 100644
index 0000000000..976e85cb58
Binary files /dev/null and b/public/static/fonts/Satoshi-Variable.ttf differ
diff --git a/public/static/fonts/Satoshi-Variable.woff b/public/static/fonts/Satoshi-Variable.woff
new file mode 100644
index 0000000000..f8dcd1d603
Binary files /dev/null and b/public/static/fonts/Satoshi-Variable.woff differ
diff --git a/public/static/fonts/Satoshi-Variable.woff2 b/public/static/fonts/Satoshi-Variable.woff2
new file mode 100644
index 0000000000..b00e833ed4
Binary files /dev/null and b/public/static/fonts/Satoshi-Variable.woff2 differ
diff --git a/public/static/fonts/Satoshi-VariableItalic.ttf b/public/static/fonts/Satoshi-VariableItalic.ttf
new file mode 100644
index 0000000000..4c2677c6f3
Binary files /dev/null and b/public/static/fonts/Satoshi-VariableItalic.ttf differ
diff --git a/public/static/fonts/Satoshi-VariableItalic.woff b/public/static/fonts/Satoshi-VariableItalic.woff
new file mode 100644
index 0000000000..3fe029e252
Binary files /dev/null and b/public/static/fonts/Satoshi-VariableItalic.woff differ
diff --git a/public/static/fonts/Satoshi-VariableItalic.woff2 b/public/static/fonts/Satoshi-VariableItalic.woff2
new file mode 100644
index 0000000000..e7ab3a09ac
Binary files /dev/null and b/public/static/fonts/Satoshi-VariableItalic.woff2 differ
diff --git a/public/static/fonts/satoshi.css b/public/static/fonts/satoshi.css
new file mode 100644
index 0000000000..dd82138f58
--- /dev/null
+++ b/public/static/fonts/satoshi.css
@@ -0,0 +1,65 @@
+/**
+ * @license
+ *
+ * Font Family: Satoshi
+ * Designed by: Deni Anggara
+ * URL: https://www.fontshare.com/fonts/satoshi
+ * © 2022 Indian Type Foundry
+ *
+ * Font Styles:
+ * Satoshi Variable(Variable font)
+ * Satoshi Variable Italic(Variable font)
+ * Satoshi Light
+ * Satoshi Light Italic
+ * Satoshi Regular
+ * Satoshi Italic
+ * Satoshi Medium
+ * Satoshi Medium Italic
+ * Satoshi Bold
+ * Satoshi Bold Italic
+ * Satoshi Black
+ * Satoshi Black Italic
+ *
+*/
+
+/**
+* This is a variable font
+* You can controll variable axes as shown below:
+* font-variation-settings: 'wght' 900.0;
+*
+* available axes:
+
+* 'wght' (range from 300.0 to 900.0)
+
+*/
+
+@font-face {
+ font-family: "Satoshi-Variable";
+ src: url("./Satoshi-Variable.woff2") format("woff2"),
+ url("./Satoshi-Variable.woff") format("woff"),
+ url("./Satoshi-Variable.ttf") format("truetype");
+ font-weight: 300 900;
+ font-display: swap;
+ font-style: normal;
+}
+
+/**
+* This is a variable font
+* You can controll variable axes as shown below:
+* font-variation-settings: 'wght' 900.0;
+*
+* available axes:
+
+* 'wght' (range from 300.0 to 900.0)
+
+*/
+
+@font-face {
+ font-family: "Satoshi-VariableItalic";
+ src: url("./Satoshi-VariableItalic.woff2") format("woff2"),
+ url("./Satoshi-VariableItalic.woff") format("woff"),
+ url("./Satoshi-VariableItalic.ttf") format("truetype");
+ font-weight: 300 900;
+ font-display: swap;
+ font-style: italic;
+}
diff --git a/styles/globals.css b/styles/globals.css
index b5c61c9567..76b7b3b23c 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -1,3 +1,5 @@
+@import url("/static/fonts/satoshi.css");
+
@tailwind base;
@tailwind components;
@tailwind utilities;
diff --git a/tailwind.config.js b/tailwind.config.js
index ea29271e42..18cbb84f6c 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -6,6 +6,9 @@ module.exports = {
],
theme: {
extend: {
+ fontFamily: {
+ display: ["Satoshi-Variable, system-ui", "sans-serif"],
+ },
animation: {
// Tooltip
"slide-up-fade": "slide-up-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1)",