();
// ... existing hooks ...
return (
<>
{/* No SearchFilter here anymore */}
{selectedVideo && }
>
);
}
```
### 3. Update App.tsx to Pass Props
**File:** `frontend/src/App.tsx`
**Option A - Pass through routes:**
```typescript
}
/>
```
**Option B - Conditional rendering in Navbar:**
```typescript
// Navbar checks current route
const location = useLocation();
const isHomePage = location.pathname === '/';
{isHomePage && (
{/* Search and filters */}
)}
```
**Recommended:** Option B is simpler
### 4. Handle State Communication
**Challenge:** HomePage has the state, but Navbar needs to trigger changes.
**Solution:** Use React Router's `useLocation` and `useNavigate` with URL query params:
```typescript
// In HomePage
const [searchParams, setSearchParams] = useSearchParams();
const page = searchParams.get('page') || '1';
const search = searchParams.get('search') || '';
const sort = searchParams.get('sort') || 'newest';
// In Navbar
const handleSearch = (query: string) => {
const newParams = new URLSearchParams(window.location.search);
newParams.set('search', query);
newParams.set('page', '1');
navigate({ search: newParams.toString() });
};
```
**Benefits:**
- Shareable URLs with filters
- Browser back/forward works
- No prop drilling needed
### 5. Update Navbar CSS
**File:** `frontend/src/components/Navbar/Navbar.css`
**Add styles for:**
- Search input container
- Filter dropdowns
- Clear button
- Responsive breakpoints
- YouTube-inspired styling
**Layout:**
```
Desktop:
[📺 Kiddos] [Home] [Admin] [🔍 Search...] [Sort ▼] [Channel ▼] [Clear] [Login]
Mobile:
[📺 Kiddos] [☰]
[🔍 Search...] [Sort ▼] [Channel ▼] [Clear]
```
### 6. Remove SearchFilter Component (Optional)
**Files to delete/deprecate:**
- `frontend/src/components/SearchFilter/SearchFilter.tsx`
- `frontend/src/components/SearchFilter/SearchFilter.css`
Or keep it for reuse elsewhere.
## Implementation Steps
1. ✅ Create this plan
2. Add URL query param management to HomePage (using `useSearchParams`)
3. Update Navbar to accept search/filter props
4. Add search/filter UI to Navbar component
5. Style Navbar with new layout
6. Update HomePage to remove SearchFilter and pass props to Navbar
7. Test on desktop and mobile
8. Remove SearchFilter component if no longer needed
9. Clean up unused CSS
## Testing Checklist
- [ ] Search works from navbar
- [ ] Sort dropdown changes video order
- [ ] Channel filter works
- [ ] Clear filters button appears when filters active
- [ ] Clear filters button resets everything
- [ ] Pagination resets to 1 when filters change
- [ ] URL updates with query params
- [ ] Browser back/forward works with filters
- [ ] Mobile responsive (hamburger menu or stacked layout)
- [ ] Navbar doesn't show search on Admin/Login pages
## Alternative: Simpler Approach
If URL params are too complex, keep state in HomePage and pass callbacks to Navbar:
```typescript
// App.tsx
function App() {
const [navbarProps, setNavbarProps] = useState({});
return (
} />
);
}
```
But this requires lifting state to App level and prop drilling.
## Recommendation
**Best approach:**
1. Use URL query params for filter state
2. Navbar reads from URL and updates URL on changes
3. HomePage reads from URL for fetching videos
4. Clean, shareable, no prop drilling
**Estimated time:** 30-45 minutes
**Complexity:** Medium (URL params + responsive styling)