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.

Rework group settings layout

Tim Wilson46e52050b6c5
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx
index 67fc97ba94..7b4cbaf875 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-settings.tsx
@@ -18,6 +18,7 @@ import { useRouter } from "next/navigation";
import { Controller, useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
+import { SettingsRow } from "./settings-row";
type FormData = z.input<typeof updateGroupSchema>;
@@ -69,133 +70,112 @@ function GroupSettingsForm({ group }: { group: GroupProps }) {
return (
<form
onSubmit={handleSubmit(onSubmit)}
- className="rounded-lg border border-neutral-200"
+ className="border-border-subtle rounded-lg border"
>
- <div className="px-5 py-5">
- <h2 className="mb-4 text-base font-bold text-neutral-900">Settings</h2>
- <div className="space-y-6">
- <div>
- <label
- htmlFor="name"
- className="text-sm font-medium text-neutral-800"
- >
- Group name
- </label>
- <div className="mt-2">
- <div className="relative">
- <input
- type="text"
- id="name"
- className={cn(
- "block w-full rounded-md border-neutral-300 px-3 py-2 pr-12 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
- errors.name &&
- "border-red-600 focus:border-red-500 focus:ring-red-600",
- )}
- {...register("name", {
- required: true,
- })}
- onChange={(e) => {
- const name = e.target.value;
- setValue("name", name, { shouldDirty: true });
-
- if (group.slug !== DEFAULT_PARTNER_GROUP.slug) {
- setValue("slug", slugify(name), { shouldDirty: true });
- }
- }}
- placeholder="Group name"
- />
- <div className="absolute inset-y-0 right-0 flex items-center pr-2.5">
- <Controller
- control={control}
- name="color"
- render={({ field }) => (
- <GroupColorPicker
- color={field.value}
- onChange={field.onChange}
- />
- )}
+ <div className="flex flex-col divide-y divide-neutral-200">
+ <div className="px-6 py-6">
+ <h3 className="text-content-emphasis text-lg font-semibold leading-7">
+ Group
+ </h3>
+ </div>
+ <SettingsRow
+ heading="Name"
+ description="For internal use only, never visible to partners"
+ >
+ <div className="relative">
+ <input
+ type="text"
+ id="name"
+ className={cn(
+ "block w-full rounded-md border-neutral-300 px-3 py-2 pr-12 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ errors.name &&
+ "border-red-600 focus:border-red-500 focus:ring-red-600",
+ )}
+ {...register("name", {
+ required: true,
+ })}
+ onChange={(e) => {
+ const name = e.target.value;
+ setValue("name", name, { shouldDirty: true });
+
+ if (group.slug !== DEFAULT_PARTNER_GROUP.slug) {
+ setValue("slug", slugify(name), { shouldDirty: true });
+ }
+ }}
+ placeholder="Group name"
+ />
+ <div className="absolute inset-y-0 right-0 flex items-center pr-2.5">
+ <Controller
+ control={control}
+ name="color"
+ render={({ field }) => (
+ <GroupColorPicker
+ color={field.value}
+ onChange={field.onChange}
/>
- </div>
- </div>
-
- <p className="mt-2 text-xs text-neutral-500">
- For internal use only, never visible to partners
- </p>
+ )}
+ />
</div>
</div>
-
- {group.slug !== DEFAULT_PARTNER_GROUP.slug && (
- <div>
- <label
- htmlFor="slug"
- className="text-sm font-medium text-neutral-800"
+ </SettingsRow>
+
+ {group.slug !== DEFAULT_PARTNER_GROUP.slug && (
+ <SettingsRow
+ heading="Group slug"
+ description="For program landing page and internal group page URLs"
+ >
+ <input
+ type="text"
+ id="slug"
+ className={cn(
+ "block w-full rounded-md border border-neutral-300 px-3 py-2 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ errors.slug &&
+ "border-red-600 focus:border-red-500 focus:ring-red-600",
+ )}
+ {...register("slug", {
+ required: true,
+ })}
+ placeholder="group-name"
+ />
+ </SettingsRow>
+ )}
+
+ <SettingsRow
+ heading="Group ID"
+ description={
+ <>
+ For setting up the Dub embedded referral dashboard within your
+ app.{" "}
+ <Link
+ href="https://dub.co/docs/partners/embedded-referrals"
+ target="_blank"
+ className="underline"
>
- Group slug
- </label>
- <div className="mt-2">
- <input
- type="text"
- id="slug"
- className={cn(
- "block w-full rounded-md border border-neutral-300 px-3 py-2 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
- errors.slug &&
- "border-red-600 focus:border-red-500 focus:ring-red-600",
- )}
- {...register("slug", {
- required: true,
- })}
- placeholder="group-name"
- />
-
- <p className="mt-2 text-xs text-neutral-500">
- For program landing page and internal group page URLs
- </p>
- </div>
- </div>
- )}
-
- <div>
- <label
- htmlFor="slug"
- className="text-sm font-medium text-neutral-800"
- >
- Group ID
- </label>
- <div className="mt-2">
- <div className="relative">
- <input
- type="text"
- readOnly
- className="block w-full rounded-md border border-neutral-300 bg-neutral-100 px-3 py-2 pr-12 font-mono text-sm text-neutral-600 focus:border-neutral-300 focus:ring-0"
- defaultValue={group.id}
- />
- <div className="absolute inset-y-0 right-0 flex items-center pr-2.5">
- <CopyButton
- value={group.id}
- onCopy={() => {
- toast.success("Group ID copied to clipboard!");
- }}
- />
- </div>
- </div>
-
- <p className="mt-2 text-xs text-neutral-500">
- For setting up the Dub embedded referral dashboard within your
- app.{" "}
- <Link
- href="https://dub.co/docs/partners/embedded-referrals"
- target="_blank"
- className="underline"
- >
- Learn more
- </Link>
- </p>
+ Learn more
+ </Link>
+ </>
+ }
+ >
+ <div className="relative">
+ <input
+ type="text"
+ readOnly
+ className="block w-full rounded-md border border-neutral-300 bg-neutral-100 px-3 py-2 pr-12 font-mono text-sm text-neutral-600 focus:border-neutral-300 focus:ring-0"
+ defaultValue={group.id}
+ />
+ <div className="absolute inset-y-0 right-0 flex items-center pr-2.5">
+ <CopyButton
+ value={group.id}
+ onCopy={() => {
+ toast.success("Group ID copied to clipboard!");
+ }}
+ />
</div>
</div>
- </div>
+ </SettingsRow>
</div>
- <div className="flex items-center justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-6 py-5">
+ <div className="border-border-subtle flex items-center justify-end rounded-b-lg border-t bg-neutral-50 px-6 py-4">
<div>
<Button
text="Save changes"
@@ -211,7 +191,7 @@ function GroupSettingsForm({ group }: { group: GroupProps }) {
function GroupSettingsFormSkeleton() {
return (
- <div className="rounded-lg border border-neutral-200">
+ <div className="border-border-subtle rounded-lg border">
<div className="px-5 py-5">
<div className="mb-4 h-6 w-20 animate-pulse rounded bg-neutral-200" />
<div className="space-y-6 py-2">
@@ -249,7 +229,7 @@ function GroupSettingsFormSkeleton() {
</div>
</div>
- <div className="flex items-center justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-6 py-5">
+ <div className="border-border-subtle flex items-center justify-end rounded-b-lg border-t bg-neutral-50 px-6 py-5">
<div className="h-8 w-28 animate-pulse rounded bg-neutral-200" />
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/settings-row.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/settings-row.tsx
new file mode 100644
index 0000000000..8749c77f35
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/settings-row.tsx
@@ -0,0 +1,23 @@
+import { PropsWithChildren, ReactNode } from "react";
+
+export function SettingsRow({
+ heading,
+ description,
+ children,
+}: PropsWithChildren<{
+ heading: string;
+ description: ReactNode;
+}>) {
+ return (
+ <div className="grid grid-cols-1 gap-10 px-6 py-8 sm:grid-cols-2">
+ <div className="flex flex-col gap-1">
+ <h3 className="text-content-emphasis text-base font-semibold leading-none">
+ {heading}
+ </h3>
+ <p className="text-content-subtle text-sm">{description}</p>
+ </div>
+
+ <div>{children}</div>
+ </div>
+ );
+}