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.

added Dub logo in QR code

Steven Teya8e436e16f05
diff --git a/components/app/modals/link-qr-modal.tsx b/components/app/modals/link-qr-modal.tsx
index 2e0aa960b4..4b93bc0bbb 100644
--- a/components/app/modals/link-qr-modal.tsx
+++ b/components/app/modals/link-qr-modal.tsx
@@ -1,24 +1,31 @@
-import { Dispatch, SetStateAction, useCallback, useMemo, useRef, useState } from 'react';
+import {
+ Dispatch,
+ SetStateAction,
+ useCallback,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
-import BlurImage from '@/components/shared/blur-image';
-import { Download, Logo } from '@/components/shared/icons';
-import Modal from '@/components/shared/modal';
-import { getQRAsCanvas, getQRAsSVGDataUri, QRCodeSVG } from '@/lib/qr';
-import useProject from '@/lib/swr/use-project';
-import { LinkProps } from '@/lib/types';
-import { linkConstructor } from '@/lib/utils';
+import BlurImage from "@/components/shared/blur-image";
+import { Download, Logo } from "@/components/shared/icons";
+import Modal from "@/components/shared/modal";
+import { getQRAsCanvas, getQRAsSVGDataUri, QRCodeSVG } from "@/lib/qr";
+import useProject from "@/lib/swr/use-project";
+import { LinkProps } from "@/lib/types";
+import { linkConstructor } from "@/lib/utils";
function LinkQRModalHelper({
showLinkQRModal,
setShowLinkQRModal,
- props
+ props,
}: {
showLinkQRModal: boolean;
setShowLinkQRModal: Dispatch<SetStateAction<boolean>>;
props: LinkProps;
}) {
const anchorRef = useRef<HTMLAnchorElement>();
- const [useSource, setUseSource] = useState(true);
+ const [showLogo, setShowLogo] = useState(true);
const { project: { domain } = {} } = useProject();
const avatarUrl = useMemo(() => {
try {
@@ -28,7 +35,11 @@ function LinkQRModalHelper({
return null;
}
}, [props]);
- const qrDestUrl = useMemo(() => `${linkConstructor({ key: props.key, domain })}${useSource && `?utm_source=qr`}`, [props, domain, useSource]);
+
+ const qrDestUrl = useMemo(
+ () => linkConstructor({ key: props.key, domain }),
+ [props, domain]
+ );
function download(url: string, extension: string) {
if (!anchorRef.current) return;
@@ -42,7 +53,13 @@ function LinkQRModalHelper({
<div className="inline-block w-full sm:max-w-md overflow-hidden align-middle transition-all transform bg-white sm:border sm:border-gray-200 shadow-xl sm:rounded-2xl">
<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">
{avatarUrl ? (
- <BlurImage src={avatarUrl} alt="Download QR Code" className="w-10 h-10 rounded-full border border-gray-200" width={40} height={40} />
+ <BlurImage
+ src={avatarUrl}
+ alt="Download QR Code"
+ className="w-10 h-10 rounded-full border border-gray-200"
+ width={40}
+ height={40}
+ />
) : (
<Logo className="w-10 h-10" />
)}
@@ -51,38 +68,71 @@ function LinkQRModalHelper({
<div className="flex flex-col space-y-6 text-left bg-gray-50 sm:px-16 px-4 py-8">
<div className="p-4 rounded-lg bg-white mx-auto border-2 border-gray-200">
- <QRCodeSVG value={qrDestUrl} size={128} bgColor="#ffffff" fgColor="#000000" level="L" includeMargin={false} />
+ <QRCodeSVG
+ value={qrDestUrl}
+ size={128}
+ bgColor="#ffffff"
+ fgColor="#000000"
+ level="L"
+ includeMargin={false}
+ imageSettings={
+ showLogo && {
+ src: "/static/logo.svg",
+ height: 36,
+ width: 36,
+ excavate: true,
+ }
+ }
+ />
</div>
- <div className="flex items-center gap-2">
+ <div className="flex justify-center items-center gap-2">
<input
id="qr-source"
name="qr-source"
type="checkbox"
- checked={useSource}
- onChange={(e) => setUseSource(e.target.checked)}
+ checked={showLogo}
+ onChange={(e) => setShowLogo(e.target.checked)}
className="h-4 w-4 rounded border-gray-300 text-blue-500 focus:border-gray-500 focus:ring-gray-500 focus:outline-none"
/>
- <label htmlFor="qr-source" className="block text-sm text-gray-700 select-none">
- Track QR visits as UTM source
+ <label
+ htmlFor="qr-source"
+ className="block text-sm text-gray-700 select-none"
+ >
+ Show Dub Logo
</label>
</div>
<div className="flex gap-2">
<button
- onClick={() => download(getQRAsSVGDataUri({ value: qrDestUrl, size: 256 }), 'svg')}
+ onClick={() =>
+ download(
+ getQRAsSVGDataUri({ value: qrDestUrl, size: 256 }),
+ "svg"
+ )
+ }
className="py-1.5 px-5 bg-black hover:bg-white rounded-md border border-black text-sm text-white hover:text-black transition-all w-full flex items-center gap-2 justify-center"
>
<Download /> SVG
</button>
<button
- onClick={() => download(getQRAsCanvas({ value: qrDestUrl, size: 256 }, 'image/png'), 'png')}
+ onClick={() =>
+ download(
+ getQRAsCanvas({ value: qrDestUrl, size: 256 }, "image/png"),
+ "png"
+ )
+ }
className="py-1.5 px-5 bg-black hover:bg-white rounded-md border border-black text-sm text-white hover:text-black transition-all w-full flex items-center gap-2 justify-center"
>
<Download /> PNG
</button>
<button
- onClick={() => download(getQRAsCanvas({ value: qrDestUrl, size: 256 }, 'image/jpeg'), 'jpg')}
+ onClick={() =>
+ download(
+ getQRAsCanvas({ value: qrDestUrl, size: 256 }, "image/jpeg"),
+ "jpg"
+ )
+ }
className="py-1.5 px-5 bg-black hover:bg-white rounded-md border border-black text-sm text-white hover:text-black transition-all w-full flex items-center gap-2 justify-center"
>
<Download /> JPEG
@@ -101,8 +151,17 @@ export function useLinkQRModal({ props }: { props: LinkProps }) {
const [showLinkQRModal, setShowLinkQRModal] = useState(false);
const LinkQRModal = useCallback(() => {
- return <LinkQRModalHelper showLinkQRModal={showLinkQRModal} setShowLinkQRModal={setShowLinkQRModal} props={props} />;
+ return (
+ <LinkQRModalHelper
+ showLinkQRModal={showLinkQRModal}
+ setShowLinkQRModal={setShowLinkQRModal}
+ props={props}
+ />
+ );
}, [showLinkQRModal, setShowLinkQRModal, props]);
- return useMemo(() => ({ setShowLinkQRModal, LinkQRModal }), [setShowLinkQRModal, LinkQRModal]);
-}
\ No newline at end of file
+ return useMemo(
+ () => ({ setShowLinkQRModal, LinkQRModal }),
+ [setShowLinkQRModal, LinkQRModal]
+ );
+}
diff --git a/public/static/logo.svg b/public/static/logo.svg
new file mode 100644
index 0000000000..1176ff7b04
--- /dev/null
+++ b/public/static/logo.svg
@@ -0,0 +1,17 @@
+<svg width="191" height="191" viewBox="0 0 191 191" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_36_30)">
+<path d="M191 95.5C191 148.243 148.243 191 95.5 191C42.7568 191 0 148.243 0 95.5C0 42.7568 42.7568 0 95.5 0C148.243 0 191 42.7568 191 95.5Z" fill="black"/>
+<mask id="mask0_36_30" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="191" height="191">
+<path d="M191 95.5C191 148.243 148.243 191 95.5 191C42.7568 191 0 148.243 0 95.5C0 42.7568 42.7568 0 95.5 0C148.243 0 191 42.7568 191 95.5Z" fill="black"/>
+</mask>
+<g mask="url(#mask0_36_30)">
+<circle cx="95" cy="100" r="49" fill="white"/>
+<path d="M122 -14H144V148H122V-14Z" fill="white"/>
+</g>
+</g>
+<defs>
+<clipPath id="clip0_36_30">
+<rect width="191" height="191" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/public/static/vercel.svg b/public/static/vercel.svg
deleted file mode 100644
index fbf0e25a65..0000000000
--- a/public/static/vercel.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
-</svg>
\ No newline at end of file