2ebb9f5293
**Bug 1: Wrong at-bottom colors** - All buttons were showing orange (#f39c12) when at bottom - User wanted each button to use its own hover color **Bug 2: Zoom button missing at-bottom state** - Zoom/search button wasn't changing color at bottom **Fix - Updated .at-bottom styles to match hover colors:** Download PDF button: - Was: Orange (#f39c12) - Now: PDF Red (#cd6060) - matches hover Print Friendly button: - Was: Orange (#f39c12) - Now: White background + Green icon (#27ae60) - matches hover Shortcuts button: - Kept: Orange (#f39c12) - already correct Color Theme Switcher: - Was: Uniform orange - Now: Dynamic colors based on theme mode - Light mode: Yellow (#f39c12) - Dark mode: Blue (#3498db) - Auto mode: Purple (#9b59b6) Info button: - Already correct: Green (#27ae60) Back-to-top button: - Already correct: Green (#27ae60) Zoom button: - Added: Blue (#3498db) - matches hover - Added to scroll handler in utils._hs **Result**: Each button now shows its characteristic color when page is scrolled to bottom, providing consistent visual feedback that matches the hover state. Files changed: - static/hyperscript/utils._hs: Added zoom button - static/css/main.css: Updated 3 button colors - static/css/color-theme.css: Dynamic theme colors
142 lines
4.3 KiB
Plaintext
142 lines
4.3 KiB
Plaintext
-- ==============================================================================
|
|
-- CV Site - Hyperscript Functions
|
|
-- ==============================================================================
|
|
-- Global hyperscript functions for CV interactive features
|
|
-- Keeps HTML templates clean and behavior organized
|
|
|
|
-- ==============================================================================
|
|
-- PRINT FUNCTIONS
|
|
-- ==============================================================================
|
|
|
|
def printFriendly()
|
|
-- Store current state
|
|
set container to the first .cv-container
|
|
set paper to the first .cv-paper
|
|
set wasClean to container.classList.contains('theme-clean')
|
|
set wasLong to paper.classList.contains('cv-long')
|
|
set currentZoom to localStorage.getItem('cv-zoom') or '100'
|
|
|
|
-- Apply print-friendly settings
|
|
if wasClean is false
|
|
add .theme-clean to container
|
|
end
|
|
remove .cv-long from paper
|
|
add .cv-short to paper
|
|
|
|
-- Reset zoom for consistent printing
|
|
set #zoom-wrapper's *zoom to 1
|
|
|
|
-- Let CSS apply, then print
|
|
wait 50ms
|
|
call window.print()
|
|
|
|
-- Wait for print dialog to close, then restore
|
|
wait 100ms
|
|
|
|
-- Restore original theme
|
|
if wasClean is false
|
|
remove .theme-clean from container
|
|
end
|
|
|
|
-- Restore original length
|
|
if wasLong is true
|
|
remove .cv-short from paper
|
|
add .cv-long to paper
|
|
end
|
|
|
|
-- Restore original zoom by triggering slider input event
|
|
if currentZoom is not '100'
|
|
set #zoom-slider's value to currentZoom
|
|
send input to #zoom-slider
|
|
end
|
|
end
|
|
|
|
-- ==============================================================================
|
|
-- SCROLL BEHAVIOR
|
|
-- ==============================================================================
|
|
|
|
def initScrollBehavior()
|
|
set :lastScroll to 0
|
|
set :scrollThreshold to 100
|
|
set :keepHeaderVisible to false
|
|
end
|
|
|
|
def handleScroll()
|
|
set currentScroll to window.pageYOffset
|
|
set menu to the first .navigation-menu
|
|
set isMenuOpen to menu.classList.contains('menu-open')
|
|
|
|
-- Calculate if at bottom (within 50px)
|
|
set scrollHeight to document.documentElement.scrollHeight
|
|
set clientHeight to document.documentElement.clientHeight
|
|
set isAtBottom to (scrollHeight - currentScroll - clientHeight) < 50
|
|
|
|
-- Reset keepHeaderVisible when scrolling up
|
|
if currentScroll < :lastScroll
|
|
set :keepHeaderVisible to false
|
|
end
|
|
|
|
-- Header visibility: Scrolling down past threshold
|
|
if currentScroll > :scrollThreshold and currentScroll > :lastScroll and :keepHeaderVisible is false
|
|
add .header-hidden to .action-bar
|
|
if isMenuOpen is true
|
|
add .header-hidden to menu
|
|
end
|
|
end
|
|
|
|
-- Header visibility: Scrolling up past threshold
|
|
if currentScroll > :scrollThreshold and (currentScroll <= :lastScroll or :keepHeaderVisible is true)
|
|
remove .header-hidden from .action-bar
|
|
if isMenuOpen is true
|
|
remove .header-hidden from menu
|
|
end
|
|
end
|
|
|
|
-- Header visibility: At top
|
|
if currentScroll <= :scrollThreshold
|
|
remove .header-hidden from .action-bar
|
|
if isMenuOpen is true
|
|
remove .header-hidden from menu
|
|
end
|
|
end
|
|
|
|
-- Back to top button visibility
|
|
if currentScroll > 300
|
|
set #back-to-top's *display to 'flex'
|
|
end
|
|
|
|
if currentScroll <= 300
|
|
set #back-to-top's *display to 'none'
|
|
end
|
|
|
|
-- At-bottom class for fixed buttons
|
|
if isAtBottom
|
|
add .at-bottom to #back-to-top
|
|
add .at-bottom to #info-button
|
|
add .at-bottom to #shortcuts-button
|
|
add .at-bottom to #download-button
|
|
add .at-bottom to #print-friendly-button
|
|
add .at-bottom to .color-theme-switcher
|
|
add .at-bottom to #zoom-toggle-button
|
|
end
|
|
|
|
if not isAtBottom
|
|
remove .at-bottom from #back-to-top
|
|
remove .at-bottom from #info-button
|
|
remove .at-bottom from #shortcuts-button
|
|
remove .at-bottom from #download-button
|
|
remove .at-bottom from #print-friendly-button
|
|
remove .at-bottom from .color-theme-switcher
|
|
remove .at-bottom from #zoom-toggle-button
|
|
end
|
|
|
|
-- Update last scroll position
|
|
set :lastScroll to currentScroll
|
|
end
|
|
|
|
-- ==============================================================================
|
|
-- KEYBOARD SHORTCUTS
|
|
-- ==============================================================================
|
|
-- Note: Keyboard event handlers are now defined inline in the body tag
|
|
-- because hyperscript 0.9.12 doesn't support nested event handlers (on ... inside def)
|