feat: add font size customization with slider control

Implemented global font size scaling with range slider:
- Adjustable from 80% to 140% in 10% increments
- Slider in Appearance tab with live value display
- Persistent preference saved to localStorage
- Updates CSS custom property --base-font-size
- Scales entire UI proportionally from 11.2px to 19.6px
- Smooth transitions with styled slider thumb
- Live preview as you drag the slider

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-14 12:34:09 -07:00
parent 30e6af61ca
commit 84d3e0df67
3 changed files with 118 additions and 0 deletions

View File

@@ -170,6 +170,37 @@ function loadSavedViewMode() {
applyViewMode(savedMode);
}
// Apply font size
function applyFontSize(scale) {
const root = document.documentElement;
// Calculate font size based on scale (80-140%)
const baseFontSize = 14; // Default base size in px
const newFontSize = (baseFontSize * scale) / 100;
root.style.setProperty('--base-font-size', `${newFontSize}px`);
root.style.fontSize = `${newFontSize}px`;
// Update the display value
const fontSizeValue = document.getElementById('font-size-value');
if (fontSizeValue) {
fontSizeValue.textContent = `${scale}%`;
}
// Store preference
localStorage.setItem('claudia-font-size', scale.toString());
}
// Load saved font size
function loadSavedFontSize() {
const savedSize = parseInt(localStorage.getItem('claudia-font-size') || '100');
const fontSizeSlider = document.getElementById('font-size-slider');
if (fontSizeSlider) {
fontSizeSlider.value = savedSize;
}
applyFontSize(savedSize);
}
// Helper function to get avatar URL
async function getAvatarUrl(avatarFilename) {
if (!avatarFilename) return null;
@@ -1211,6 +1242,14 @@ function setupAppControls() {
applyViewMode(e.target.value);
});
}
// Setup font size slider
const fontSizeSlider = document.getElementById('font-size-slider');
if (fontSizeSlider) {
fontSizeSlider.addEventListener('input', (e) => {
applyFontSize(parseInt(e.target.value));
});
}
}
// Keyboard shortcuts
@@ -1608,6 +1647,7 @@ window.addEventListener('DOMContentLoaded', () => {
// Load saved preferences before anything else
loadSavedTheme();
loadSavedViewMode();
loadSavedFontSize();
loadExistingConfig();
});