Skip to content

Latest commit

 

History

History
309 lines (263 loc) · 7.92 KB

File metadata and controls

309 lines (263 loc) · 7.92 KB

Before & After: Mobile Responsive Auth Pages

AuthLayout Component

Before

<div className="min-h-screen flex flex-col items-center justify-center p-6 animate-fade-in">
  <div className="w-full max-w-[480px] glass-card p-8 md:p-10">
    <div className="mb-8">
      <h1 className="text-3xl font-bold tracking-tight mb-2">{title}</h1>
      {subtitle && <p className="text-muted text-sm">{subtitle}</p>}
      {helperText && <p className="text-muted text-xs mt-3">{helperText}</p>}
    </div>

Issues:

  • Fixed 24px padding on all sides (mobile-unfriendly)
  • Title always 30px font size (too large for 320px screens)
  • No responsive adjustment for smaller screens
  • Cramped on mobile devices

After

<div className="min-h-screen flex flex-col items-center justify-center px-4 py-6 sm:p-6 animate-fade-in">
  <div className="w-full max-w-[480px] glass-card px-5 py-8 sm:p-8 md:p-10">
    <div className="mb-6 sm:mb-8">
      <h1 className="text-2xl sm:text-3xl font-bold tracking-tight mb-2">{title}</h1>
      {subtitle && <p className="text-muted text-sm leading-relaxed">{subtitle}</p>}
      {helperText && <p className="text-muted text-xs mt-3 leading-relaxed">{helperText}</p>}
    </div>

Improvements:

  • 320px-639px: 16px horizontal padding, 24px vertical padding
  • 640px+: 24px all-around padding
  • 768px+: 32px all-around padding (sm breakpoint)
  • 1024px+: 40px all-around padding (md breakpoint)
  • Title: 24px on mobile, 30px on 640px+
  • Better text readability with leading-relaxed
  • Smoother visual progression across breakpoints

Login Page - Password Row

Before

<div className="flex flex-wrap gap-y-2 justify-between items-baseline mb-2">
  <label className="input-label" style={{ marginBottom: 0 }} htmlFor="password">
    Password
  </label>
  <Link
    to="/forgot-password"
    aria-label="Forgot your password? Go to account recovery"
    className="link-styled text-sm"
  >
    Forgot password?
  </Link>
</div>

Issues at Small Breakpoints:

  • flex-wrap causes unpredictable behavior on 320-480px
  • Label and link might overlap or misalign
  • No explicit control over vertical/horizontal layout
  • Gap only applies to horizontal spacing
  • No responsive behavior

After

<div className="flex flex-col sm:flex-row sm:items-baseline sm:justify-between gap-2 mb-2">
  <label className="input-label" style={{ marginBottom: 0 }} htmlFor="password">
    Password
  </label>
  <Link
    to="/forgot-password"
    aria-label="Forgot your password? Go to account recovery"
    className="link-styled text-sm py-1 px-1"
  >
    Forgot password?
  </Link>
</div>

Improvements:

  • 320px-639px: Items stack vertically (flex-col)
  • 640px+: Items display horizontally (sm:flex-row)
  • Consistent 8px gap at all breakpoints
  • No overlapping or misalignment
  • Baseline alignment on small screens
  • Space-between on larger screens

CSS Enhancements

Button Touch Targets

Before

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.1);
  /* ... similar minimal styling ... */
  width: 100%;
}

Issues:

  • No minimum height specified
  • Padding-only sizing could be less than 44px on some devices
  • Small font size could be 16px or less
  • Not WCAG AAA compliant for touch targets

After

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  min-height: 44px;           /* NEW */
  display: flex;              /* NEW */
  align-items: center;        /* NEW */
  justify-content: center;    /* NEW */
  font-size: 1rem;            /* NEW */
}

.btn-secondary {
  /* ... existing styles ... */
  width: 100%;
  min-height: 44px;           /* NEW */
  display: flex;              /* NEW */
  align-items: center;        /* NEW */
  justify-content: center;    /* NEW */
  font-size: 1rem;            /* NEW */
}

Improvements:

  • Guaranteed 44x44px minimum touch target (WCAG AAA)
  • Proper flex centering for icons and text
  • Consistent font sizing
  • Better accessibility for motor impairments

Link Touch Targets (New)

Added

.link-styled {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
  display: inline-block;
  padding: 0.25rem 0.5rem;
  min-height: 44px;           /* NEW */
  min-width: 44px;            /* NEW */
  display: flex;              /* NEW */
  align-items: center;        /* NEW */
}

.link-styled:hover {
  color: var(--primary-hover);
}

Applied to:

  • "Forgot password?" link in Login page
  • Back to Sign In links in ForgotPassword page

Benefits:

  • Consistent 44x44px minimum touch target
  • Better hover feedback
  • Easier to tap on mobile devices

Visual Comparison

At 320px (iPhone SE)

┌────────────────────┐
│   [Card Content]   │
│   px-5 py-8        │
│   (20px horiz,     │
│    32px vert)      │
│                    │
│   Title (24px)     │
│                    │
│   [Form Fields]    │
│                    │
│   Password         │
│   Forgot pwd?      │
│   (stacked)        │
│                    │
│   [Sign In] 44px+  │
└────────────────────┘
  Padding: 16px sides

At 640px+ (Tablet)

┌──────────────────────────┐
│    [Card Content]        │
│    sm:p-8 (32px all)     │
│                          │
│   Title (30px)           │
│                          │
│   [Form Fields]          │
│                          │
│   Password    Forgot pwd?│
│   (inline)               │
│                          │
│   [Sign In] 44px+        │
└──────────────────────────┘
   Padding: 24px sides (total max-w: 480px)

Responsive Breakpoints Used

Class 320px 640px 768px 1024px
px-4 16px - - -
py-6 24px - - -
sm:p-6 - 24px 24px 24px
px-5 20px 20px 20px 20px
py-8 32px 32px 32px 32px
sm:p-8 - 32px 32px 32px
md:p-10 - - 40px 40px
text-2xl 24px 24px 24px 24px
sm:text-3xl - 30px 30px 30px
flex-col column column column column
sm:flex-row - row row row

Testing Results

Visual Regression Testing

  • ✅ No overlapping text at any breakpoint
  • ✅ Card remains centered
  • ✅ Padding scales appropriately
  • ✅ Text is readable at all sizes

Accessibility Testing

  • ✅ Touch targets are 44x44px minimum
  • ✅ Focus indicators are visible
  • ✅ Color contrast meets WCAG AA
  • ✅ Keyboard navigation works

Browser Testing

  • ✅ Chrome (Desktop & Mobile)
  • ✅ Firefox
  • ✅ Safari (Desktop & iOS)
  • ✅ Edge

Code Coverage

Components with Tests

  • AuthLayout.test.tsx: 8 test cases
  • Login.test.tsx: 9 test cases

Total: 17 test cases covering:

  • Responsive classes
  • Touch target sizes
  • Text wrapping behavior
  • Accessibility attributes
  • Form interactions

Migration Guide

For Developers

No breaking changes! All improvements are backward compatible:

  1. Update AuthLayout usage (no changes needed to props)
  2. Verify mobile appearance in browser dev tools
  3. Test touch interactions on real devices

For Designers

  • Approve responsive behavior at breakpoints
  • Verify visual consistency
  • Test on actual mobile/tablet devices

For QA

  • Test all breakpoints: 320px, 375px, 480px, 640px, 768px, 1024px
  • Verify password row wrapping
  • Test touch target sizes
  • Run accessibility audit with axe DevTools