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.

ui fixes

Kiran K1c8dc63297be
diff --git a/apps/web/app/app.dub.co/embed/widget/page-client.tsx b/apps/web/app/app.dub.co/embed/widget/page-client.tsx
index 7910236861..116fe46301 100644
--- a/apps/web/app/app.dub.co/embed/widget/page-client.tsx
+++ b/apps/web/app/app.dub.co/embed/widget/page-client.tsx
@@ -7,6 +7,7 @@ import {
MoneyBill2,
ToggleGroup,
useCopyToClipboard,
+ Wordmark,
} from "@dub/ui";
import { currencyFormatter, getPrettyUrl } from "@dub/utils";
import { useState } from "react";
@@ -24,9 +25,9 @@ export function EmbedWidgetPageClient() {
return (
<div>
- <div className="flex flex-col gap-2 rounded-lg rounded-b-none bg-black p-4">
+ <div className="flex flex-col gap-2 rounded-lg rounded-b-none bg-black p-8">
<MoneyBill2 className="flex size-14 rounded-full bg-gray-800 p-2 text-white" />
- <h2 className="mt-4 text-lg font-medium text-white">
+ <h2 className="mt-4 text-xl font-medium text-white">
Refer a friend and earn
</h2>
@@ -44,7 +45,7 @@ export function EmbedWidgetPageClient() {
]}
selected={selectedTab}
selectAction={(option: Tab) => setSelectedTab(option)}
- className="grid grid-cols-2 bg-gray-100"
+ className="grid grid-cols-2 bg-neutral-100"
optionClassName="w-full h-10"
indicatorClassName="rounded-md bg-white border-none shadow-sm"
/>
@@ -54,12 +55,17 @@ export function EmbedWidgetPageClient() {
<>
<div className="flex flex-col gap-2">
{!isLoadingLink && link ? (
- <input
- type="text"
- readOnly
- value={getPrettyUrl(link.shortLink)}
- className="xs:w-auto h-10 w-full rounded-md border border-neutral-300 px-3 text-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 lg:min-w-64 xl:min-w-72"
- />
+ <>
+ <span className="text-sm text-neutral-500">
+ Invite link
+ </span>
+ <input
+ type="text"
+ readOnly
+ value={getPrettyUrl(link.shortLink)}
+ className="xs:w-auto h-10 w-full rounded-md border border-neutral-300 px-3 text-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 lg:min-w-64 xl:min-w-72"
+ />
+ </>
) : (
<div className="h-10 animate-pulse rounded-md bg-neutral-200" />
)}
@@ -81,7 +87,7 @@ export function EmbedWidgetPageClient() {
{selectedTab === "rewards" && (
<>
- <h2 className="text-lg font-bold">Activity</h2>
+ <h2 className="text-lg font-bold">Rewards earned</h2>
{isLoadingLink || !link ? (
<div className="mt-4 grid grid-cols-3 gap-4">
<div className="flex animate-pulse flex-col gap-2 rounded-lg bg-gray-200 p-3 shadow-sm">
@@ -124,6 +130,17 @@ export function EmbedWidgetPageClient() {
)}
</>
)}
+
+ <div className="flex items-center justify-center">
+ <a
+ href="https://d.to/conversions"
+ target="_blank"
+ className="mt-2 flex items-center justify-center gap-2 rounded-lg bg-white p-2 transition-colors"
+ >
+ <p className="text-sm text-gray-700">Powered by</p>
+ <Wordmark className="h-4" />
+ </a>
+ </div>
</div>
</div>
</div>
diff --git a/apps/web/ui/embed/context.tsx b/apps/web/ui/embed/context.tsx
deleted file mode 100644
index 44b818ed41..0000000000
--- a/apps/web/ui/embed/context.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React, { createContext, useContext } from "react";
-
-interface DubContextType {
- publicToken: string;
-}
-
-const DubContext = createContext<DubContextType | undefined>(undefined);
-
-export const DubProvider: React.FC<
- DubContextType & { children: React.ReactNode }
-> = ({ publicToken, children }) => {
- return (
- <DubContext.Provider value={{ publicToken }}>
- {children}
- </DubContext.Provider>
- );
-};
-
-export const useDub = () => {
- const context = useContext(DubContext);
-
- if (context === undefined) {
- throw new Error("useDub must be used within a DubProvider");
- }
-
- return context;
-};
diff --git a/apps/web/ui/embed/referrals-embed.tsx b/apps/web/ui/embed/referrals-embed.tsx
deleted file mode 100644
index 3e7ce38763..0000000000
--- a/apps/web/ui/embed/referrals-embed.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { APP_DOMAIN } from "@dub/utils";
-import { useEffect } from "react";
-
-interface RewardDashboardProps {
- publicToken: string;
- onTokenExpired?: () => void;
-}
-
-export const RewardDashboard = ({
- publicToken,
- onTokenExpired,
-}: RewardDashboardProps) => {
- useEffect(() => {
- const handleMessage = (event: MessageEvent) => {
- // Verify the message is from our embed page
- if (event.origin !== APP_DOMAIN) {
- return;
- }
-
- if (event.data === "TOKEN_EXPIRED") {
- onTokenExpired?.();
- }
- };
-
- window.addEventListener("message", handleMessage);
-
- return () => window.removeEventListener("message", handleMessage);
- }, [onTokenExpired]);
-
- return (
- <iframe
- src={`${APP_DOMAIN}/embed/dashboard?token=${publicToken}`}
- style={{
- width: "100%",
- height: "100vh",
- border: "none",
- }}
- />
- );
-};
diff --git a/packages/embeds/react/example/index.html b/packages/embeds/react/example/index.html
index 58948b6eea..760e8471d2 100644
--- a/packages/embeds/react/example/index.html
+++ b/packages/embeds/react/example/index.html
@@ -11,7 +11,7 @@
<script type="module" src="../dist/embed.js"></script>
</head>
<body>
- <button data-dub-token="dub_embed_GHdbSOZBg5iyiuiOIsj0ZbQlAkstoQSrpc4s">
+ <button data-dub-token="dub_embed_MrRaGiUA3MkbdjTWJFHMYZrEaBR8KX355R0y">
Click Me
</button>
</body>
diff --git a/packages/embeds/react/src/embed.ts b/packages/embeds/react/src/embed.ts
index 121ea611c8..d014f0b5c9 100644
--- a/packages/embeds/react/src/embed.ts
+++ b/packages/embeds/react/src/embed.ts
@@ -4,6 +4,7 @@
// - Inline embed (dashboard)
// - Floating button + widget
// - Open on a button click
+// - Reuse addEventListener logic
import { DubOptions } from "./types";
@@ -53,8 +54,6 @@ const createIframe = (iframeUrl: string, token: string): HTMLIFrameElement => {
iframe.style.height = "100%";
iframe.style.border = "none";
iframe.setAttribute("credentialssupport", "");
- iframe.setAttribute("allow", "same-origin");
- iframe.setAttribute("crossorigin", "use-credentials");
return iframe;
};