import {Config} from "data"; import {React, ReactDOM, Utilities} from "modules"; import SideBar from "./sidebarmenu"; export default class V2_SettingsPanel_Sidebar { constructor(onClick) { this.onClick = onClick; } get items() { return [{text: "Settings", id: "core"}, {text: "Emotes", id: "emotes"}, {text: "Plugins", id: "plugins"}, {text: "Themes", id: "themes"}, {text: "Custom CSS", id: "customcss"}]; } get component() { return React.createElement( "span", null, React.createElement(SideBar, {onClick: this.onClick, headerText: "Bandaged BD", items: this.items}), React.createElement( "div", {style: {fontSize: "12px", fontWeight: "600", color: "#72767d", padding: "2px 10px"}}, `BD v${Config.version} by `, React.createElement( "a", {href: "https://github.com/Jiiks/", target: "_blank"}, "Jiiks" ) ), React.createElement( "div", {style: {fontSize: "12px", fontWeight: "600", color: "#72767d", padding: "2px 10px"}}, `BBD v${Config.bbdVersion} by `, React.createElement( "a", {href: "https://github.com/rauenzi/", target: "_blank"}, "Zerebos" ) ) ); } get root() { const _root = $("#bd-settings-sidebar"); if (!_root.length) { if (!this.injectRoot()) return null; return this.root; } return _root[0]; } injectRoot() { const changeLog = $("[class*='side-'] > [class*='item-']:not([class*=Danger])").last(); if (!changeLog.length) return false; $("", {id: "bd-settings-sidebar"}).insertBefore(changeLog.prev()); return true; } render() { const root = this.root; if (!root) { console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])"); return; } ReactDOM.render(this.component, root); Utilities.onRemoved(root, () => { ReactDOM.unmountComponentAtNode(root); }); } }