From dc4ed59547473449d6d4027092bb10e1dba41fdc Mon Sep 17 00:00:00 2001 From: sageTheDM Date: Fri, 11 Oct 2024 09:28:23 +0200 Subject: [PATCH] ColorSettings comments --- app/components/settings/ColorSettings.tsx | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/components/settings/ColorSettings.tsx b/app/components/settings/ColorSettings.tsx index 4ada123..cc701dc 100644 --- a/app/components/settings/ColorSettings.tsx +++ b/app/components/settings/ColorSettings.tsx @@ -1,29 +1,32 @@ - import React from 'react'; +import React from 'react'; - interface ColorSettingProps { +// Define the props for the ColorSetting component +interface ColorSettingProps { name: string; // The name to display in the

tag value: string; // The current color value setValue: (newColor: string) => void; // The method to update the state cssVariable: string; // The CSS variable name to set - } +} - const ColorSetting: React.FC = ({ name, value, setValue, cssVariable }) => { +// Functional component definition +const ColorSetting: React.FC = ({ name, value, setValue, cssVariable }) => { + // Handler to change the color value const handleColorChange = (e: React.ChangeEvent) => { - const newColor = e.target.value; - setValue(newColor); - document.documentElement.style.setProperty(cssVariable, newColor); + const newColor = e.target.value; // Get the new color from the input + setValue(newColor); // Update the state with the new color + document.documentElement.style.setProperty(cssVariable, newColor); // Set the CSS variable }; return ( -

-

{name}

- +
{/* Container for the color setting */} +

{name}

{/* Display the name */} +
); - }; +}; - export default ColorSetting; +export default ColorSetting;