The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
WIP earnings calculator block
Tim Wilson40fd1f1cc7b1
diff --git a/apps/web/lib/zod/schemas/program-lander.ts b/apps/web/lib/zod/schemas/program-lander.tsindex 067d8c512c..a0705ba519 100644--- a/apps/web/lib/zod/schemas/program-lander.ts+++ b/apps/web/lib/zod/schemas/program-lander.ts@@ -58,11 +58,20 @@ export const programLanderAccordionBlockSchema =}),});+export const programLanderEarningsCalculatorBlockSchema =+ programLanderBlockCommonSchema.extend({+ type: z.literal("earnings-calculator"),+ data: z.object({+ productPrice: z.number(),+ }),+ });+export const programLanderBlockSchema = z.discriminatedUnion("type", [programLanderImageBlockSchema,programLanderTextBlockSchema,programLanderFilesBlockSchema,programLanderAccordionBlockSchema,+ programLanderEarningsCalculatorBlockSchema,]);export const programLanderSchema = z.object({diff --git a/apps/web/ui/partners/design/modals/add-block-modal.tsx b/apps/web/ui/partners/design/modals/add-block-modal.tsxindex ea7dfaf677..7384edb926 100644--- a/apps/web/ui/partners/design/modals/add-block-modal.tsx+++ b/apps/web/ui/partners/design/modals/add-block-modal.tsx@@ -1,8 +1,9 @@"use client";import { programLanderBlockSchema } from "@/lib/zod/schemas/program-lander";-import { Modal } from "@dub/ui";-import { Dispatch, Fragment, SetStateAction, useState } from "react";+import { Calculator, Icon, Modal } from "@dub/ui";+import { cn } from "@dub/utils";+import { Dispatch, Fragment, ReactNode, SetStateAction, useState } from "react";import { useWatch } from "react-hook-form";import { v4 as uuid } from "uuid";import { z } from "zod";@@ -32,13 +33,15 @@ export function AddBlockModal(props: AddBlockModalProps) {);}-export const DESIGNER_BLOCKS: {+export const DESIGNER_BLOCKS: ({id: z.infer<typeof programLanderBlockSchema>["type"];label: string;description: string;modal: React.ComponentType<any>;- thumbnail: React.ReactNode;-}[] = [+} & (+ | { icon: Icon; thumbnail?: never }+ | { thumbnail: ReactNode; icon?: never }+))[] = [{id: "text",label: "Text",@@ -67,6 +70,13 @@ export const DESIGNER_BLOCKS: {modal: AccordionBlockModal,thumbnail: <AccordionBlockThumbnail />,},+ {+ id: "earnings-calculator",+ label: "Earnings Calculator",+ description: "Calculate potential earnings for your program",+ modal: TextBlockModal,+ icon: Calculator,+ },];function AddBlockModalInner({@@ -74,7 +84,7 @@ function AddBlockModalInner({addIndex,}: AddBlockModalProps) {const [modalState, setModalState] = useState<- null | "text" | "image" | "files" | "accordion"+ null | z.infer<typeof programLanderBlockSchema>["type"]>(null);const { control, setValue } = useBrandingFormContext();@@ -116,11 +126,20 @@ function AddBlockModalInner({<buttontype="button"onClick={() => setModalState(block.id)}- className="flex flex-col gap-4 rounded-md border border-transparent bg-neutral-100 p-4 text-left outline-none ring-black/10 transition-all duration-150 hover:border-neutral-800 hover:ring focus-visible:border-neutral-800"+ className={cn(+ "flex flex-col gap-4 rounded-md border border-transparent bg-neutral-100 p-4 text-left outline-none ring-black/10 transition-all duration-150 hover:border-neutral-800 hover:ring focus-visible:border-neutral-800",+ block.icon && "col-span-2 flex-row items-center",+ )}>- <div className="flex h-24 items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white">- {block.thumbnail}- </div>+ {block.icon ? (+ <div className="flex size-12 items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white">+ <block.icon className="size-5 text-neutral-600" />+ </div>+ ) : (+ <div className="flex h-24 items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white">+ {block.thumbnail}+ </div>+ )}<div className="flex flex-col gap-1"><span className="text-sm font-semibold text-neutral-900">{block.label}diff --git a/packages/ui/src/icons/nucleo/calculator.tsx b/packages/ui/src/icons/nucleo/calculator.tsxnew file mode 100644index 0000000000..164dfc92eb--- /dev/null+++ b/packages/ui/src/icons/nucleo/calculator.tsx@@ -0,0 +1,70 @@+import { SVGProps } from "react";++export function Calculator(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">+ <rect+ height="14.5"+ width="10.5"+ fill="none"+ rx="2"+ ry="2"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x="3.75"+ y="1.75"+ />+ <rect+ height="1"+ width="5.5"+ fill="currentColor"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x="6.25"+ y="4.25"+ />+ <circle cx="6.25" cy="11" fill="currentColor" r=".75" stroke="none" />+ <circle cx="6.25" cy="8.25" fill="currentColor" r=".75" stroke="none" />+ <circle cx="9" cy="8.25" fill="currentColor" r=".75" stroke="none" />+ <circle+ cx="11.75"+ cy="8.25"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle cx="9" cy="11" fill="currentColor" r=".75" stroke="none" />+ <circle+ cx="6.25"+ cy="13.75"+ fill="currentColor"+ r=".75"+ stroke="none"+ />+ <circle cx="9" cy="13.75" fill="currentColor" r=".75" stroke="none" />+ <line+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.5"+ x1="11.75"+ x2="11.75"+ y1="11"+ y2="13.75"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex 330975a310..26dddd36cc 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -22,6 +22,7 @@ export * from "./brackets-curly";export * from "./brush";export * from "./bullet-list";export * from "./bullet-list-fill";+export * from "./calculator";export * from "./calendar";export * from "./calendar-days";export * from "./calendar-refresh";