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.

fix link card styles

Steven Tey5b2f654e7fa5
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
index fdecbcd621..5fd5129ef1 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
@@ -97,60 +97,37 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {
<div className="flex min-w-0 flex-col">
<div className="flex flex-col">
<div className="flex items-center gap-1">
- <div
+ <a
+ href={isDeactivated ? undefined : partnerLink}
+ target="_blank"
+ rel="noopener noreferrer"
className={cn(
- "group/shortlink relative flex w-fit items-center gap-1 py-0 pl-1 pr-1.5 transition-colors duration-150",
- !isDeactivated && "hover:rounded-lg hover:bg-neutral-100",
+ "truncate text-sm font-semibold leading-6 transition-colors",
+ isDeactivated
+ ? "cursor-default text-neutral-400"
+ : "text-neutral-700 hover:text-black",
)}
+ onClick={
+ isDeactivated ? (e) => e.preventDefault() : undefined
+ }
>
- <a
- href={isDeactivated ? undefined : partnerLink}
- target="_blank"
- rel="noopener noreferrer"
- className={cn(
- "truncate text-sm font-semibold leading-6 transition-colors",
- isDeactivated
- ? "cursor-default text-neutral-400"
- : "text-neutral-700 hover:text-black",
- )}
- onClick={
- isDeactivated ? (e) => e.preventDefault() : undefined
- }
- >
- {getPrettyUrl(partnerLink)}
- </a>
- {!isDeactivated && (
- <span className="flex items-center">
- <CopyButton
- value={partnerLink}
- variant="neutral"
- className="p-0.5 opacity-0 transition-opacity duration-150 group-hover/shortlink:opacity-100"
- />
- </span>
- )}
- </div>
+ {getPrettyUrl(partnerLink)}
+ </a>
+ {!isDeactivated && (
+ <CopyButton value={partnerLink} variant="neutral" />
+ )}
{link.comments && <CommentsBadge comments={link.comments} />}
</div>
{/* The max width implementation here is a bit hacky, we should improve in the future */}
- <div
- className={cn(
- "group/desturl flex max-w-[100px] items-center gap-1 py-0 pl-1 pr-1.5 transition-colors duration-150 sm:w-fit sm:max-w-[400px]",
- !isDeactivated && "hover:rounded-lg hover:bg-neutral-100",
- )}
- >
+ <div className="flex max-w-[100px] items-center gap-1 py-0 pl-1 pr-1.5 sm:w-fit sm:max-w-[400px]">
<ArrowTurnRight2 className="h-3 w-3 shrink-0 text-neutral-400" />
<a
href={isDeactivated ? undefined : link.url}
target="_blank"
rel="noopener noreferrer"
- className={cn(
- "truncate text-sm transition-colors",
- isDeactivated
- ? "cursor-default text-neutral-400"
- : "text-neutral-500 hover:text-neutral-700",
- )}
+ className="cursor-alias truncate text-sm text-neutral-500 decoration-dotted transition-colors hover:text-neutral-700 hover:underline hover:underline-offset-2"
title={getPrettyUrl(link.url)}
onClick={
isDeactivated ? (e) => e.preventDefault() : undefined
@@ -158,15 +135,6 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {
>
{getPrettyUrl(link.url)}
</a>
- {!isDeactivated && (
- <span className="flex items-center">
- <CopyButton
- value={link.url}
- variant="neutral"
- className="p-0.5 opacity-0 transition-opacity duration-150 group-hover/desturl:opacity-100"
- />
- </span>
- )}
</div>
</div>
</div>
@@ -191,7 +159,7 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {
"This program supports discount code tracking. Copy the code to use it in podcasts, videos, etc. [Learn more](https://dub.co/help/article/dual-sided-incentives)"
}
>
- <div className="flex items-center gap-1.5 rounded-xl border border-neutral-200 py-1 pl-2 pr-1">
+ <div className="hidden items-center gap-1.5 rounded-xl border border-neutral-200 py-1 pl-2 pr-1 sm:flex">
<span className="text-sm leading-none text-neutral-500">
Discount code
</span>
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsx
index dee2ae97ce..ba3b2b2969 100644
--- a/apps/web/ui/links/link-title-column.tsx
+++ b/apps/web/ui/links/link-title-column.tsx
@@ -354,7 +354,7 @@ const Details = memo(
target="_blank"
rel="noopener noreferrer"
title={url}
- className="truncate text-neutral-500 transition-colors hover:text-neutral-700 hover:underline hover:underline-offset-2"
+ className="cursor-alias truncate text-neutral-500 decoration-dotted transition-colors hover:text-neutral-700 hover:underline hover:underline-offset-2"
>
{getPrettyUrl(url)}
</a>
diff --git a/apps/web/ui/modals/partner-link-modal.tsx b/apps/web/ui/modals/partner-link-modal.tsx
index fa431464bf..46f9da53cc 100644
--- a/apps/web/ui/modals/partner-link-modal.tsx
+++ b/apps/web/ui/modals/partner-link-modal.tsx
@@ -162,8 +162,8 @@ function PartnerLinkModalContent({
link?: PartnerProfileLinkProps;
setShowPartnerLinkModal: Dispatch<SetStateAction<boolean>>;
}) {
- const isEditingLink = Boolean(link?.id); // When duplicating the id will be empty
const isCreatingLink = !link;
+ const isEditingLink = Boolean(link?.id); // When duplicating the id will be empty
const { programSlug } = useParams();
const { isMobile } = useMediaQuery();
@@ -253,16 +253,6 @@ function PartnerLinkModalContent({
[isLoading, isEditingLink, isDirty, destinationDomains],
);
- // we hide the destination URL input if:
- // 1. the link is a partner group default link
- // 2. there is only one destination domain and we are in exact mode
- const hideDestinationUrl = useMemo(
- () =>
- link?.partnerGroupDefaultLinkId ||
- (destinationDomains.length === 1 && isExactMode),
- [destinationDomains.length, isExactMode, link?.partnerGroupDefaultLinkId],
- );
-
const shortLink = useMemo(
() =>
linkConstructor({
@@ -378,7 +368,9 @@ function PartnerLinkModalContent({
})}
type="text"
id="key"
- autoFocus={Boolean(hideDestinationUrl && !isMobile)}
+ autoFocus={Boolean(
+ link?.partnerGroupDefaultLinkId && !isMobile,
+ )}
onFocus={() => setKeyInputFocused(true)}
onBlur={() => setKeyInputFocused(false)}
disabled={lockKey}
@@ -401,60 +393,79 @@ function PartnerLinkModalContent({
)}
</div>
- {!hideDestinationUrl && (
- <div>
- <div className="flex items-center gap-2">
- <label
- htmlFor="url"
- className="block text-sm font-medium text-neutral-700"
- >
- Destination URL
- </label>
- <InfoTooltip content="The URL your users will get redirected to when they visit your short link. [Learn more.](https://dub.co/help/article/how-to-create-link)" />
- </div>
- <div className="relative mt-1 flex rounded-md shadow-sm">
- <div className="z-[1]">
+ <div>
+ <div className="flex items-center gap-2">
+ <label
+ htmlFor="url"
+ className="block text-sm font-medium text-neutral-700"
+ >
+ Destination URL
+ </label>
+ <InfoTooltip content="The URL your users will get redirected to when they visit your short link. [Learn more.](https://dub.co/help/article/how-to-create-link)" />
+ </div>
+ <div className="relative mt-1 flex rounded-md shadow-sm">
+ <div className="z-[1]">
+ {destinationDomains.length === 1 ||
+ link?.partnerGroupDefaultLinkId ? (
+ <div
+ className={cn(
+ "flex h-full w-fit items-center justify-start rounded-l-md border border-r-0 border-neutral-300 bg-neutral-50 px-2.5 text-sm text-neutral-700",
+ {
+ "cursor-not-allowed bg-neutral-100 text-neutral-500":
+ link?.partnerGroupDefaultLinkId,
+ },
+ )}
+ >
+ {punycode(destinationDomains[0])}
+ </div>
+ ) : (
<DestinationDomainCombobox
selectedDomain={destinationDomain}
setSelectedDomain={setDestinationDomain}
destinationDomains={destinationDomains}
- disabled={isEditingLink}
+ disabled={Boolean(
+ isEditingLink || link?.partnerGroupDefaultLinkId,
+ )}
/>
- </div>
- <input
- {...register("pathname", { required: false })}
- type="text"
- placeholder="(optional)"
- autoFocus={Boolean(!hideDestinationUrl && !isMobile)}
- disabled={isExactMode}
- onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
- if (isExactMode) return;
-
- e.preventDefault();
- // if pasting in a URL, extract the pathname + query params
- const text = e.clipboardData.getData("text/plain");
- let newValue: string;
- try {
- const url = new URL(text);
- newValue = url.pathname.slice(1) + url.search;
- } catch (err) {
- newValue = text;
- }
-
- // Use setValue to properly dirty the form
- setValue("pathname", newValue, { shouldDirty: true });
- }}
- className={cn(
- "z-0 block w-full rounded-r-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:z-[1] focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
- {
- "cursor-not-allowed border bg-neutral-100 text-neutral-500":
- isExactMode,
- },
- )}
- />
+ )}
</div>
+ <input
+ {...register("pathname", { required: false })}
+ type="text"
+ placeholder="(optional)"
+ autoFocus={Boolean(
+ !link?.partnerGroupDefaultLinkId && !isMobile,
+ )}
+ disabled={Boolean(
+ isExactMode || link?.partnerGroupDefaultLinkId,
+ )}
+ onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
+ if (isExactMode || link?.partnerGroupDefaultLinkId) return;
+
+ e.preventDefault();
+ // if pasting in a URL, extract the pathname + query params
+ const text = e.clipboardData.getData("text/plain");
+ let newValue: string;
+ try {
+ const url = new URL(text);
+ newValue = url.pathname.slice(1) + url.search;
+ } catch (err) {
+ newValue = text;
+ }
+
+ // Use setValue to properly dirty the form
+ setValue("pathname", newValue, { shouldDirty: true });
+ }}
+ className={cn(
+ "z-0 block w-full rounded-r-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:z-[1] focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ {
+ "cursor-not-allowed border bg-neutral-100 text-neutral-500":
+ isExactMode || link?.partnerGroupDefaultLinkId,
+ },
+ )}
+ />
</div>
- )}
+ </div>
<div>
<div className="flex items-center gap-2">