The user wants a random quote generator that:
- Fetches data from an API
- Has animated transitions
- Uses HTML, JS, and CSS
Let me create something visually striking and not generic. I'll:
- Use a distinctive font pairing - maybe something like "Space Grotesk" for UI and "Playfair Display" for quotes
- Create a unique visual aesthetic - maybe a dark, moody theme with a warm accent color
- Add meaningful animations:
- Quote transition with staggered text reveal
- Background subtle movement
- Button interactions
- Use a real quote API - I'll use quotable.io or similar free API, or fallback to local quotes if API fails
Design direction:
- Dark, atmospheric background with subtle gradients and maybe some geometric shapes
- Warm amber/gold accent color for contrast
- Elegant typography with the quote being the hero
- Smooth, sophisticated animations
Let me build this out:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quote Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap" rel="stylesheet">
<style>
/* CSS Variables */
:root {
--bg: #0a0a0b;
--bg-secondary: #141416;
--fg: #fafafa;
--muted: #71717a;
--accent: #f59e0b;
--accent-glow: rgba(245, 158, 11, 0.3);
--card: rgba(255, 255, 255, 0.03);
--border: rgba(255, 255, 255, 0.08);
}
/* Base styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
/* Background elements */
.bg-gradient {
position: fixed;
inset: 0;
background:
radial-gradient(ellipse 80% 50% at 50% -20%, rgba(245, 158, 11, 0.08), transparent),
radial-gradient(ellipse 60% 40% at 80% 100%, rgba(245, 158, 11, 0.05), transparent);
pointer-events: none;
}
.bg-grid {
position: fixed;
inset: 0;
background-image:
linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
background-size: 60px 60px;
pointer-events: none;
}
.floating-shapes {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
}
.shape {
position: absolute;
border: 1px solid var(--border);
opacity: 0.5;
animation: float 20s ease-in-out infinite;
}
.shape-1 {
width: 200px;
height: 200px;
top: 10%;
left: 5%;
border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
animation-delay: 0s;
}
.shape-2 {
width: 150px;
height: 150px;
bottom: 20%;
right: 10%;
border-radius: 50%;
animation-delay: -5s;
}
.shape-3 {
width: 100px;
height: 100px;
top: 50%;
right: 20%;
transform: rotate(45deg);
animation-delay: -10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
25% { transform: translate(20px, -20px) rotate(5deg); }
50% { transform: translate(-10px, 20px) rotate(-5deg); }
75% { transform: translate(15px, 10px) rotate(3deg); }
}
/* Quote display */
.quote-container {
max-width: 900px;
margin: 0 auto;
padding: 2rem;
}
.quote-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 24px;
padding: 3rem;
position: relative;
backdrop-filter: blur(20px);
}
.quote-mark {
font-family: 'Instrument Serif', serif;
font-size: 12rem;
line-height: 0;
position: absolute;
top: 20px;
left: 30px;
color: var(--accent);
opacity: 0.15;
pointer-events: none;
}
.quote-text {
font-family: 'Instrument Serif', serif;
font-size: clamp(1.5rem, 4vw, 2.5rem);
font-style: italic;
line-height: 1.5;
color: var(--fg);
position: relative;
z-index: 1;
}
.quote-author {
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 1rem;
}
.author-avatar {
width: 48px;
height: 48px;
border-radius: 50%;
background: linear-gradient(135deg, var(--accent), rgba(245, 158, 11, 0.3));
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
color: var(--bg);
}
.author-info {
flex: 1;
}
.author-name {
font-weight: 600;
font-size: 1.1rem;
}
.author-tags {
display: flex;
gap: 0.5rem;
margin-top: 0.25rem;
flex-wrap: wrap;
}
.tag {
font-size: 0.75rem;
padding: 0.25rem 0.75rem;
background: rgba(245, 158, 11, 0.1);
color: var(--accent);
border-radius: 100px;
}
/* Animations */
.fade-out {
opacity: 0;
transform: translateY(-20px);
}
.fade-in {
animation: fadeIn 0.6s ease-out forwards;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.word-animate {
display: inline-block;
opacity: 0;
transform: translateY(20px);
animation: wordReveal 0.4s ease-out forwards;
}
@keyframes wordReveal {
to {
opacity: 1;
transform: translateY(0);
}
}
/* Buttons */
.btn-primary {
background: var(--accent);
color: var(--bg);
font-weight: 600;
padding: 1rem 2rem;
border-radius: 12px;
border: none;
cursor: pointer;
font-size: 1rem;
font-family: inherit;
display: inline-flex;
align-items: center;
gap: 0.5rem;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.btn-primary::before {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
opacity: 0;
transition: opacity 0.3s;
}
.btn-primary:hover::before {
opacity: 1;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 40px var(--accent-glow);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-primary:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.btn-secondary {
background: var(--card);
color: var(--fg);
border: 1px solid var(--border);
padding: 0.75rem 1rem;
border-radius: 10px;
cursor: pointer;
font-family: inherit;
font-size: 0.9rem;
transition: all 0.3s ease;
}
.btn-secondary:hover {
background: rgba(255,255,255,0.05);
border-color: var(--accent);
}
.btn-secondary:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Loading state */
.loading {
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: center;
min-height: 200px;
}
.loading-dot {
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--accent);
animation: loadingPulse 1.4s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes loadingPulse {
0%, 80%, 100% {
transform: scale(0.6);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
/* Spinner for button */
.spinner {
width: 20px;
height: 20px;
border: 2px solid transparent;
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
.shape,
.word-animate,
.fade-in {
animation: none;
}
.word-animate {
opacity: 1;
transform: none;
}
.fade-in {
opacity: 1;
transform: none;
}
.btn-primary:hover {
transform: none;
}
}
/* Header */
header {
padding: 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-weight: 700;
font-size: 1.25rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.logo-icon {
width: 32px;
height: 32px;
background: var(--accent);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
}
/* Stats */
.stats {
display: flex;
gap: 2rem;
margin-top: 3rem;
justify-content: center;
flex-wrap: wrap;
}
.stat {
text-align: center;
}
.stat-value {
font-size: 2rem;
font-weight: 700;
color: var(--accent);
}
.stat-label {
font-size: 0.875rem;
color: var(--muted);
margin-top: 0.25rem;
}
/* Toast */
.toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(100px);
background: var(--bg-secondary);
border: 1px solid var(--border);
padding: 1rem 1.5rem;
border-radius: 12px;
display: flex;
align-items: center;
gap: 0.75rem;
z-index: 100;
opacity: 0;
transition: all 0.3s ease;
}
.toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
.toast-icon {
color: var(--accent);
}
/* Main container */
main {
min-height: calc(100vh - 100px);
display: flex;
flex-direction: column;
justify-content: center;
padding: 2rem;
}
.controls {
display: flex;
justify-content: center;
gap: 1rem;
margin-top: 2rem;
flex-wrap: wrap;
}
</style>
</head>
<body>
<div class="bg-gradient"></div>
<div class="bg-grid"></div>
<div class="floating-shapes">
<div class="shape shape-1"></div>
<div class="shape shape-2"></div>
<div class="shape shape-3"></div>
</div>
<header>
<div class="logo">
<div class="logo-icon">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21c0 1 0 1 1 1z"/>
<path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/>
</svg>
</div>
Quotient
</div>
<div style="display: flex; gap: 0.5rem;">
<button class="btn-secondary" onclick="shareQuote()" aria-label="Share quote">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display: inline; vertical-align: middle; margin-right: 4px;">
<circle cx="18" cy="5" r="3"/>
<circle cx="6" cy="12" r="3"/>
<circle cx="18" cy="19" r="3"/>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/>
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>
</svg>
Share
</button>
<button class="btn-secondary" onclick="copyQuote()" aria-label="Copy quote to clipboard">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display: inline; vertical-align: middle; margin-right: 4px;">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
Copy
</button>
</div>
</header>
<main>
<div class="quote-container">
<div class="quote-card" id="quoteCard">
<div class="quote-mark">"</div>
<div id="quoteContent">
<div class="loading">
<div class="loading-dot"></div>
<div class="loading-dot"></div>
<div class="loading-dot"></div>
</div>
</div>
</div>
<div class="controls">
<button class="btn-primary" id="newQuoteBtn" onclick="fetchNewQuote()">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/>
<path d="M21 3v5h-5"/>
</svg>
New Quote
</button>
</div>
<div class="stats">
<div class="stat">
<div class="stat-value" id="quoteCount">0</div>
<div class="stat-label">Quotes Generated</div>
</div>
<div class="stat">
<div class="stat-value" id="copyCount">0</div>
<div class="stat-label">Times Copied</div>
</div>
</div>
</div>
</main>
<div class="toast" id="toast">
<div class="toast-icon">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12"/>
</svg>
</div>
<span id="toastMessage">Copied to clipboard!</span>
</div>
<script>
// State
let currentQuote = null;
let quoteCount = 0;
let copyCount = 0;
let isLoading = false;
// Fallback quotes in case API fails
const fallbackQuotes = [
{
content: "The only way to do great work is to love what you do.",
author: "Steve Jobs",
tags: ["motivation", "work"]
},
{
content: "Innovation distinguishes between a leader and a follower.",
author: "Steve Jobs",
tags: ["innovation", "leadership"]
},
{
content: "Stay hungry, stay foolish.",
author: "Steve Jobs",
tags: ["motivation"]
},
{
content: "The future belongs to those who believe in the beauty of their dreams.",
author: "Eleanor Roosevelt",
tags: ["dreams", "future"]
},
{
content: "It is during our darkest moments that we must focus to see the light.",
author: "Aristotle",
tags: ["perseverance", "hope"]
},
{
content: "The only impossible journey is the one you never begin.",
author: "Tony Robbins",
tags: ["action", "beginnings"]
},
{
content: "Success is not final, failure is not fatal: it is the courage to continue that counts.",
author: "Winston Churchill",
tags: ["success", "courage"]
},
{
content: "What lies behind us and what lies before us are tiny matters compared to what lies within us.",
author: "Ralph Waldo Emerson",
tags: ["inner-strength", "wisdom"]
},
{
content: "The greatest glory in living lies not in never falling, but in rising every time we fall.",
author: "Nelson Mandela",
tags: ["resilience", "glory"]
},
{
content: "Life is what happens when you're busy making other plans.",
author: "John Lennon",
tags: ["life", "planning"]
}
];
// Get initials from author name
function getInitials(name) {
return name
.split(' ')
.map(word => word[0])
.join('')
.substring(0, 2)
.toUpperCase();
}
// Animate words one by one
function animateQuote(text) {
const words = text.split(' ');
const html = words.map((word, i) =>
`<span class="word-animate" style="animation-delay: ${i * 0.05}s">${word}</span>`
).join(' ');
return html;
}
// Render quote
function renderQuote(quote) {
currentQuote = quote;
const content = document.getElementById('quoteContent');
// Fade out current content
content.style.opacity = '0';
content.style.transform = 'translateY(-20px)';
setTimeout(() => {
content.innerHTML = `
<p class="quote-text">${animateQuote(quote.content)}</p>
<div class="quote-author fade-in" style="animation-delay: 0.3s">
<div class="author-avatar">${getInitials(quote.author)}</div>
<div class="author-info">
<div class="author-name">${quote.author}</div>
<div class="author-tags">
${(quote.tags || ['wisdom']).map(tag => `<span class="tag">${tag}</span>`).join('')}
</div>
</div>
</div>
`;
// Reset and animate in
content.style.opacity = '1';
content.style.transform = 'translateY(0)';
content.style.transition = 'all 0.4s ease-out';
// Update stats
quoteCount++;
document.getElementById('quoteCount').textContent = quoteCount;
}, 300);
}
// Fetch quote from API
async function fetchNewQuote() {
if (isLoading) return;
isLoading = true;
const btn = document.getElementById('newQuoteBtn');
btn.innerHTML = '<div class="spinner"></div> Loading...';
btn.disabled = true;
try {
// Using quotable.io API
const response = await fetch('https://api.quotable.io/random');
if (!response.ok) throw new Error('API failed');
const data = await response.json();
renderQuote({
content: data.content,
author: data.author,
tags: data.tags
});
} catch (error) {
console.log('API unavailable, using fallback');
// Use random fallback quote
const randomQuote = fallbackQuotes[Math.floor(Math.random() * fallbackQuotes.length)];
renderQuote(randomQuote);
} finally {
isLoading = false;
btn.innerHTML = `
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/>
<path d="M21 3v5h-5"/>
</svg>
New Quote
`;
btn.disabled = false;
}
}
// Show toast notification
function showToast(message) {
const toast = document.getElementById('toast');
document.getElementById('toastMessage').textContent = message;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
// Copy quote to clipboard
function copyQuote() {
if (!currentQuote) return;
const text = `"${currentQuote.content}" — ${currentQuote.author}`;
navigator.clipboard.writeText(text).then(() => {
copyCount++;
document.getElementById('copyCount').textContent = copyCount;
showToast('Copied to clipboard!');
}).catch(() => {
showToast('Failed to copy');
});
}
// Share quote
function shareQuote() {
if (!currentQuote) return;
const text = `"${currentQuote.content}" — ${currentQuote.author}`;
if (navigator.share) {
navigator.share({
title: 'Quote from Quotient',
text: text
}).catch(() => {});
} else {
// Fallback: copy to clipboard
copyQuote();
}
}
// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
if (e.code === 'Space' && !e.target.closest('button')) {
e.preventDefault();
fetchNewQuote();
}
if (e.code === 'KeyC' && (e.metaKey || e.ctrlKey)) {
copyQuote();
}
});
// Initialize
fetchNewQuote();
</script>
</body>
</html>
Wait, let me review this:
- I have fallback quotes in case API fails
- I have animated transitions
- I'm using a distinctive design
- The code is clean and organized
But I need to double-check:
- No title glowing
- No emoji
- Not default colors
The design is dark with amber accent - that's good. No emojis. No glowing title.
Let me refine the code a bit more and make sure it's polished.
Random Quote Generator
I'll create a visually striking quote generator with smooth animations, API integration, and fallback quotes for reliability.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quotient - Random Quote Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0c0c0e;
--bg-card: rgba(22, 22, 26, 0.8);
--fg: #f4f4f5;
--muted: #71717a;
--accent: #e07b39;
--accent-dim: rgba(224, 123, 57, 0.15);
--border: rgba(255, 255, 255, 0.06);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
/* Atmospheric Background */
.atmosphere {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 0;
}
.atmosphere::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background:
radial-gradient(ellipse 40% 30% at 20% 20%, rgba(224, 123, 57, 0.08), transparent 50%),
radial-gradient(ellipse 35% 40% at 80% 70%, rgba(224, 123, 57, 0.05), transparent 50%);
animation: atmosphereShift 30s ease-in-out infinite;
}
@keyframes atmosphereShift {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
50% { transform: translate(-5%, 3%) rotate(2deg); }
}
.grid-overlay {
position: fixed;
inset: 0;
background-image:
linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
background-size: 80px 80px;
pointer-events: none;
z-index: 0;
}
/* Floating geometric elements */
.geo-container {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
z-index: 0;
}
.geo {
position: absolute;
border: 1px solid var(--border);
opacity: 0.4;
}
.geo-1 {
width: 300px;
height: 300px;
top: 5%;
left: -5%;
border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%;
animation: geoFloat1 25s ease-in-out infinite;
}
.geo-2 {
width: 200px;
height: 200px;
bottom: 10%;
right: 5%;
border-radius: 50%;
animation: geoFloat2 20s ease-in-out infinite;
}
.geo-3 {
width: 120px;
height: 120px;
top: 40%;
right: 15%;
animation: geoFloat3 18s ease-in-out infinite;
}
@keyframes geoFloat1 {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
33% { transform: translate(30px, 20px) rotate(10deg); }
66% { transform: translate(-20px, 40px) rotate(-5deg); }
}
@keyframes geoFloat2 {
0%, 100% { transform: translate(0, 0) scale(1); }
50% { transform: translate(-40px, -30px) scale(1.1); }
}
@keyframes geoFloat3 {
0%, 100% { transform: rotate(45deg); }
50% { transform: rotate(90deg) translateX(20px); }
}
/* Header */
header {
position: relative;
z-index: 10;
padding: 1.5rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
font-size: 1.25rem;
letter-spacing: -0.02em;
}
.logo-mark {
width: 36px;
height: 36px;
background: linear-gradient(135deg, var(--accent), #c45d1f);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
color: white;
}
.header-actions {
display: flex;
gap: 0.75rem;
}
/* Buttons */
.btn {
font-family: inherit;
font-size: 0.875rem;
font-weight: 500;
padding: 0.625rem 1rem;
border-radius: 10px;
border: none;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.5rem;
transition: all 0.25s ease;
}
.btn-ghost {
background: transparent;
color: var(--muted);
border: 1px solid transparent;
}
.btn-ghost:hover {
color: var(--fg);
background: rgba(255,255,255,0.04);
}
.btn-ghost:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.btn-primary {
background: var(--accent);
color: white;
font-size: 1rem;
font-weight: 600;
padding: 1rem 2rem;
border-radius: 14px;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 12px 32px rgba(224, 123, 57, 0.35);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-primary:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 3px;
}
.btn-primary:disabled {
opacity: 0.7;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
/* Main content */
main {
position: relative;
z-index: 10;
min-height: calc(100vh - 120px);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 2rem;
}
.quote-wrapper {
max-width: 880px;
width: 100%;
}
.quote-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 28px;
padding: 3.5rem;
position: relative;
backdrop-filter: blur(24px);
overflow: hidden;
}
.quote-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}
.quote-decoration {
position: absolute;
top: 24px;
left: 32px;
font-family: 'Instrument Serif', serif;
font-size: 14rem;
line-height: 1;
color: var(--accent);
opacity: 0.08;
pointer-events: none;
user-select: none;
}
.quote-content {
position: relative;
z-index: 1;
min-height: 180px;
transition: opacity 0.3s ease, transform 0.3s ease;
}
.quote-text {
font-family: 'Instrument Serif', serif;
font-size: clamp(1.5rem, 4.5vw, 2.75rem);
font-style: italic;
line-height: 1.5;
letter-spacing: -0.01em;
color: var(--fg);
}
.quote-text .word {
display: inline-block;
opacity: 0;
transform: translateY(24px) rotateX(-10deg);
animation: wordReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes wordReveal {
to {
opacity: 1;
transform: translateY(0) rotateX(0);
}
}
.quote-meta {
margin-top: 2.5rem;
padding-top: 2rem;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 1.25rem;
opacity: 0;
animation: fadeSlideUp 0.6s ease forwards;
animation-delay: 0.4s;
}
@keyframes fadeSlideUp {
from {
opacity: 0;
transform: translateY(16px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.author-avatar {
width: 52px;
height: 52px;
border-radius: 50%;
background: linear-gradient(135deg, var(--accent), #9c4a1c);
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 1rem;
color: white;
flex-shrink: 0;
}
.author-details {
flex: 1;
}
.author-name {
font-weight: 600;
font-size: 1.125rem;
margin-bottom: 0.375rem;
}
.quote-tags {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.tag {
font-size: 0.75rem;
font-weight: 500;
padding: 0.25rem 0.875rem;
background: var(--accent-dim);
color: var(--accent);
border-radius: 100px;
}
/* Loading state */
.loader {
display: flex;
justify-content: center;
align-items: center;
gap: 0.625rem;
min-height: 180px;
}
.loader-dot {
width: 10px;
height: 10px;
background: var(--accent);
border-radius: 50%;
animation: loaderPulse 1.2s ease-in-out infinite;
}
.loader-dot:nth-child(2) { animation-delay: 0.15s; }
.loader-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes loaderPulse {
0%, 80%, 100% {
transform: scale(0.6);
opacity: 0.4;
}
40% {
transform: scale(1);
opacity: 1;
}
}
/* Spinner */
.spinner {
width: 18px;
height: 18px;
border: 2px solid rgba(255,255,255,0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.7s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Controls */
.controls {
display: flex;
justify-content: center;
margin-top: 2.5rem;
}
/* Stats */
.stats-bar {
display: flex;
justify-content: center;
gap: 3rem;
margin-top: 3rem;
flex-wrap: wrap;
}
.stat-item {
text-align: center;
}
.stat-number {
font-size: 2.25rem;
font-weight: 700;
color: var(--accent);
letter-spacing: -0.02em;
}
.stat-label {
font-size: 0.8125rem;
color: var(--muted);
margin-top: 0.25rem;
}
/* Toast */
.toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(120%);
background: #1a1a1e;
border: 1px solid var(--border);
padding: 0.875rem 1.5rem;
border-radius: 14px;
display: flex;
align-items: center;
gap: 0.625rem;
z-index: 100;
opacity: 0;
transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.visible {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
.toast svg {
color: var(--accent);
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
.geo,
.atmosphere::before,
.quote-text .word,
.quote-meta {
animation: none;
}
.quote-text .word {
opacity: 1;
transform: none;
}
.quote-meta {
opacity: 1;
transform: none;
}
.btn-primary:hover {
transform: none;
}
}
/* Responsive */
@media (max-width: 640px) {
header {
padding: 1rem;
}
.quote-card {
padding: 2rem;
border-radius: 20px;
}
.quote-decoration {
font-size: 8rem;
top: 12px;
left: 16px;
}
.quote-meta {
flex-direction: column;
text-align: center;
}
.stats-bar {
gap: 2rem;
}
}
</style>
</head>
<body>
<div class="atmosphere"></div>
<div class="grid-overlay"></div>
<div class="geo-container">
<div class="geo geo-1"></div>
<div class="geo geo-2"></div>
<div class="geo geo-3"></div>
</div>
<header>
<div class="logo">
<div class="logo-mark">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21"/>
<path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/>
</svg>
</div>
Quotient
</div>
<div class="header-actions">
<button class="btn btn-ghost" id="copyBtn" aria-label="Copy quote">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
Copy
</button>
<button class="btn btn-ghost" id="shareBtn" aria-label="Share quote">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="18" cy="5" r="3"/>
<circle cx="6" cy="12" r="3"/>
<circle cx="18" cy="19" r="3"/>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/>
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>
</svg>
Share
</button>
</div>
</header>
<main>
<div class="quote-wrapper">
<div class="quote-card">
<div class="quote-decoration">"</div>
<div class="quote-content" id="quoteContent">
<div class="loader">
<div class="loader-dot"></div>
<div class="loader-dot"></div>
<div class="loader-dot"></div>
</div>
</div>
</div>
<div class="controls">
<button class="btn btn-primary" id="newQuoteBtn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/>
<path d="M21 3v5h-5"/>
</svg>
Generate Quote
</button>
</div>
<div class="stats-bar">
<div class="stat-item">
<div class="stat-number" id="generatedCount">0</div>
<div class="stat-label">Quotes Generated</div>
</div>
<div class="stat-item">
<div class="stat-number" id="copiedCount">0</div>
<div class="stat-label">Times Copied</div>
</div>
</div>
</div>
</main>
<div class="toast" id="toast">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"/>
</svg>
<span id="toastMessage">Copied to clipboard</span>
</div>
<script>
// Initialize state
const state = {
currentQuote: null,
generatedCount: 0,
copiedCount: 0,
isLoading: false
};
// Fallback quotes (used when API is unavailable)
const fallbackQuotes = [
{ content: "The only way to do great work is to love what you do.", author: "Steve Jobs", tags: ["motivation", "work"] },
{ content: "Innovation distinguishes between a leader and a follower.", author: "Steve Jobs", tags: ["innovation", "leadership"] },
{ content: "The future belongs to those who believe in the beauty of their dreams.", author: "Eleanor Roosevelt", tags: ["dreams", "inspiration"] },
{ content: "It is during our darkest moments that we must focus to see the light.", author: "Aristotle", tags: ["perseverance", "hope"] },
{ content: "The only impossible journey is the one you never begin.", author: "Tony Robbins", tags: ["action", "beginnings"] },
{ content: "Success is not final, failure is not fatal: it is the courage to continue that counts.", author: "Winston Churchill", tags: ["success", "courage"] },
{ content: "What lies behind us and what lies before us are tiny matters compared to what lies within us.", author: "Ralph Waldo Emerson", tags: ["strength", "wisdom"] },
{ content: "The greatest glory in living lies not in never falling, but in rising every time we fall.", author: "Nelson Mandela", tags: ["resilience", "glory"] },
{ content: "Life is what happens when you're busy making other plans.", author: "John Lennon", tags: ["life", "perspective"] },
{ content: "The way to get started is to quit talking and begin doing.", author: "Walt Disney", tags: ["action", "creativity"] },
{ content: "Your time is limited, don't waste it living someone else's life.", author: "Steve Jobs", tags: ["authenticity", "time"] },
{ content: "If life were predictable it would cease to be life, and be without flavor.", author: "Eleanor Roosevelt", tags: ["life", "unpredictability"] },
{ content: "Spread love everywhere you go. Let no one ever come to you without leaving happier.", author: "Mother Teresa", tags: ["love", "kindness"] },
{ content: "When you reach the end of your rope, tie a knot in it and hang on.", author: "Franklin D. Roosevelt", tags: ["perseverance", "determination"] },
{ content: "Always remember that you are absolutely unique. Just like everyone else.", author: "Margaret Mead", tags: ["individuality", "humor"] }
];
// DOM Elements
const quoteContent = document.getElementById('quoteContent');
const newQuoteBtn = document.getElementById('newQuoteBtn');
const copyBtn = document.getElementById('copyBtn');
const shareBtn = document.getElementById('shareBtn');
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toastMessage');
const generatedCountEl = document.getElementById('generatedCount');
const copiedCountEl = document.getElementById('copiedCount');
// Utility: Get initials from name
function getInitials(name) {
if (!name) return '??';
return name
.split(' ')
.filter(word => word.length > 0)
.map(word => word[0])
.join('')
.substring(0, 2)
.toUpperCase();
}
// Utility: Escape HTML
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Animate quote words
function createAnimatedQuote(text) {
const words = text.split(' ');
return words
.map((word, index) => {
const delay = Math.min(index * 0.04, 0.8);
return `<span class="word" style="animation-delay: ${delay}s">${escapeHtml(word)}</span>`;
})
.join(' ');
}
// Render quote
function renderQuote(quote) {
state.currentQuote = quote;
// Animate out
quoteContent.style.opacity = '0';
quoteContent.style.transform = 'translateY(-16px)';
setTimeout(() => {
quoteContent.innerHTML = `
<p class="quote-text">${createAnimatedQuote(quote.content)}</p>
<div class="quote-meta">
<div class="author-avatar">${getInitials(quote.author)}</div>
<div class="author-details">
<div class="author-name">${escapeHtml(quote.author)}</div>
<div class="quote-tags">
${(quote.tags || ['wisdom']).map(tag => `<span class="tag">${escapeHtml(tag)}</span>`).join('')}
</div>
</div>
</div>
`;
// Animate in
quoteContent.style.opacity = '1';
quoteContent.style.transform = 'translateY(0)';
// Update stats
state.generatedCount++;
generatedCountEl.textContent = state.generatedCount;
}, 280);
}
// Show loading state
function showLoader() {
quoteContent.innerHTML = `
<div class="loader">
<div class="loader-dot"></div>
<div class="loader-dot"></div>
<div class="loader-dot"></div>
</div>
`;
}
// Fetch quote from API
async function fetchQuote() {
if (state.isLoading) return;
state.isLoading = true;
newQuoteBtn.disabled = true;
newQuoteBtn.innerHTML = '<div class="spinner"></div> Loading...';
try {
const response = await fetch('https://api.quotable.io/random');
if (!response.ok) throw new Error('API request failed');
const data = await response.json();
renderQuote({
content: data.content,
author: data.author,
tags: data.tags
});
} catch (error) {
console.warn('API unavailable, using fallback:', error.message);
const randomQuote = fallbackQuotes[Math.floor(Math.random() * fallbackQuotes.length)];
renderQuote(randomQuote);
} finally {
state.isLoading = false;
newQuoteBtn.disabled = false;
newQuoteBtn.innerHTML = `
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/>
<path d="M21 3v5h-5"/>
</svg>
Generate Quote
`;
}
}
// Show toast notification
function showToast(message) {
toastMessage.textContent = message;
toast.classList.add('visible');
setTimeout(() => {
toast.classList.remove('visible');
}, 2500);
}
// Copy quote to clipboard
function copyQuote() {
if (!state.currentQuote) {
showToast('No quote to copy');
return;
}
const text = `"${state.currentQuote.content}" — ${state.currentQuote.author}`;
navigator.clipboard.writeText(text)
.then(() => {
state.copiedCount++;
copiedCountEl.textContent = state.copiedCount;
showToast('Copied to clipboard');
})
.catch(() => {
showToast('Failed to copy');
});
}
// Share quote
function shareQuote() {
if (!state.currentQuote) {
showToast('No quote to share');
return;
}
const text = `"${state.currentQuote.content}" — ${state.currentQuote.author}`;
if (navigator.share) {
navigator.share({
title: 'Quote from Quotient',
text: text
}).catch(() => {});
} else {
copyQuote();
showToast('Copied for sharing');
}
}
// Event listeners
newQuoteBtn.addEventListener('click', fetchQuote);
copyBtn.addEventListener('click', copyQuote);
shareBtn.addEventListener('click', shareQuote);
// Keyboard shortcuts
document.addEventListener('keydown', (event) => {
// Space or Enter to generate new quote
if ((event.code === 'Space' || event.code === 'Enter') &&
!event.target.closest('button') &&
!event.target.closest('input')) {
event.preventDefault();
fetchQuote();
}
// C to copy
if (event.code === 'KeyC' && !event.metaKey && !event.ctrlKey &&
!event.target.closest('input') && !event.target.closest('textarea')) {
copyQuote();
}
});
// Initialize
fetchQuote();
</script>
</body>
</html>
Design Highlights
Visual Identity:
- Deep charcoal background with warm amber/orange accent (#e07b39)
- Editorial serif font (Instrument Serif) for quotes paired with Space Grotesk for UI
- Layered atmospheric gradients and animated geometric shapes
Interactions:
- Word-by-word reveal animation - Each word animates in with staggered delays
- Smooth fade transitions - Quotes transition with elegant fade/slide effects
- Button states - Hover lift with shadow, loading spinner, disabled states
- Toast notifications - Slide-up confirmation for copy/share actions
API Integration:
- Fetches from
api.quotable.io
- Falls back to 15 curated quotes if the API is unavailable
- Loading state with animated dots while fetching
Additional Features:
- Copy to clipboard with one click
- Web Share API integration (falls back to copy on desktop)
- Stats tracking (quotes generated, times copied)
- Keyboard shortcuts:
Space for new quote, C to copy
- Full accessibility with focus states and reduced motion support
- Responsive design from 375px to 1440px+