Skip to content

Commit

Permalink
Integrate ThemeManager component and update settings
Browse files Browse the repository at this point in the history
  • Loading branch information
yashdev16 committed Dec 22, 2024
1 parent b7d568f commit dcd5280
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/app-page-builder/src/admin/components/ColorPicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";

interface ColorPickerProps {
value: { color: string };
onChange: (value: { color: string }) => void;
}

const ColorPicker: React.FC<ColorPickerProps> = ({ value, onChange }) => {
const handleColorChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onChange({ ...value, color: e.target.value });
};

return (
<div className="color-picker">
<label>
Color:
<input type="color" value={value.color || "#000000"} onChange={handleColorChange} />
</label>
</div>
);
};

export default ColorPicker;
51 changes: 51 additions & 0 deletions packages/app-page-builder/src/admin/components/ThemeManager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useState } from "react";
import TypographySelector from "./TypographySelector";
import ColorPicker from "./ColorPicker";

const ThemeManager: React.FC = () => {
const [typography, setTypography] = useState<{ fontFamily: string; fontSize: number }>({
fontFamily: "",
fontSize: 16
});

const [colorScheme, setColorScheme] = useState<{ color: string }>({ color: "#000000" });

const handleSave = () => {
console.log("Typography settings:", typography);
console.log("Color scheme settings:", colorScheme);

localStorage.setItem("typographySettings", JSON.stringify(typography));
localStorage.setItem("colorSchemeSettings", JSON.stringify(colorScheme));

fetch("/api/save-theme-settings", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
typography,
colorScheme
})
})
.then(response => response.json())
.then(data => {
console.log("Success:", data);
})
.catch(error => {
console.error("Error:", error);
});
};

return (
<div className="theme-manager">
<h2>Theme Manager</h2>
{/* Render the TypographySelector and ColorPicker components */}
<TypographySelector value={typography} onChange={setTypography} />
<ColorPicker value={colorScheme} onChange={setColorScheme} />
{/* Button to save the settings */}
<button onClick={handleSave}>Save Theme</button>
</div>
);
};

export default ThemeManager;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";

interface TypographySelectorProps {
value: { fontFamily: string; fontSize: number };
onChange: (value: { fontFamily: string; fontSize: number }) => void;
}

const TypographySelector: React.FC<TypographySelectorProps> = ({ value, onChange }) => {
const handleFontChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onChange({ ...value, fontFamily: e.target.value });
};

const handleSizeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onChange({ ...value, fontSize: parseInt(e.target.value, 10) });
};

return (
<div className="typography-selector">
<label>
Font Family:
<input type="text" value={value.fontFamily || ""} onChange={handleFontChange} />
</label>
<label>
Font Size:
<input type="number" value={value.fontSize || 16} onChange={handleSizeChange} />
</label>
</div>
);
};

export default TypographySelector;

0 comments on commit dcd5280

Please sign in to comment.