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 UI fixes

Steven Teyb1c78de798c5
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index 848d1ca967..48fea11ea4 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -15,6 +15,7 @@ import Tooltip, { TooltipContent } from "#/ui/tooltip";
import useProject from "#/lib/swr/use-project";
import { LinkProps } from "#/lib/types";
import {
+ cn,
fetcher,
getApexDomain,
linkConstructor,
@@ -217,11 +218,14 @@ export default function LinkCard({ props }: { props: LinkProps }) {
) : (
<a
onClick={(e) => {
- e.stopPropagation();
+ e.stopPropagation(); // to avoid selecting the link card
}}
- className={`truncate text-sm font-semibold ${
- archived ? "text-gray-500" : "text-blue-800"
- } w-full max-w-[200px] sm:text-base`}
+ className={cn(
+ "w-full max-w-[170px] truncate text-sm font-semibold text-blue-800 sm:max-w-[300px] sm:text-base md:max-w-[360px] xl:max-w-[500px]",
+ {
+ "text-gray-500": archived,
+ },
+ )}
href={linkConstructor({ key, domain })}
target="_blank"
rel="noreferrer"
@@ -242,7 +246,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
}}
className="transition-all duration-75 hover:scale-105 active:scale-100"
>
- <TagBadge {...tag} withIcon />
+ <TagBadge {...tag} withIcon hideTextOnMobile />
</button>
)}
</div>
@@ -251,7 +255,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
{timeAgo(createdAt)}
</p>
<p>•</p>
- <p className="max-w-[200px] truncate text-sm font-medium text-gray-700 md:max-w-md xl:max-w-[30rem]">
+ <p className="max-w-[180px] truncate text-sm font-medium text-gray-700 sm:max-w-[300px] md:max-w-[360px] xl:max-w-[500px]">
{url}
</p>
</div>
diff --git a/components/app/links/tag-badge.tsx b/components/app/links/tag-badge.tsx
index eb080ad1f6..509f4a1c19 100644
--- a/components/app/links/tag-badge.tsx
+++ b/components/app/links/tag-badge.tsx
@@ -6,16 +6,19 @@ export default function TagBadge({
name,
color,
withIcon,
+ hideTextOnMobile,
}: {
name: string;
color: TagColorProps;
withIcon?: boolean;
+ hideTextOnMobile?: boolean;
}) {
return (
<span
className={cn(
"my-auto whitespace-nowrap rounded-md px-2 py-0.5 text-sm",
withIcon && "flex items-center space-x-1.5",
+ hideTextOnMobile && "rounded-full p-1.5",
color === "red" && "bg-red-100 text-red-600",
color === "yellow" && "bg-yellow-100 text-yellow-600",
color === "green" && "bg-green-100 text-green-600",
@@ -25,7 +28,9 @@ export default function TagBadge({
)}
>
{withIcon && <Tag className="h-3 w-3" />}
- <p>{truncate(name || "", 15)}</p>
+ <p {...(hideTextOnMobile && { className: "hidden sm:inline-block" })}>
+ {truncate(name || "", 15)}
+ </p>
</span>
);
}
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 60207e42c8..cd4347cb07 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -18,6 +18,7 @@ import Tooltip, { TooltipContent } from "#/ui/tooltip";
import useProject from "#/lib/swr/use-project";
import { LinkProps } from "#/lib/types";
import {
+ cn,
getApexDomain,
getQueryString,
getUrlWithoutUTMParams,
@@ -286,7 +287,7 @@ function AddEditLinkModal({
width={20}
height={20}
/>
- <h3 className="text-lg font-medium">
+ <h3 className="max-w-sm truncate text-lg font-medium">
{props
? `Edit ${linkConstructor({
key: props.key,
@@ -463,39 +464,40 @@ function AddEditLinkModal({
</option>
))}
</select>
- {props && lockKey ? (
- <div className="block w-full cursor-not-allowed select-none rounded-r-md border border-gray-300 bg-gray-100 px-3 py-2 text-sm text-gray-500">
- {props.key}
- </div>
- ) : (
- <input
- type="text"
- name="key"
- id={`key-${randomIdx}`}
- required
- pattern="[\p{L}\p{N}\p{Pd}\/]+"
- onInvalid={(e) => {
- e.currentTarget.setCustomValidity(
- "Only letters, numbers, '-', and '/' are allowed.",
- );
- }}
- autoComplete="off"
- className={`${
- keyError
- ? "border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
- } block w-full rounded-r-md pr-10 text-sm focus:outline-none`}
- placeholder="github"
- value={key}
- onChange={(e) => {
- setKeyError(null);
- e.currentTarget.setCustomValidity("");
- setData({ ...data, key: e.target.value });
- }}
- aria-invalid="true"
- aria-describedby="key-error"
- />
- )}
+ <input
+ type="text"
+ name="key"
+ id={`key-${randomIdx}`}
+ required
+ pattern="[\p{L}\p{N}\p{Pd}\/]+"
+ onInvalid={(e) => {
+ e.currentTarget.setCustomValidity(
+ "Only letters, numbers, '-', and '/' are allowed.",
+ );
+ }}
+ disabled={props && lockKey}
+ autoComplete="off"
+ className={cn(
+ "block w-full rounded-r-md text-sm focus:outline-none",
+ {
+ "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":
+ keyError,
+ "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500":
+ !keyError,
+ "cursor-not-allowed border border-gray-300 bg-gray-100 text-gray-500":
+ props && lockKey,
+ },
+ )}
+ placeholder="github"
+ value={key}
+ onChange={(e) => {
+ setKeyError(null);
+ e.currentTarget.setCustomValidity("");
+ setData({ ...data, key: e.target.value });
+ }}
+ aria-invalid="true"
+ aria-describedby="key-error"
+ />
{keyError && (
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
<AlertCircleFill
diff --git a/components/layout/app/index.tsx b/components/layout/app/index.tsx
index 883e7510db..1c54d61441 100644
--- a/components/layout/app/index.tsx
+++ b/components/layout/app/index.tsx
@@ -11,6 +11,7 @@ import { Crisp } from "crisp-sdk-web";
import { useSession } from "next-auth/react";
import ProBanner from "./pro-banner";
import Cookies from "js-cookie";
+import { linkConstructor } from "#/lib/utils";
const NavTabs = dynamic(() => import("./nav-tabs"), {
ssr: false,
@@ -98,7 +99,11 @@ export default function AppLayout({
}
className="text-sm font-medium"
>
- {domain || "dub.sh"}/{key}
+ {linkConstructor({
+ domain: domain || "dub.sh",
+ key,
+ pretty: true,
+ })}
</Link>
</>
)}
diff --git a/components/layout/app/project-select.tsx b/components/layout/app/project-select.tsx
index 5247032920..9f2187f869 100644
--- a/components/layout/app/project-select.tsx
+++ b/components/layout/app/project-select.tsx
@@ -72,7 +72,7 @@ export default function ProjectSelect() {
>
<button
onClick={() => setOpenPopover(!openPopover)}
- className="flex items-center justify-between rounded-lg bg-white p-1.5 text-left text-sm transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200 sm:w-60"
+ className="flex items-center justify-between rounded-lg bg-white p-1.5 text-left text-sm transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200"
>
<div className="flex items-center space-x-3 pr-2">
<BlurImage
@@ -85,9 +85,9 @@ export default function ProjectSelect() {
<div
className={`${
key ? "hidden" : "flex"
- } w-28 items-center space-x-3 sm:flex sm:w-40`}
+ } items-center space-x-3 sm:flex`}
>
- <span className="truncate whitespace-nowrap text-sm font-medium">
+ <span className="inline-block max-w-[100px] truncate text-sm font-medium sm:max-w-[200px]">
{selected.name}
</span>
{selected.slug !== "/" && <PlanBadge plan={selected.plan} />}