Pun Generator | PunsBook.com

🎰 Pun Generator 🎰

import React, { useState } from “react”; import { Input } from “@/components/ui/input”; import { Button } from “@/components/ui/button”; import { Card, CardContent } from “@/components/ui/card”; import { Loader } from “lucide-react”; const punsDatabase = { cat: [“You’re purr-fect!”, “Stay pawsitive!”, “Feline good today?”], dog: [“You’re pawsome!”, “What a ruff day!”, “Barking up the right tree!”], food: [“Lettuce celebrate!”, “You’re the zest!”, “Time to ketchup!”], love: [“You stole a pizza my heart!”, “I’m soy into you!”, “Olive you so much!”], }; export default function PunGenerator() { const [keyword, setKeyword] = useState(“”); const [pun, setPun] = useState(null); const [loading, setLoading] = useState(false); const generatePun = () => { setLoading(true); setTimeout(() => { const lowerKeyword = keyword.toLowerCase(); if (punsDatabase[lowerKeyword]) { const randomPun = punsDatabase[lowerKeyword][ Math.floor(Math.random() * punsDatabase[lowerKeyword].length) ]; setPun(randomPun); } else { setPun(`No puns found for “${keyword}”. Try another word!`); } setLoading(false); }, 1000); }; return (

Pun Generator

setKeyword(e.target.value)} className=”p-2 border rounded-md” />
{pun && ( {pun} )}
); }
Scroll to Top