# Primora Frontend Migration Guide ## Overview This guide helps you migrate from the previous component patterns to the new enhanced component library. --- ## No Breaking Changes! 🎉 Good news: **All enhancements are backward compatible**. Your existing code will continue to work without modifications. This guide shows you how to leverage the new features. --- ## New Components Available ### 1. Replace Custom Modals with Modal Component **Before:** ```tsx

Confirm Action

Are you sure?

``` **After:** ```tsx setShowDialog(false)} title="Confirm Action" description="Are you sure?" size="md" > ``` **Benefits:** - Automatic backdrop blur - ESC key support - Click outside to close - Proper z-index management - Smooth animations - Accessibility built-in --- ### 2. Add Tooltips to Icon Buttons **Before:** ```tsx ``` **After:** ```tsx Actions} items={[ { id: "edit", label: "Edit", icon: , onClick: handleEdit }, { id: "divider", divider: true }, { id: "delete", label: "Delete", icon: , danger: true, onClick: handleDelete }, ]} /> ``` **Benefits:** - Smart positioning - Click outside to close - Keyboard navigation - Icon support - Danger states - Dividers --- ### 4. Use Toast Instead of Custom Alerts **Before:** ```tsx
{message()}
``` **After:** ```tsx // Add once to app root // Use anywhere toast.success("Operation successful!"); toast.error("Something went wrong"); toast.info("New update available"); ``` **Benefits:** - Global API - Auto-dismiss - Stacked notifications - Multiple variants - Smooth animations --- ### 5. Add Loading States with Progress **Before:** ```tsx
``` **After:** ```tsx // Spinner // Progress bar // Circular progress ``` **Benefits:** - Multiple variants - Size options - Label support - Smooth animations --- ### 6. Use Tabs for Multi-Section Views **Before:** ```tsx
``` **After:** ```tsx , content: }, { id: "settings", label: "Settings", badge: "3", content: }, ]} onChange={(tabId) => console.log(tabId)} /> ``` **Benefits:** - Multiple variants (default, pills, underline) - Icon and badge support - Disabled states - Smooth transitions - Keyboard navigation --- ## Enhanced Components ### Button Enhancements **New Features:** ```tsx // Loading state // Icon positioning // Sizes ``` --- ### Card Enhancements **New Features:** ```tsx // Elevated variant ... // Interactive card Clickable card // Stat card } trend="up" trendValue="+12%" /> // Hover effects Interactive card with effects ``` --- ### Input Enhancements **New Features:** ```tsx // Error states setEmail(e.currentTarget.value)} error={errors().email} /> // Sizes ``` --- ## New CSS Utilities ### Animations ```tsx // Fade in
Content
// Slide animations
Slide from bottom
Slide from top
Slide from right
Slide from left
// Scale and bounce
Scale in
Bounce in
// Stagger children
Item 1
Item 2
Item 3
``` --- ### Visual Effects ```tsx // Card effects Lifts on hover Shine effect // Glass effect
Frosted glass background
// Text effects Shimmer text Neon glow Gradient text // Loading states
``` --- ## Common Migration Patterns ### 1. Confirmation Dialogs **Before:** ```tsx const [showConfirm, setShowConfirm] = createSignal(false);

Confirm Deletion

This action cannot be undone.

``` **After:** ```tsx const [showConfirm, setShowConfirm] = createSignal(false); setShowConfirm(false)} title="Confirm Deletion" description="This action cannot be undone." size="sm" > ``` --- ### 2. Action Menus **Before:** ```tsx
``` **After:** ```tsx •••} items={[ { id: "view", label: "View Details", icon: }, { id: "edit", label: "Edit", icon: }, { id: "divider", divider: true }, { id: "delete", label: "Delete", icon: , danger: true }, ]} /> ``` --- ### 3. Loading States **Before:** ```tsx }> {/* Content */} ``` **After:** ```tsx }> {/* Content */} // Or with progress
}> {/* Content */} ``` --- ### 4. Form Submissions **Before:** ```tsx
setName(e.currentTarget.value)} />
``` **After:** ```tsx
setName(e.currentTarget.value)} error={errors().name} />
``` --- ### 5. Success/Error Messages **Before:** ```tsx
{successMessage()}
``` **After:** ```tsx // Option 1: Message component setSuccessMessage("")}> {successMessage()} // Option 2: Toast (recommended) toast.success(successMessage()); ``` --- ## Step-by-Step Migration ### Phase 1: Add ToastContainer ```tsx // In your App.tsx or main component import { ToastContainer } from "./components"; export default function App() { return ( <> {/* Rest of your app */} ); } ``` ### Phase 2: Replace Alerts with Toasts Replace all custom alert/message displays with toast notifications. ### Phase 3: Add Tooltips Add tooltips to icon-only buttons for better UX. ### Phase 4: Replace Custom Modals Migrate custom modal implementations to the Modal component. ### Phase 5: Add Dropdowns Replace custom dropdown menus with the Dropdown component. ### Phase 6: Enhance Forms Add loading states, error handling, and progress indicators to forms. ### Phase 7: Add Tabs Replace custom tab implementations with the Tabs component. --- ## Best Practices ### 1. Use Semantic Components ```tsx // Good // Avoid ``` ### 2. Leverage Loading States ```tsx // Good // Avoid ``` ### 3. Use Toast for Notifications ```tsx // Good toast.success("Project created!"); // Avoid setMessage("Project created!"); setTimeout(() => setMessage(""), 3000); ``` ### 4. Add Tooltips to Icons ```tsx // Good // Avoid ``` --- ## Troubleshooting ### Modal Not Showing Make sure the Modal is rendered and `open` prop is true: ```tsx setShow(false)}> ``` ### Tooltip Not Appearing Check that the tooltip has a trigger element: ```tsx ``` ### Toast Not Working Ensure ToastContainer is added to your app root: ```tsx ``` ### Dropdown Not Positioning Correctly The dropdown uses Portal rendering. Make sure your app has proper z-index management. --- ## Need Help? - **Quick Reference**: See `COMPONENT_GUIDE.md` - **Detailed Docs**: See `FRONTEND_ENHANCEMENTS.md` - **Design System**: See `project_frontend.md` --- **Happy migrating! 🚀**