2024-06-24 01:08:40 +01:00
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import "../../../../css/bulma.css";
|
|
|
|
|
import "./App.css";
|
|
|
|
|
import Slider from "./components/Slider";
|
|
|
|
|
|
2024-06-24 03:25:58 +01:00
|
|
|
// const COLORS = ["primary", "link", "info", "success", "warning", "danger"];
|
|
|
|
|
|
|
|
|
|
const KEYS = [
|
|
|
|
|
"scheme-h",
|
|
|
|
|
"primary-h",
|
|
|
|
|
"primary-s",
|
|
|
|
|
"primary-l",
|
|
|
|
|
"skeleton-lines-gap",
|
|
|
|
|
];
|
2024-06-24 01:08:40 +01:00
|
|
|
const UNITS = ["deg", "rem", "em", "%"];
|
2024-06-24 03:25:58 +01:00
|
|
|
const SUFFIX_TO_KIND = {
|
|
|
|
|
"-h": "hue",
|
|
|
|
|
"-s": "saturation",
|
|
|
|
|
"-l": "lightness",
|
|
|
|
|
"-gap": "gap",
|
|
|
|
|
};
|
2024-06-24 01:08:40 +01:00
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
const [vars, setVars] = useState([]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const rootStyle = window.getComputedStyle(document.documentElement);
|
|
|
|
|
|
|
|
|
|
const cssvars = KEYS.map((key) => {
|
|
|
|
|
const original = rootStyle.getPropertyValue(`--bulma-${key}`);
|
2024-06-24 03:25:58 +01:00
|
|
|
const suffix = Object.keys(SUFFIX_TO_KIND).find((kind) =>
|
|
|
|
|
key.endsWith(kind),
|
|
|
|
|
);
|
2024-06-24 01:08:40 +01:00
|
|
|
const unit = UNITS.find((unit) => original.endsWith(unit)) || "";
|
|
|
|
|
const value = unit !== "" ? original.split(unit)[0] : original;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: key,
|
2024-06-24 03:25:58 +01:00
|
|
|
kind: SUFFIX_TO_KIND[suffix] || "any",
|
2024-06-24 01:08:40 +01:00
|
|
|
original,
|
|
|
|
|
unit,
|
|
|
|
|
start: Number(value),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setVars(cssvars);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
console.log("ZLOG vars", vars);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<section className="section">
|
|
|
|
|
<div className="card">
|
|
|
|
|
<div className="card-content">
|
|
|
|
|
{vars.map((v) => {
|
2024-06-24 03:25:58 +01:00
|
|
|
const { id, kind, original, unit, start } = v;
|
2024-06-24 01:08:40 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={id} className="block">
|
2024-06-24 03:25:58 +01:00
|
|
|
<code>{id}</code>
|
|
|
|
|
<Slider
|
|
|
|
|
id={id}
|
|
|
|
|
kind={kind}
|
|
|
|
|
original={original}
|
|
|
|
|
start={start}
|
|
|
|
|
unit={unit}
|
|
|
|
|
/>
|
2024-06-24 01:08:40 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
<div className="buttons">
|
|
|
|
|
<button className="button">Button</button>
|
|
|
|
|
|
|
|
|
|
<button className="button is-primary">Primary</button>
|
|
|
|
|
<button className="button is-link">Link</button>
|
|
|
|
|
|
|
|
|
|
<button className="button is-info">Info</button>
|
|
|
|
|
<button className="button is-success">Success</button>
|
|
|
|
|
<button className="button is-warning">Warning</button>
|
|
|
|
|
<button className="button is-danger">Danger</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|