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 button text alignment

Tim Wilson1c5aed9340d8
diff --git a/apps/web/ui/modals/import-csv-modal/field-mapping.tsx b/apps/web/ui/modals/import-csv-modal/field-mapping.tsx
index 34005a3e97..6f0bf43b30 100644
--- a/apps/web/ui/modals/import-csv-modal/field-mapping.tsx
+++ b/apps/web/ui/modals/import-csv-modal/field-mapping.tsx
@@ -163,6 +163,7 @@ function FieldRow({
<Button
variant="secondary"
className="h-9 min-w-0 px-3"
+ textWrapperClassName="grow text-left"
onClick={() => setIsOpen((o) => !o)}
disabled={isLoading}
text={
diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx
index b333457bd5..22cfcaa42f 100644
--- a/packages/ui/src/button.tsx
+++ b/packages/ui/src/button.tsx
@@ -31,6 +31,7 @@ export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
text?: ReactNode | string;
+ textWrapperClassName?: string;
loading?: boolean;
icon?: ReactNode;
shortcut?: string;
@@ -43,6 +44,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
text,
variant = "primary",
className,
+ textWrapperClassName,
loading,
icon,
shortcut,
@@ -56,7 +58,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
<Tooltip content={disabledTooltip}>
<div
className={cn(
- "flex h-10 w-full cursor-not-allowed items-center justify-center gap-x-2 rounded-md border border-gray-200 bg-gray-100 px-4 text-left text-sm text-gray-400 transition-all focus:outline-none",
+ "flex h-10 w-full cursor-not-allowed items-center justify-center gap-x-2 rounded-md border border-gray-200 bg-gray-100 px-4 text-sm text-gray-400 transition-all focus:outline-none",
{
"border-transparent bg-transparent":
variant?.endsWith("outline"),
@@ -67,7 +69,11 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
{icon}
{text && (
<div
- className={cn("min-w-0 grow truncate", shortcut && "flex-1")}
+ className={cn(
+ "min-w-0 truncate",
+ shortcut && "flex-1 text-left",
+ textWrapperClassName,
+ )}
>
{text}
</div>
@@ -94,7 +100,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
// if onClick is passed, it's a "button" type, otherwise it's being used in a form, hence "submit"
type={props.onClick ? "button" : "submit"}
className={cn(
- "group flex h-10 w-full items-center justify-center gap-2 whitespace-nowrap rounded-md border px-4 text-left text-sm",
+ "group flex h-10 w-full items-center justify-center gap-2 whitespace-nowrap rounded-md border px-4 text-sm",
props.disabled || loading
? "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"
: buttonVariants({ variant }),
@@ -105,7 +111,13 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
>
{loading ? <LoadingSpinner /> : icon ? icon : null}
{text && (
- <div className={cn("min-w-0 grow truncate", shortcut && "flex-1")}>
+ <div
+ className={cn(
+ "min-w-0 truncate",
+ shortcut && "flex-1 text-left",
+ textWrapperClassName,
+ )}
+ >
{text}
</div>
)}