Files
cv-site/tests/test-bottom-buttons.html
T

217 lines
6.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bottom Buttons Test</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: Arial, sans-serif;
min-height: 300vh; /* Make page scrollable */
background: linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%);
}
.test-info {
position: fixed;
top: 20px;
left: 20px;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
z-index: 1000;
max-width: 400px;
}
.test-info h2 {
margin-top: 0;
color: #333;
}
.status {
margin: 10px 0;
padding: 10px;
border-radius: 4px;
font-family: monospace;
}
.status.at-bottom {
background: #27ae60;
color: white;
}
.status.not-bottom {
background: #e0e0e0;
color: #333;
}
/* Copy styles from main.css */
.back-to-top {
position: fixed;
bottom: 2rem;
right: 2rem;
width: 35px;
height: 35px;
background: #2a2a2a;
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
z-index: 99;
transition: all 0.3s ease;
opacity: 0.2;
font-size: 20px;
}
.back-to-top:hover {
opacity: 1;
transform: translateY(-3px) scale(1.43);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
background: #3a3a3a;
}
.back-to-top.at-bottom {
opacity: 1;
background: #27ae60;
}
.info-button {
position: fixed;
bottom: 2rem;
left: 2rem;
width: 50px;
height: 50px;
background: #2a2a2a;
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
z-index: 99;
transition: all 0.3s ease;
opacity: 0.2;
font-size: 24px;
}
.info-button:hover {
opacity: 1;
transform: translateY(-3px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
background: #3a3a3a;
}
.info-button.at-bottom {
opacity: 1;
background: #27ae60;
}
.content-marker {
padding: 20px;
margin: 50px 0;
background: white;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="test-info">
<h2>🧪 Bottom Buttons Test</h2>
<p>Scroll to the bottom to see the buttons turn green!</p>
<div id="status" class="status not-bottom">
Not at bottom
</div>
<div style="margin-top: 15px;">
<strong>Current Scroll:</strong> <span id="scroll-pos">0</span>px<br>
<strong>Distance from Bottom:</strong> <span id="distance">0</span>px
</div>
</div>
<div class="content-marker">
<h1>Top of Page</h1>
<p>Start scrolling down to test the bottom detection...</p>
</div>
<div class="content-marker" style="margin-top: 100vh;">
<h2>Middle Section</h2>
<p>Keep scrolling...</p>
</div>
<div class="content-marker" style="margin-top: 100vh;">
<h2>Almost There...</h2>
<p>Just a bit more...</p>
</div>
<div class="content-marker" style="margin-top: 50vh; margin-bottom: 100px;">
<h2>🎯 Bottom of Page</h2>
<p>You should see the buttons turn green now!</p>
<p><strong>The info button (️ bottom-left) and back-to-top button (↑ bottom-right) should both be GREEN when you're at the bottom.</strong></p>
</div>
<!-- Test buttons -->
<button class="info-button" onclick="alert('Info button clicked!')"></button>
<button class="back-to-top" onclick="window.scrollTo({top: 0, behavior: 'smooth'})"></button>
<script>
// Test implementation matching the actual code
function updateBottomStatus() {
const currentScroll = window.pageYOffset || document.documentElement.scrollTop;
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
const distanceFromBottom = scrollHeight - currentScroll - clientHeight;
const isAtBottom = distanceFromBottom < 50;
// Update test info
const statusDiv = document.getElementById('status');
const scrollPos = document.getElementById('scroll-pos');
const distance = document.getElementById('distance');
scrollPos.textContent = Math.round(currentScroll);
distance.textContent = Math.round(distanceFromBottom);
if (isAtBottom) {
statusDiv.textContent = '✅ AT BOTTOM - Buttons should be GREEN!';
statusDiv.className = 'status at-bottom';
} else {
statusDiv.textContent = '❌ Not at bottom yet';
statusDiv.className = 'status not-bottom';
}
// Update button states
const backToTopBtn = document.querySelector('.back-to-top');
const infoBtn = document.querySelector('.info-button');
if (isAtBottom) {
backToTopBtn.classList.add('at-bottom');
infoBtn.classList.add('at-bottom');
} else {
backToTopBtn.classList.remove('at-bottom');
infoBtn.classList.remove('at-bottom');
}
// Show back-to-top button when scrolled down
if (currentScroll > 300) {
backToTopBtn.style.display = 'flex';
} else {
backToTopBtn.style.display = 'none';
}
}
// Update on scroll
window.addEventListener('scroll', updateBottomStatus);
// Initial update
updateBottomStatus();
</script>
</body>
</html>