From 52e27bab536501b3842f1b1826c44f0e41bebab3 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Fri, 7 Nov 2025 07:58:34 +0000 Subject: [PATCH] chore: Add shared onboarding components (OnboardingCard, OnboardingLayout, browser views) (#24946) ## What does this PR do? Creates new onboarding UI components for the user onboarding flow, including: - `OnboardingCard` - A reusable card component with title, subtitle, content, and footer sections - `OnboardingLayout` - A layout component with progress indicators and sign-out functionality - `OnboardingBrowserView` - A browser preview showing how the user's booking page will look - `OnboardingCalendarBrowserView` - A calendar preview showing sample events - `OnboardingInviteBrowserView` - A preview of the team invitation email - Enhanced `PlanIcon` component with new variants and animations for organization and team plans ## Visual Demo (For contributors especially) #### Image Demo: The PR adds several visual components for the onboarding flow, including browser previews, calendar views, and animated plan icons with concentric rings and user avatars. ## Mandatory Tasks (DO NOT REMOVE) - [x] I have self-reviewed the code. - [x] I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. - [x] I confirm automated tests are in place that prove my fix is effective or that my feature works. ## How should this be tested? - Navigate to the onboarding flow to see the new components in action - Test the layout with different screen sizes to ensure responsive behavior - Verify that the browser previews render correctly with sample data - Check that the plan icon animations work properly for different variants (single, team, organization) - Ensure the calendar view displays sample events correctly ## Checklist - I have read the [contributing guide](https://github.com/calcom/cal.com/blob/main/CONTRIBUTING.md) - My code follows the style guidelines of this project - I have commented my code, particularly in hard-to-understand areas - I have checked if my changes generate no new warnings --- .../onboarding/components/OnboardingCard.tsx | 41 ++++ .../components/OnboardingLayout.tsx | 64 ++++++ .../components/onboarding-browser-view.tsx | 134 +++++++++++ .../onboarding-invite-browser-view.tsx | 67 ++++++ .../onboarding/components/plan-icon.tsx | 209 +++++++++++------- .../getting-started/onboarding-view.tsx | 4 +- 6 files changed, 439 insertions(+), 80 deletions(-) create mode 100644 apps/web/modules/onboarding/components/OnboardingCard.tsx create mode 100644 apps/web/modules/onboarding/components/OnboardingLayout.tsx create mode 100644 apps/web/modules/onboarding/components/onboarding-browser-view.tsx create mode 100644 apps/web/modules/onboarding/components/onboarding-invite-browser-view.tsx diff --git a/apps/web/modules/onboarding/components/OnboardingCard.tsx b/apps/web/modules/onboarding/components/OnboardingCard.tsx new file mode 100644 index 0000000000..72ca7500db --- /dev/null +++ b/apps/web/modules/onboarding/components/OnboardingCard.tsx @@ -0,0 +1,41 @@ +import type { ReactNode } from "react"; + +import { SkeletonText } from "@calcom/ui/components/skeleton"; + +type OnboardingCardProps = { + title: string; + subtitle: string; + children: ReactNode; + footer: ReactNode; + isLoading?: boolean; +}; + +export const OnboardingCard = ({ title, subtitle, children, footer, isLoading }: OnboardingCardProps) => { + return ( +
+ {/* Card Header */} +
+
+

{title}

+

{subtitle}

+
+
+ + {/* Content */} +
+ {isLoading ? ( +
+ + +
+ ) : ( + children + )} +
+ + {/* Footer */} +
{footer}
+
+ ); +}; + diff --git a/apps/web/modules/onboarding/components/OnboardingLayout.tsx b/apps/web/modules/onboarding/components/OnboardingLayout.tsx new file mode 100644 index 0000000000..1a538362f0 --- /dev/null +++ b/apps/web/modules/onboarding/components/OnboardingLayout.tsx @@ -0,0 +1,64 @@ +"use client"; + +import { signOut } from "next-auth/react"; +import { Children, type ReactNode } from "react"; + +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { Button } from "@calcom/ui/components/button"; +import { Logo } from "@calcom/ui/components/logo"; + +type OnboardingLayoutProps = { + userEmail: string; + currentStep: 1 | 2 | 3; + children: ReactNode; +}; + +export const OnboardingLayout = ({ userEmail, currentStep, children }: OnboardingLayoutProps) => { + const { t } = useLocale(); + + const handleSignOut = () => { + signOut({ callbackUrl: "/auth/logout" }); + }; + + // Extract children as array + const childrenArray = Children.toArray(children); + const column1 = childrenArray[0]; + const column2 = childrenArray[1]; + + return ( +
+ {/* Logo and container - centered */} +
+ +
+ {/* Column 1 - Always visible, 40% on xl+ */} +
{column1}
+ {/* Column 2 - Hidden on mobile, visible on xl+, 60% on xl+ */} + {column2 && ( +
{column2}
+ )} +
+
+ + {/* Footer with progress dots and sign out */} +
+
+ {[1, 2, 3].map((step) => ( +
+
+ {step <= currentStep &&
} +
+ ))} +
+ +
+
+ ); +}; + diff --git a/apps/web/modules/onboarding/components/onboarding-browser-view.tsx b/apps/web/modules/onboarding/components/onboarding-browser-view.tsx new file mode 100644 index 0000000000..3736266871 --- /dev/null +++ b/apps/web/modules/onboarding/components/onboarding-browser-view.tsx @@ -0,0 +1,134 @@ +"use client"; + +import { WEBAPP_URL } from "@calcom/lib/constants"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { Avatar } from "@calcom/ui/components/avatar"; +import { Button } from "@calcom/ui/components/button"; +import { Icon, type IconName } from "@calcom/ui/components/icon"; + +type OnboardingBrowserViewProps = { + avatar?: string | null; + name?: string; + bio?: string; + username?: string | null; + teamSlug?: string; +}; + +export const OnboardingBrowserView = ({ + avatar, + name, + bio, + username, + teamSlug, +}: OnboardingBrowserViewProps) => { + const { t } = useLocale(); + const webappUrl = WEBAPP_URL.replace(/^https?:\/\//, ""); + const displayUrl = + teamSlug !== undefined ? `${webappUrl}/team/${teamSlug || ""}` : `${webappUrl}/${username || ""}`; + + const events: Array<{ + title: string; + description: string; + duration: number; + icon: IconName; + }> = [ + { + title: t("onboarding_browser_view_demo"), + description: t("onboarding_browser_view_demo_description"), + duration: 15, + icon: "bell", + }, + { + title: t("onboarding_browser_view_quick_meeting"), + description: t("onboarding_browser_view_quick_meeting_description"), + duration: 15, + icon: "bell", + }, + { + title: t("onboarding_browser_view_longer_meeting"), + description: t("onboarding_browser_view_longer_meeting_description"), + duration: 30, + icon: "clock", + }, + { + title: t("in_person_meeting"), + description: t("onboarding_browser_view_in_person_description"), + duration: 120, + icon: "map-pin", + }, + { + title: t("onboarding_browser_view_ask_question"), + description: t("onboarding_browser_view_ask_question_description"), + duration: 15, + icon: "message-circle", + }, + ]; + return ( +
+ {/* Browser header */} +
+ {/* Navigation buttons */} +
+ + + +
+
+ +

{displayUrl}

+
+ +
+ {/* Content */} +
+
+ {/* Profile Header */} +
+
+ +
+

+ {name || t("your_name")} +

+

+ {bio || t("onboarding_browser_view_default_bio")} +

+
+
+
+ + {/* Events List */} +
+ {events.map((event, index) => ( +
+ {index > 0 &&
} +
+
+
+

{event.title}

+
+ + + {event.duration} {t("minute_timeUnit")} + +
+
+

{event.description}

+
+ +
+
+ ))} +
+
+
+
+ ); +}; diff --git a/apps/web/modules/onboarding/components/onboarding-invite-browser-view.tsx b/apps/web/modules/onboarding/components/onboarding-invite-browser-view.tsx new file mode 100644 index 0000000000..e9ce7747bc --- /dev/null +++ b/apps/web/modules/onboarding/components/onboarding-invite-browser-view.tsx @@ -0,0 +1,67 @@ +"use client"; + +import { trpc } from "@calcom/trpc/react"; +import { Avatar } from "@calcom/ui/components/avatar"; + +import { useOnboardingStore } from "../store/onboarding-store"; + +type OnboardingInviteBrowserViewProps = { + teamName?: string; +}; + +export const OnboardingInviteBrowserView = ({ teamName }: OnboardingInviteBrowserViewProps) => { + const { data: user } = trpc.viewer.me.get.useQuery(); + const { teamBrand } = useOnboardingStore(); + + // Use default values if not provided + const rawInviterName = user?.name || user?.username || "Alex"; + const displayInviterName = rawInviterName.charAt(0).toUpperCase() + rawInviterName.slice(1); + const displayTeamName = teamName || "Deel"; + const teamAvatar = teamBrand.logo || null; + + return ( +
+ {/* Browser header */} +
+ {/* Navigation buttons */} +
+
+
+
+
+
+
+

mail.example.com

+
+
+ + {/* Content */} +
+
+ {/* Email Header */} +
+
+ +
+

+ {displayInviterName} invited you to join {displayTeamName} +

+

+ We're emailing you all the details +

+
+
+
+ + {/* Email Body */} +
+
+
+
+ ); +}; diff --git a/apps/web/modules/onboarding/components/plan-icon.tsx b/apps/web/modules/onboarding/components/plan-icon.tsx index bd04740979..52e9cf8b99 100644 --- a/apps/web/modules/onboarding/components/plan-icon.tsx +++ b/apps/web/modules/onboarding/components/plan-icon.tsx @@ -1,24 +1,68 @@ -import classNames from "@calcom/ui/classNames"; +import { motion } from "framer-motion"; + import { Icon, type IconName } from "@calcom/ui/components/icon"; -export function PlanIcon({ icon, variant = "single" }: { icon: IconName; variant?: "single" | "double" }) { - const renderIconContainer = (index: number) => { - // For double variant: 55px icon width + 24px gap = 79px between centers, so ±39.5px from center - const leftPosition = variant === "double" ? `calc(50% + ${index === 0 ? -39.5 : 39.5}px)` : "50%"; +// Ring sizes - just the diameters, all centered on the icon +const RING_SIZES = [166, 233, 345, 465]; +// Positions for small user icons on rings (for team variant) +// Format: [ringIndex, angleInDegrees] +// Angles: 0 = top, 90 = right, 180 = bottom, 270 = left +const TEAM_ICON_POSITIONS = [ + { ringIndex: 2, angle: 30 }, // Top-right of third ring + { ringIndex: 2, angle: 150 }, // Bottom-left of third ring + { ringIndex: 2, angle: 210 }, // Bottom-left of third ring + { ringIndex: 2, angle: 330 }, // Top-left of third ring + { ringIndex: 3, angle: 0 }, // Top of largest ring + { ringIndex: 3, angle: 180 }, // Bottom of largest ring +]; + +export function PlanIcon({ + icon, + variant = "single", + animationDirection = "down", +}: { + icon: IconName; + variant?: "single" | "organization" | "team"; + animationDirection?: "up" | "down"; +}) { + const renderIconContainer = (index: number) => { return ( -
{/* Icon */} -
- +
+
{/* Inner highlight/shine effect */} @@ -29,79 +73,88 @@ export function PlanIcon({ icon, variant = "single" }: { icon: IconName; variant opacity: 0.15, }} /> -
+ + ); + }; + + const renderSmallUserIcon = (ringIndex: number, angle: number, index: number) => { + const ringSize = RING_SIZES[ringIndex]; + const radius = ringSize / 2; + const angleRad = (angle * Math.PI) / 180; + + // Calculate position on the ring + const x = Math.cos(angleRad) * radius; + const y = Math.sin(angleRad) * radius; + const iconHalfSize = 20.25; // Half of 40.5px + + return ( + +
+ +
+
+ ); }; return ( -
- {/* Outer ring - SVG with linear gradient */} - - - - - - - - - +
+ {/* Generate concentric rings centered on icon */} + {RING_SIZES.map((size, index) => { + const opacity = [0.6, 0.5, 0.4, 0.35][index] || 0.3; + return ( +
+ ); + })} - {/* Middle ring - SVG with linear gradient */} - - - - - - - - - + {/* Small user icons on rings (for team variant) */} + {(variant === "team" || variant === "organization") && + TEAM_ICON_POSITIONS.map(({ ringIndex, angle }, index) => + renderSmallUserIcon(ringIndex, angle, index) + )} - {/* Main icon container(s) with gradient background */} - {variant === "single" ? renderIconContainer(0) : [renderIconContainer(0), renderIconContainer(1)]} + {renderIconContainer(0)}
); } diff --git a/apps/web/modules/onboarding/getting-started/onboarding-view.tsx b/apps/web/modules/onboarding/getting-started/onboarding-view.tsx index 4a908efa8e..0fd6c51ebf 100644 --- a/apps/web/modules/onboarding/getting-started/onboarding-view.tsx +++ b/apps/web/modules/onboarding/getting-started/onboarding-view.tsx @@ -10,9 +10,9 @@ import { Button } from "@calcom/ui/components/button"; import { type IconName } from "@calcom/ui/components/icon"; import { RadioAreaGroup } from "@calcom/ui/components/radio"; +import { OnboardingLayout } from "../components/OnboardingLayout"; import { OnboardingContinuationPrompt } from "../components/onboarding-continuation-prompt"; import { PlanIcon } from "../components/plan-icon"; -import { OnboardingLayout } from "../personal/_components/OnboardingLayout"; import { useOnboardingStore, type PlanType } from "../store/onboarding-store"; type OnboardingViewProps = { @@ -64,7 +64,7 @@ export const OnboardingView = ({ userName, userEmail }: OnboardingViewProps) => badge: t("onboarding_plan_organization_badge"), description: t("onboarding_plan_organization_description"), icon: planIconByType.organization, - variant: "double" as const, + variant: "organization" as const, }, ];