FavoritesList

A responsive grid component for displaying user's favorite content items with smooth animations and remove functionality

📦 Installation

pnpm dlx shadcn@latest add https://zezo-ui.vercel.app/r/zezo-favorites.json

💡 Usage Example

import FavoritesList from "@/components/zezo/users/FavoritesList/FavoritesList";
import type { IFavoriteContentItem } from "@zezosoft/zezo-ott-api-client";

// Fetch favorites from your API
const fetchFavorites = async () => {
  const response = await fetch("/api/favorites");
  const data = await response.json();
  return data.data; // IFavoriteContentItem[]
};

function FavoritesPage() {
  const [favorites, setFavorites] = React.useState<IFavoriteContentItem[]>([]);
  const [isRemoving, setIsRemoving] = React.useState(false);

  React.useEffect(() => {
    fetchFavorites().then(setFavorites);
  }, []);

  const handleRemove = async (contentId: string) => {
    setIsRemoving(true);
    try {
      await fetch(`/api/favorites/${contentId}`, {
        method: "DELETE",
      });
      setFavorites(prev => 
        prev.filter(item => item.content._id !== contentId)
      );
      toast.success("Removed from favorites");
    } catch (error) {
      toast.error("Failed to remove favorite");
    } finally {
      setIsRemoving(false);
    }
  };

  return (
    <FavoritesList
      items={favorites}
      onRemove={handleRemove}
      isLoading={isRemoving}
      emptyMessage="You haven&apos;t added any favorites yet"
    />
  );
}

📘 Props

PropTypeRequiredDescription
itemsIFavoriteContentItem[]YesArray of favorite content items to display in the grid
onRemove(id: string) => voidOptionalCallback function called when remove button is clicked. Receives the content ID as parameter
isLoadingbooleanOptionalDisables the remove button while loading (default: false)
emptyMessagestringOptionalCustom message displayed when no favorites are found (default: "No favorites found.")

🔷 Interfaces

The component uses types from @zezosoft/zezo-ott-api-client package:

import type { IFavoriteContentItem } from "@zezosoft/zezo-ott-api-client";

// IFavoriteContentItem structure:
interface IFavoriteContentItem {
  _id: string;                    // Favorite item ID
  content: {
    _id: string;                   // Content ID
    poster: string;                // Poster image URL
    // ... other content fields
  };
}

📦 Required Packages

Install these packages before using FavoritesList:

npm install @zezosoft/zezo-ott-api-client framer-motion lucide-react

# Or with pnpm
pnpm add @zezosoft/zezo-ott-api-client framer-motion lucide-react

# Or with yarn
yarn add @zezosoft/zezo-ott-api-client framer-motion lucide-react

✨ Features

🎨 Smooth Animations

Framer Motion powered hover effects with scale transformations

🗑️ Remove Functionality

Optional remove button with loading state support

📱 Responsive Design

Flexible grid layout that adapts to different screen sizes

🌓 Dark Mode

Full dark mode support with automatic theme switching

🎯 Theme Integration

Uses dynamic theme colors from getThemeColors() config

📭 Empty State

Customizable empty state message when no favorites exist

🖼️ Fixed Card Size

Consistent 160x240px poster cards for uniform appearance

♿ Accessibility

Proper ARIA labels and keyboard navigation support

👁️ Preview

No favorites found.