Skip to content

Commit

Permalink
feat: cleanup onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed May 27, 2024
1 parent 4e67054 commit 7e392e5
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 44 deletions.
23 changes: 8 additions & 15 deletions src/app/(dashboard)/onboarding/_components/connect-stripe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { motion } from "framer-motion"
import { Button } from "@/components/ui/button"
import { ConnectStoreToStripeButton } from "@/components/connect-store-to-stripe-button"

import { StepHeader } from "./step-header"

interface ConnectStripeProps {
storeId: string | null
}
Expand Down Expand Up @@ -36,24 +38,15 @@ export function ConnectStripe({ storeId }: ConnectStripeProps) {
}}
initial="hidden"
animate="show"
className="flex flex-col rounded-xl bg-background/60 p-8"
className="flex flex-col space-y-6 rounded-xl bg-background/60 p-8"
>
<motion.h1
className="mb-4 text-balance text-2xl font-bold transition-colors sm:text-3xl"
variants={{
hidden: { opacity: 0, x: 250 },
show: {
opacity: 1,
x: 0,
transition: { duration: 0.4, type: "spring" },
},
}}
>
Now let&apos;s connect your store to Stripe
</motion.h1>
<StepHeader
title="Now let's connect your store to Stripe"
description="Connect your store to Stripe to start accepting payments"
/>
{storeId && (
<motion.div
className="flex flex-col-reverse gap-2 pt-2.5 sm:flex-row sm:justify-end"
className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"
variants={{
hidden: { opacity: 0, x: 100 },
show: {
Expand Down
21 changes: 6 additions & 15 deletions src/app/(dashboard)/onboarding/_components/create-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Button } from "@/components/ui/button"
import { Icons } from "@/components/icons"

import { CreateStoreForm } from "../../store/[storeId]/_components/create-store-form"
import { StepHeader } from "./step-header"

interface CreateStoreProps {
userId: string
Expand Down Expand Up @@ -56,7 +57,6 @@ export function CreateStore({ userId }: CreateStoreProps) {

return (
<motion.div
className="my-auto flex size-full flex-col items-center justify-center"
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.3, type: "spring" }}
>
Expand All @@ -70,21 +70,12 @@ export function CreateStore({ userId }: CreateStoreProps) {
}}
initial="hidden"
animate="show"
className="flex flex-col rounded-xl bg-background/60 p-8"
className="flex flex-col space-y-4 rounded-xl bg-background/60 p-8"
>
<motion.h1
className="mb-4 text-balance text-2xl font-bold transition-colors sm:text-3xl"
variants={{
hidden: { opacity: 0, x: 250 },
show: {
opacity: 1,
x: 0,
transition: { duration: 0.4, type: "spring" },
},
}}
>
Let&apos;s start by creating your store
</motion.h1>
<StepHeader
title="Let's start by creating your store"
description="You can update your store name and description later"
/>
<motion.div
variants={{
hidden: { opacity: 0, x: 100 },
Expand Down
1 change: 0 additions & 1 deletion src/app/(dashboard)/onboarding/_components/intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Button } from "@/components/ui/button"

export function Intro() {
const router = useRouter()

const showText = useDebounce(true, 800)

return (
Expand Down
12 changes: 5 additions & 7 deletions src/app/(dashboard)/onboarding/_components/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ export function Onboarding({ userId }: OnboardingProps) {
const storeId = search.get("store")

return (
<div className="mx-auto flex h-[calc(100vh-14rem)] w-full max-w-screen-sm flex-col items-center">
<AnimatePresence mode="wait">
{!step && <Intro key="intro" />}
{step === "create" && <CreateStore userId={userId} />}
{step === "connect" && <ConnectStripe storeId={storeId} />}
</AnimatePresence>
</div>
<AnimatePresence mode="wait">
{!step && <Intro key="intro" />}
{step === "create" && <CreateStore userId={userId} />}
{step === "connect" && <ConnectStripe storeId={storeId} />}
</AnimatePresence>
)
}
31 changes: 31 additions & 0 deletions src/app/(dashboard)/onboarding/_components/step-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { motion } from "framer-motion"

interface StepHeaderProps {
title: string
description?: string
}

export function StepHeader({ title, description }: StepHeaderProps) {
return (
<motion.div
variants={{
hidden: { opacity: 0, x: 250 },
show: {
opacity: 1,
x: 0,
transition: { duration: 0.4, type: "spring" },
},
}}
className="w-full space-y-1.5"
>
<h1 className="text-pretty text-2xl font-bold transition-colors sm:text-3xl">
{title}
</h1>
{description ? (
<p className="text-pretty text-sm text-muted-foreground transition-colors sm:text-base">
You can update your store name and description later
</p>
) : null}
</motion.div>
)
}
17 changes: 15 additions & 2 deletions src/app/(dashboard)/onboarding/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from "react"
import { type Metadata } from "next"
import { redirect } from "next/navigation"
import { auth } from "@clerk/nextjs/server"

import { Skeleton } from "@/components/ui/skeleton"
import { GridPattern } from "@/components/grid-pattern"
import { Shell } from "@/components/shell"

import { Onboarding } from "./_components/onboarding"
Expand All @@ -19,8 +22,18 @@ export default function OnboardingPage() {
}

return (
<Shell>
<Onboarding userId={userId} />
<Shell className="h-[calc(100vh-4rem)] max-w-screen-sm">
<GridPattern
width={30}
height={30}
x={-1}
y={-1}
strokeDasharray={"4 2"}
className="[mask-image:radial-gradient(300px_circle_at_left_top,white,transparent)]"
/>
<React.Suspense fallback={<Skeleton className="size-full" />}>
<Onboarding userId={userId} />
</React.Suspense>
</Shell>
)
}
6 changes: 3 additions & 3 deletions src/app/(dashboard)/store/[storeId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { stores } from "@/db/schema"
import { env } from "@/env.js"
import { eq } from "drizzle-orm"

import { deleteStore, updateStore } from "@/lib/actions/store"
import { updateStore } from "@/lib/actions/store"
import { getStripeAccount } from "@/lib/actions/stripe"
import { cn, formatDate } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
Expand Down Expand Up @@ -205,14 +205,14 @@ export default async function DashboardStorePage({
Update store
<span className="sr-only">Update store</span>
</LoadingButton>
<LoadingButton
{/* <LoadingButton
formAction={deleteStore.bind(null, store.id)}
variant="destructive"
action="delete"
>
Delete store
<span className="sr-only">Delete store</span>
</LoadingButton>
</LoadingButton> */}
</div>
</form>
</CardContent>
Expand Down
65 changes: 65 additions & 0 deletions src/components/grid-pattern.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as React from "react"

import { cn } from "@/lib/utils"

interface GridPatternProps extends React.SVGProps<SVGSVGElement> {
squares?: Array<[x: number, y: number]>
width?: number
height?: number
}

export function GridPattern({
width = 40,
height = 40,
x = -1,
y = -1,
strokeDasharray = 0,
squares,
className,
...props
}: GridPatternProps) {
const id = React.useId()

return (
<svg
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 size-full fill-gray-400/30 stroke-gray-400/30",
className
)}
{...props}
>
<defs>
<pattern
id={id}
width={width}
height={height}
patternUnits="userSpaceOnUse"
x={x}
y={y}
>
<path
d={`M.5 ${height}V.5H${width}`}
fill="none"
strokeDasharray={strokeDasharray}
/>
</pattern>
</defs>
<rect width="100%" height="100%" strokeWidth={0} fill={`url(#${id})`} />
{squares && (
<svg x={x} y={y} className="overflow-visible">
{squares.map(([x, y]) => (
<rect
strokeWidth="0"
key={`${x}-${y}`}
width={width - 1}
height={height - 1}
x={x * width + 1}
y={y * height + 1}
/>
))}
</svg>
)}
</svg>
)
}
2 changes: 1 addition & 1 deletion src/components/layouts/auth-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function AuthDropdown({
fallback={
<div className="flex flex-col space-y-1.5 p-1">
{Array.from({ length: 3 }).map((_, i) => (
<Skeleton key={i} className="h-6 w-full" />
<Skeleton key={i} className="h-6 w-full rounded-sm" />
))}
</div>
}
Expand Down
68 changes: 68 additions & 0 deletions src/components/radial-gradient.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { cn } from "@/lib/utils"

type Type = "circle" | "ellipse"

type Origin =
| "center"
| "top"
| "bottom"
| "left"
| "right"
| "top left"
| "top right"
| "bottom left"
| "bottom right"

interface RadialGradientProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* The type of radial gradient
* @default circle
* @type string
*/
type?: Type
/**
* The color to transition from
* @default #00000000
* @type string
* */
from?: string

/**
* The color to transition to
* @default #290A5C
* @type string
* */
to?: string

/**
* The size of the gradient in pixels
* @default 300
* @type number
* */
size?: number

/**
* The origin of the gradient
* @default center
* @type string
* */
origin?: Origin
}

export function RadialGradient({
type = "circle",
from = "hsla(241, 41%, 62%, 0.3)",
to = "hsla(0, 0%, 0%, 0)",
size = 300,
origin = "center",
className,
}: RadialGradientProps) {
const styles: React.CSSProperties = {
position: "absolute",
pointerEvents: "none",
inset: 0,
backgroundImage: `radial-gradient(${type} ${size}px at ${origin}, ${from}, ${to})`,
}

return <div className={cn(className)} style={styles} />
}

0 comments on commit 7e392e5

Please sign in to comment.