MattWorksAW's picture
on the source page https://www.google.com/?pli=1 the radial gradient of the "AI mode" button changes based on cursor x position within the button, can we do that here as well?
8b885b9 verified
Raw History Blame Contribute Delete
3.38 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google AI Mode Button Clone</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500&display=swap');
.google-btn {
font-family: 'Google Sans', Arial, sans-serif;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.google-btn:hover {
box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}
.google-btn:active {
background-color: #f1f3f4;
}
.magic-sparkle {
background: radial-gradient(circle at center, #4285F4, #34A853, #FBBC05, #EA4335);
background-size: 200% 200%;
transition: background-position 0.1s ease-out;
}
</style>
</head>
<body class="bg-white min-h-screen flex items-center justify-center">
<div class="relative">
<button id="aiModeButton" class="google-btn flex items-center justify-center bg-white text-[#1a73e8] border border-[#dadce0] rounded-full py-2 px-4 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-[#1a73e8]/50">
<div class="flex items-center space-x-2">
<div class="w-5 h-5 rounded-full magic-sparkle flex items-center justify-center">
<div class="w-3 h-3 bg-white rounded-full"></div>
</div>
<span>AI mode</span>
</div>
</button>
</div>
<script>
const aiButton = document.getElementById('aiModeButton');
const magicSparkle = document.querySelector('.magic-sparkle');
aiButton.addEventListener('mousemove', function(e) {
const rect = this.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const percentX = (x / rect.width) * 100;
const percentY = (y / rect.height) * 100;
magicSparkle.style.background = `radial-gradient(circle at ${percentX}% ${percentY}%, #4285F4, #34A853, #FBBC05, #EA4335)`;
magicSparkle.style.backgroundSize = '200% 200%';
});
aiButton.addEventListener('mouseleave', function() {
magicSparkle.style.background = 'radial-gradient(circle at center, #4285F4, #34A853, #FBBC05, #EA4335)';
});
aiButton.addEventListener('click', function() {
// Create ripple effect
const ripple = document.createElement('span');
ripple.classList.add('absolute', 'rounded-full', 'bg-[#1a73e8]/10', 'animate-ripple');
ripple.style.width = '100%';
ripple.style.height = '100%';
ripple.style.top = '0';
ripple.style.left = '0';
this.appendChild(ripple);
// Remove ripple after animation
setTimeout(() => {
ripple.remove();
}, 600);
// Simulate original behavior (you would replace this with actual functionality)
console.log('AI Mode activated!');
// Toggle active state
this.classList.toggle('bg-[#f1f3f4]');
});
</script>
</body>
</html>