0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-27 22:33:07 +00:00

add color-selector component and colorings

This commit is contained in:
Charlie Humphreys
2023-07-17 00:46:55 -05:00
parent 46f413c656
commit 379f260de5
11 changed files with 236 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
require('./modal.less');
const React = require('react');
const ReactDOMClient = require('react-dom/client');
const createClass = require('create-react-class');
const Modal = createClass({
@@ -46,4 +47,29 @@ const Modal = createClass({
}
});
module.exports = Modal;
module.exports = {
/*
* Requirements:
* - modalRef member variable
* - should be re-rendered via `this.state.modalRoot?.render` in `componentDidUpdate`
*/
Modal,
modalHelpers : {
// should be called in `componentDidMount`
// `self` should be passed as the component instance (`this`)
mount : (self)=>{
const el = document.createElement('div');
const root = ReactDOMClient.createRoot(el);
document.querySelector('body').append(el);
self.setState({
el,
modalRoot : root
});
},
// should be called in `componentWillUnmount`
// `self` should be passed as the component instance (`this`)
unmount : (self)=>{
self.state.el.remove();
}
}
};