};
export const CustomizerContext = createContext({
+ isOpen: false,
cssvars: {},
currentTab: "",
currentPage: "",
function App() {
const styleRef = useRef();
const initialContext = {
+ isOpen: true,
cssvars: {},
currentTab: "Global Variables",
currentPage: "delete",
context.changePage(pageId);
};
+ const handleOpening = (event) => {
+ event.preventDefault();
+
+ setContext((context) => {
+ return {
+ ...context,
+ isOpen: !context.isOpen,
+ };
+ });
+ };
+
useEffect(() => {
const styles = {
root: window.getComputedStyle(document.documentElement),
"--bulma-tabs-link-active-color": "var(--bulma-primary)",
};
+ const appClass = classNames({
+ [cn.app]: true,
+ [cn.open]: context.isOpen,
+ });
+
+ const buttonClass = classNames({
+ [cn.button]: true,
+ "button is-primary": true,
+ });
+
return (
<CustomizerContext.Provider value={context}>
<style ref={styleRef} />
- <div className={cn.app}>
+
+ <div className={appClass}>
<div className={cn.controls}>
<div className="select" style={tabsStyle}>
<select onChange={handleTabChange} value={context.currentTab}>
{PAGE_TO_COMPONENT[context.currentPage]}
</div>
+
+ <button className={buttonClass} onClick={handleOpening}>
+ {context.isOpen ? "Close Customizer" : "Open Customizer"}
+ </button>
</CustomizerContext.Provider>
);
}
--var-item-slider-width: 30rem;
--var-item-padding: 1rem;
--var-item-gap: 1rem;
+ transform-origin: bottom right;
+ transition-duration: 300ms;
+ transition-property: opacity, transform;
+ transform: scale(0.9);
+ opacity: 0;
+}
+
+.open {
+ opacity: 1;
+ transform: none;
}
.controls {
gap: 0.5rem;
padding: 1.5rem;
}
+
+.button {
+ bottom: 1rem;
+ right: 1rem;
+ position: fixed;
+}