Add Reset button

This commit is contained in:
Jeremy Thomas
2024-06-25 13:48:53 +01:00
parent 0c9ae61698
commit 2cc6593269
3 changed files with 42 additions and 22 deletions

View File

@@ -49,7 +49,14 @@ function App() {
getVar: (id) => {
return context.cssvars[id];
},
updateVar: (id, newValue) => {
updateVar: (id, newValue, unit) => {
const computedValue = `${newValue}${unit}`;
document.documentElement.style.setProperty(
`--bulma-${id}`,
computedValue,
);
setContext((context) => {
return {
...context,
@@ -57,7 +64,7 @@ function App() {
...context.cssvars,
[id]: {
...context.cssvars[id],
value: newValue,
current: newValue,
},
},
};
@@ -66,8 +73,6 @@ function App() {
};
const [context, setContext] = useState(initialContext);
console.log("ZLOG context", context);
useEffect(() => {
const rootStyle = window.getComputedStyle(document.documentElement);