mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
apply custom css for dashboard initially load (#4031)
This commit is contained in:
@@ -30,30 +30,10 @@ class CssEditor extends React.PureComponent {
|
||||
cssTemplateOptions: [],
|
||||
};
|
||||
}
|
||||
componentWillMount() {
|
||||
this.updateDom();
|
||||
}
|
||||
changeCss(css) {
|
||||
this.setState({ css }, this.updateDom);
|
||||
this.props.onChange(css);
|
||||
}
|
||||
updateDom() {
|
||||
const css = this.state.css;
|
||||
const className = 'CssEditor-css';
|
||||
const head = document.head || document.getElementsByTagName('head')[0];
|
||||
let style = document.querySelector('.' + className);
|
||||
|
||||
if (!style) {
|
||||
style = document.createElement('style');
|
||||
style.className = className;
|
||||
style.type = 'text/css';
|
||||
head.appendChild(style);
|
||||
}
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = css;
|
||||
} else {
|
||||
style.innerHTML = css;
|
||||
}
|
||||
this.setState({ css }, () => {
|
||||
this.props.onChange(css);
|
||||
});
|
||||
}
|
||||
changeCssTemplate(opt) {
|
||||
this.changeCss(opt.css);
|
||||
|
||||
Reference in New Issue
Block a user