Skip to content

Commit

Permalink
refactor(dashboard): onboarding playground skip playground
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Dec 8, 2024
1 parent c41351a commit 7474151
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
20 changes: 16 additions & 4 deletions apps/dashboard/src/components/auth/inbox-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ export function InboxPlayground() {
navigate(`${ROUTES.INBOX_EMBED}?${queryParams}`);
};

const handleSkipToDashboard = () => {
telemetry(TelemetryEvent.SKIP_ONBOARDING_CLICKED, {
skippedFrom: 'inbox-playground',
});
navigate(ROUTES.WELCOME);
};

useEffect(() => {
const subscription = form.watch((value, { name }) => {
if (name === 'selectedStyle') {
Expand Down Expand Up @@ -217,18 +224,23 @@ export function InboxPlayground() {
)}
</Button>
) : (
<Button size="sm" className="px-2" onClick={handleImplementClick}>
Implement &lt;Inbox /&gt;
</Button>
<>
<Button size="sm" variant="ghost" className="px-2" onClick={handleSkipToDashboard}>
Skip to Dashboard
</Button>
<Button size="sm" className="px-2" onClick={handleImplementClick}>
Implement &lt;Inbox /&gt;
</Button>
</>
)}
</div>
</div>
</div>

<div className="max-h-[610px] w-full border-l">
<InboxPreviewContent
hasNotificationBeenSent={hasNotificationBeenSent}
selectedStyle={form.watch('selectedStyle')}
hideHint={hasNotificationBeenSent}
primaryColor={form.watch('primaryColor')}
foregroundColor={form.watch('foregroundColor')}
/>
Expand Down
31 changes: 23 additions & 8 deletions apps/dashboard/src/components/auth/inbox-preview-content.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Inbox, InboxContent, InboxProps } from '@novu/react';
import { SVGProps } from 'react';
import { motion, AnimatePresence } from 'motion/react';
import { useFetchEnvironments } from '../../context/environment/hooks';
import { useUser } from '@clerk/clerk-react';
import { useAuth } from '../../context/auth/hooks';
import { API_HOSTNAME, WEBSOCKET_HOSTNAME } from '../../config';

interface InboxPreviewContentProps {
selectedStyle: string;
hideHint?: boolean;
hasNotificationBeenSent?: boolean;
primaryColor: string;
foregroundColor: string;
}

export function InboxPreviewContent({
selectedStyle,
hideHint,
hasNotificationBeenSent,
primaryColor,
foregroundColor,
}: InboxPreviewContentProps) {
Expand Down Expand Up @@ -67,12 +68,26 @@ export function InboxPreviewContent({
<div className="mt-10 flex w-full max-w-[440px] items-center justify-end">
<Inbox {...configuration} placement="bottom-end" open />
</div>
{!hideHint && (
<div className="absolute bottom-[-10px] left-2 flex flex-col items-start">
<SendNotificationArrow className="mt-2 h-[73px] w-[86px]" />
<p className="text-success relative top-[-32px] text-[10px] italic">Hit send, to get an notification!</p>
</div>
)}
<div className="absolute bottom-[-10px] left-2 flex flex-col items-start">
<SendNotificationArrow className="mt-2 h-[73px] w-[86px]" />
<AnimatePresence mode="wait">
<motion.p
key={hasNotificationBeenSent ? 'implement' : 'send'}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{
type: 'spring',
duration: 0.2,
}}
className="text-success relative top-[-32px] max-w-[200px] text-[10px] italic leading-[12px]"
>
{hasNotificationBeenSent
? 'Click to implement the Inbox in your application now'
: 'Hit send, to get an notification!'}
</motion.p>
</AnimatePresence>
</div>
</div>
)}
{selectedStyle === 'sidebar' && (
Expand Down

0 comments on commit 7474151

Please sign in to comment.