added debugComponents

This commit is contained in:
srgooglo 2022-03-11 01:05:40 +01:00
parent 9d99ad4002
commit 16a7e8454b
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1 @@
export { default as ThemeDebug } from "./theme"

View File

@ -0,0 +1,56 @@
import React from "react"
import * as antd from "antd"
import ReactJSON from "react-json-view"
import { Theme } from "extensions"
import "./index.less"
export default class ThemeDebug extends React.Component {
state = {
currentVariant: null,
rootVariables: null,
}
componentDidMount = async () => {
await this.setValues()
}
setValues = async () => {
const currentVariant = document.documentElement.style.getPropertyValue("--themeVariant")
const rootVariables = window.app.ThemeController.getRootVariables()
this.setState({ currentVariant, rootVariables })
}
editValues = async (values) => {
console.log(values)
await window.app.ThemeController.update({ [values.name]: values.new_value })
await this.setState({ rootVariables: values.updated_src })
}
setDefaults = async () => {
await window.app.ThemeController.resetDefault()
await this.setValues()
}
render() {
return <div className="themeDebugger">
<div>
<antd.Button onClick={this.setDefaults}>
default
</antd.Button>
</div>
<div>
Current variant: <antd.Tag>{this.state.currentVariant}</antd.Tag>
</div>
<div>
<ReactJSON
src={this.state.rootVariables}
onEdit={this.editValues}
/>
</div>
</div>
}
}

View File

@ -0,0 +1,8 @@
.themeDebugger {
display: flex;
flex-direction: column;
> div {
margin-bottom: 20px;
}
}