mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added debugComponents
This commit is contained in:
parent
9d99ad4002
commit
16a7e8454b
1
packages/app/src/debugComponents/index.js
Normal file
1
packages/app/src/debugComponents/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default as ThemeDebug } from "./theme"
|
56
packages/app/src/debugComponents/theme/index.jsx
Normal file
56
packages/app/src/debugComponents/theme/index.jsx
Normal 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>
|
||||||
|
}
|
||||||
|
}
|
8
packages/app/src/debugComponents/theme/index.less
Normal file
8
packages/app/src/debugComponents/theme/index.less
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.themeDebugger {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user