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.

Create Email modal

Tim Wilsonfd9f35869398
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/emails/create-email-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/emails/create-email-button.tsx
index 2ae2e372a7..32c4871f66 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/emails/create-email-button.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/emails/create-email-button.tsx
@@ -1,19 +1,106 @@
"use client";
-import { Button, useKeyboardShortcut } from "@dub/ui";
-import { toast } from "sonner";
+import useWorkspace from "@/lib/swr/use-workspace";
+import {
+ Button,
+ Megaphone,
+ Modal,
+ PaperPlane,
+ useKeyboardShortcut,
+ Workflow,
+} from "@dub/ui";
+import { cn } from "@dub/utils";
+import Link from "next/link";
+import { Dispatch, SetStateAction, useState } from "react";
export function CreateEmailButton() {
- useKeyboardShortcut("c", () => toast.info("WIP"));
+ const [isOpen, setIsOpen] = useState(false);
+
+ useKeyboardShortcut("c", () => setIsOpen(true));
return (
<>
+ <CreateEmailModal isOpen={isOpen} setIsOpen={setIsOpen} />
<Button
type="button"
- onClick={() => toast.info("WIP")}
+ onClick={() => setIsOpen(true)}
text="Create email"
shortcut="C"
/>
</>
);
}
+
+const emailTypes = [
+ {
+ type: "campaign",
+ icon: Megaphone,
+ name: "Campaign",
+ description: "Sent once manually",
+ colorClassName: "text-blue-700 bg-blue-100",
+ },
+ {
+ type: "automation",
+ icon: Workflow,
+ name: "Automation",
+ description: "Triggered by an event",
+ colorClassName: "text-green-700 bg-green-100",
+ },
+];
+
+function CreateEmailModal({
+ isOpen,
+ setIsOpen,
+}: {
+ isOpen: boolean;
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
+}) {
+ const { slug: workspaceSlug } = useWorkspace();
+
+ return (
+ <Modal showModal={isOpen} setShowModal={setIsOpen} className="sm:max-w-lg">
+ <div className="p-4 sm:p-8">
+ <div className="flex flex-col gap-6">
+ <div className="border-border-subtle flex size-12 items-center justify-center rounded-full border">
+ <PaperPlane className="text-content-default size-4" />
+ </div>
+
+ <div>
+ <h2 className="text-content-emphasis text-lg font-semibold">
+ Create email
+ </h2>
+ <p className="text-content-subtle text-base">
+ Select the type of email to create
+ </p>
+ </div>
+
+ <div className="xs:grid-cols-2 grid grid-cols-1 gap-4">
+ {emailTypes.map(
+ ({ type, icon: Icon, name, description, colorClassName }) => (
+ <Link
+ key={type}
+ href={`/${workspaceSlug}/program/communication/emails/new?type=${type}`}
+ className="border-border-subtle flex flex-col items-center gap-5 rounded-xl border px-2 py-6 transition-[background-color,transform] hover:bg-neutral-50 active:scale-[0.98]"
+ >
+ <div
+ className={cn(
+ "flex size-12 items-center justify-center rounded-lg",
+ colorClassName,
+ )}
+ >
+ <Icon className="size-5" />
+ </div>
+
+ <div className="text-content-default text-center">
+ <span className="text-sm font-semibold">{name}</span>
+ <p className="text-xs">{description}</p>
+ </div>
+ </Link>
+ ),
+ )}
+ </div>
+ </div>
+ </div>
+ </Modal>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 278e21e0c0..988b4eef6a 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -149,6 +149,7 @@ export * from "./lock-fill";
export * from "./magnifier";
export * from "./map-position";
export * from "./marketing-target";
+export * from "./megaphone";
export * from "./menu3";
export * from "./message-smile";
export * from "./microphone-fill";
@@ -227,4 +228,5 @@ export * from "./webhook";
export * from "./window";
export * from "./window-search";
export * from "./window-settings";
+export * from "./workflow";
export * from "./xmark";
diff --git a/packages/ui/src/icons/nucleo/megaphone.tsx b/packages/ui/src/icons/nucleo/megaphone.tsx
new file mode 100644
index 0000000000..2d527d1d44
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/megaphone.tsx
@@ -0,0 +1,48 @@
+import { SVGProps } from "react";
+
+export function Megaphone(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <path
+ d="M3.75,11.457v2.704c0,.41,.25,.778,.631,.929l1.945,.773c.4,.159,.856,.044,1.134-.284l1.666-1.979"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M12.954,15.125L2.61,11.002c-.256-.099-.457-.296-.564-.549-.148-.35-.296-.847-.296-1.453,0-.271,.03-.817,.289-1.436,.108-.257,.313-.466,.573-.566,3.638-1.409,6.704-2.715,10.342-4.124"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M14.5,9c0-.828-.672-1.5-1.5-1.5-.053,0-.103,.01-.155,.016-.058,.452-.095,.945-.095,1.484s.037,1.032,.095,1.484c.052,.005,.102,.016,.155,.016,.828,0,1.5-.672,1.5-1.5Z"
+ fill="currentColor"
+ stroke="none"
+ />
+ <ellipse
+ cx="13.5"
+ cy="9"
+ fill="none"
+ rx="2.75"
+ ry="6.25"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/workflow.tsx b/packages/ui/src/icons/nucleo/workflow.tsx
new file mode 100644
index 0000000000..ac25a8792b
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/workflow.tsx
@@ -0,0 +1,42 @@
+import { SVGProps } from "react";
+
+export function Workflow(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <path
+ d="m8.25,4.75c1.1046,0,2,.8954,2,2v4.5c0,1.1046.8954,2,2,2h3.75"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="3.75"
+ cy="4.75"
+ fill="none"
+ r="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <polyline
+ fill="none"
+ points="13.5 10.5 16.25 13.25 13.5 16"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}