Skip to content

Latest commit

 

History

History
233 lines (192 loc) · 7.38 KB

File metadata and controls

233 lines (192 loc) · 7.38 KB

🎯 UserInputModal Revamp with Redux Integration

🚀 What's New

Modern Design Overhaul

  • Gradient Header - Beautiful rainbow gradient background with sparkles
  • 📊 Progress Bar - Animated progress indicator with percentage
  • 🎯 Step Indicators - Visual step circles with checkmarks for completed steps
  • 🎨 Glassmorphism - Backdrop blur effects throughout
  • 🌈 Gradient Buttons - Eye-catching CTA buttons with hover effects

Redux State Management

  • 🔄 Persistent State - User preferences saved in Redux store
  • 💾 API Integration - Automatically saves to /api/user/profile
  • 🚫 Skip Logic - If user already completed onboarding, skips modal
  • 🔄 State Sync - Redux state syncs with existing profile data

🎨 Design Features

Header Section

<div className="relative overflow-hidden rounded-t-lg bg-gradient-to-br from-[#FFA9AE] via-[#8D81FF] to-[#69E1FE] p-8">
  <div className="absolute inset-0 bg-black/20" />
  <div className="relative z-10">
    <div className="mx-auto mb-4 inline-flex h-16 w-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm">
      <Sparkles className="h-8 w-8 text-white" />
    </div>
  </div>
</div>

Progress Tracking

  • Animated Progress Bar - Smooth width transitions
  • Step Circles - Visual indicators with checkmarks
  • Percentage Display - Real-time completion percentage

Step Content

Each step has:

  • 🎯 Icon - Unique gradient icon for each step
  • 📝 Title - Clear, descriptive heading
  • 💡 Description - Helpful context text
  • 🎨 Modern Inputs - Styled form elements with hover effects

🔧 Redux Integration

Store Setup

// src/lib/store.ts
export const store = configureStore({
  reducer: {
    user: userSlice,
  },
});

User Slice

// src/lib/slices/userSlice.ts
interface UserState {
  isAuthenticated: boolean;
  profile: UserProfile | null;
  isLoading: boolean;
  hasCompletedOnboarding: boolean;
}

Actions

  • setProfile() - Save user profile data
  • setOnboardingComplete() - Mark onboarding as done
  • updateProfile() - Update specific profile fields
  • clearUser() - Reset user state

📱 Step-by-Step Experience

Step 1: Experience Level

  • 🎯 Target Icon - Blue to purple gradient
  • 📊 Enhanced Select - Color-coded options with descriptions
  • 🟢 Beginner - Green dot, "New to prompt engineering"
  • 🟡 Intermediate - Yellow dot, "Some experience with AI"
  • 🔴 Advanced - Red dot, "Expert in AI tools"

Step 2: Area of Expertise

  • 🧠 Brain Icon - Purple to pink gradient
  • 📝 Text Input - Placeholder with examples
  • 💡 Smart Placeholder - "e.g., Software Development, Marketing, Data Science..."

Step 3: Learning Style

  • Zap Icon - Green to teal gradient
  • 🎨 Card Layout - Each option in a styled card
  • 📋 Three Options:
    • Visual - "I learn through diagrams, charts, and visual examples"
    • Auditory - "I learn through listening and verbal explanations"
    • Hands-on - "I learn by doing and practicing"

Step 4: Goals

  • CheckCircle Icon - Orange to red gradient
  • ☑️ Multi-select - Checkbox cards for multiple goals
  • 🎯 Four Goal Options:
    • Improve writing skills
    • Learn advanced techniques
    • Increase efficiency
    • Explore creative applications

🎭 Animations & Interactions

Framer Motion

<motion.div
  key={currentStep}
  initial={{ opacity: 0, x: 50 }}
  animate={{ opacity: 1, x: 0 }}
  exit={{ opacity: 0, x: -50 }}
  transition={{ duration: 0.3 }}
>

Progress Bar Animation

<motion.div
  className="h-2 rounded-full bg-gradient-to-r from-[#FFA9AE] via-[#8D81FF] to-[#69E1FE]"
  initial={{ width: 0 }}
  animate={{ width: `${((currentStep + 1) / steps.length) * 100}%` }}
  transition={{ duration: 0.3 }}
/>

Step Indicators

<motion.div
  className={`flex h-10 w-10 items-center justify-center rounded-full border-2 transition-all ${
    index <= currentStep
      ? "border-[#8D81FF] bg-[#8D81FF] text-white"
      : "border-gray-600 bg-gray-800 text-gray-400"
  }`}
  initial={{ scale: 0.8 }}
  animate={{ scale: 1 }}
  transition={{ delay: index * 0.1 }}
>

🔄 State Management Flow

Initial Load

  1. Check Redux store for existing profile
  2. If hasCompletedOnboarding is true, skip modal
  3. If profile exists, pre-populate form fields

Form Submission

  1. Save to Redux store with setProfile()
  2. Mark onboarding complete with setOnboardingComplete()
  3. Save to API with POST to /api/user/profile
  4. Close modal and proceed to dashboard

Navigation

  • Back Button - Disabled on first step
  • Next Button - Disabled until current step is valid
  • Final Button - "Start Your Journey" with sparkles icon

🎨 Styling Details

Color Scheme

  • Primary Gradient: #FFA9AE#8D81FF#69E1FE
  • Background: black/95 with backdrop blur
  • Cards: gray-900/50 with border gray-700
  • Text: White primary, gray-400 secondary

Interactive States

  • Hover: Scale up, shadow effects, border color changes
  • Focus: Ring effects, background changes
  • Disabled: Opacity reduction, cursor not-allowed

Responsive Design

  • Mobile: Full-width cards, stacked layout
  • Desktop: Centered modal with max-width
  • Tablet: Optimized spacing and sizing

🚀 Performance

Optimizations

  • Lazy Loading - Redux state only loads when needed
  • Memoization - Form state updates efficiently
  • API Caching - Profile data cached in Redux
  • Smooth Animations - GPU-accelerated transitions

Error Handling

  • API Failures - Graceful degradation
  • Validation - Real-time form validation
  • State Recovery - Redux state persists across sessions

🎯 User Experience

Onboarding Flow

  1. Welcome - Beautiful gradient header with sparkles
  2. Progress - Clear visual progress tracking
  3. Guidance - Helpful descriptions for each step
  4. Validation - Real-time form validation
  5. Completion - Satisfying finish with animations

Returning Users

  • Skip Logic - If already personalized, skip modal
  • Data Persistence - Profile data loads from Redux
  • Seamless Experience - No unnecessary re-onboarding

🔧 Technical Implementation

Dependencies Added

npm install @reduxjs/toolkit react-redux

Files Created

  • src/lib/store.ts - Redux store configuration
  • src/lib/slices/userSlice.ts - User state slice
  • src/lib/hooks.ts - Typed Redux hooks
  • src/components/providers/ReduxProvider.tsx - Provider component

Integration Points

  • Layout - ReduxProvider wraps entire app
  • Modal - Uses Redux hooks for state management
  • API - Syncs with existing profile endpoints
  • Auth - Integrates with NextAuth session

🎉 Result

The UserInputModal now features:

  • Stunning modern design with gradients and animations
  • 🔄 Full Redux integration for state management
  • 💾 Persistent user preferences across sessions
  • 🚫 Smart skip logic for returning users
  • 📱 Responsive design for all devices
  • 🎯 Enhanced UX with progress tracking and validation

All user personalization data is now properly managed with Redux and persists across sessions! 🎊