2024-10-01 12:45:21 +02:00
|
|
|
// FontSizeSetting.tsx
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
interface FontSizeSettingProps {
|
2024-10-11 09:30:37 +02:00
|
|
|
fontSize: string; // The current font size as a string (e.g., "16px")
|
2024-10-01 12:45:21 +02:00
|
|
|
setFontSize: (newSize: string) => void; // Function to update the font size
|
|
|
|
}
|
|
|
|
|
|
|
|
const FontSizeSetting: React.FC<FontSizeSettingProps> = ({ fontSize, setFontSize }) => {
|
2024-10-11 09:30:37 +02:00
|
|
|
// Handle changes to the font size input
|
2024-10-01 12:45:21 +02:00
|
|
|
const handleFontSizeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
2024-10-11 09:30:37 +02:00
|
|
|
const newSize = `${e.target.value}px`; // Create the new font size string
|
|
|
|
setFontSize(newSize); // Update the font size state
|
|
|
|
document.documentElement.style.setProperty('--font-size', newSize); // Update the CSS variable
|
2024-10-01 12:45:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2024-10-11 09:30:37 +02:00
|
|
|
<div className="settings-option"> {/* Container for the font size setting */}
|
|
|
|
<p>Font Size</p> {/* Label for the setting */}
|
2024-10-01 12:45:21 +02:00
|
|
|
<input
|
2024-10-11 09:30:37 +02:00
|
|
|
type="range" // Range input for selecting font size
|
|
|
|
min="12" // Minimum font size
|
|
|
|
max="30" // Maximum font size
|
|
|
|
value={parseInt(fontSize, 10)} // Ensure value is a number for the slider
|
|
|
|
onChange={handleFontSizeChange} // Update font size on change
|
2024-10-01 12:45:21 +02:00
|
|
|
/>
|
2024-10-11 09:30:37 +02:00
|
|
|
<span>{fontSize}</span> {/* Display the current font size */}
|
2024-10-01 12:45:21 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default FontSizeSetting;
|