2024-09-22 22:24:35 +05:30
|
|
|
import Widget from "../../../canvas/widgets/base"
|
|
|
|
|
import Tools from "../../../canvas/constants/tools"
|
2024-09-23 12:31:01 +05:30
|
|
|
import { removeKeyFromObject } from "../../../utils/common"
|
2024-09-25 17:27:12 +05:30
|
|
|
import TkinterBase from "./base"
|
2024-09-22 22:24:35 +05:30
|
|
|
|
|
|
|
|
|
2024-09-25 17:27:12 +05:30
|
|
|
class Label extends TkinterBase{
|
2024-09-22 22:24:35 +05:30
|
|
|
|
|
|
|
|
static widgetType = "label"
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
|
2024-09-25 17:27:12 +05:30
|
|
|
this.droppableTags = null
|
2024-09-22 22:24:35 +05:30
|
|
|
|
2024-09-23 12:31:01 +05:30
|
|
|
const newAttrs = removeKeyFromObject("layout", this.state.attrs)
|
|
|
|
|
|
|
|
|
|
|
2024-09-22 22:24:35 +05:30
|
|
|
this.state = {
|
|
|
|
|
...this.state,
|
|
|
|
|
size: { width: 80, height: 40 },
|
|
|
|
|
attrs: {
|
2024-09-23 12:31:01 +05:30
|
|
|
...newAttrs,
|
2024-09-22 22:24:35 +05:30
|
|
|
styling: {
|
2024-09-23 12:31:01 +05:30
|
|
|
...newAttrs.styling,
|
2024-09-22 22:24:35 +05:30
|
|
|
foregroundColor: {
|
|
|
|
|
label: "Foreground Color",
|
|
|
|
|
tool: Tools.COLOR_PICKER, // the tool to display, can be either HTML ELement or a constant string
|
|
|
|
|
value: "#000",
|
|
|
|
|
onChange: (value) => {
|
2024-09-25 17:27:12 +05:30
|
|
|
this.setWidgetInnerStyle("color", value)
|
2024-09-22 22:24:35 +05:30
|
|
|
this.setAttrValue("styling.foregroundColor", value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
labelWidget: {
|
|
|
|
|
label: "Text",
|
|
|
|
|
tool: Tools.INPUT, // the tool to display, can be either HTML ELement or a constant string
|
|
|
|
|
toolProps: {placeholder: "text", maxLength: 100},
|
|
|
|
|
value: "Label",
|
|
|
|
|
onChange: (value) => this.setAttrValue("labelWidget", value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
super.componentDidMount()
|
2024-09-23 12:31:01 +05:30
|
|
|
this.setAttrValue("styling.backgroundColor", "#fff")
|
2024-09-25 17:27:12 +05:30
|
|
|
this.setWidgetInnerStyle("backgroundColor", "#fff0")
|
2024-09-22 22:24:35 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getToolbarAttrs(){
|
2024-09-23 12:31:01 +05:30
|
|
|
const toolBarAttrs = super.getToolbarAttrs()
|
|
|
|
|
|
2024-09-22 22:24:35 +05:30
|
|
|
return ({
|
|
|
|
|
id: this.__id,
|
2024-09-23 12:31:01 +05:30
|
|
|
widgetName: toolBarAttrs.widgetName,
|
2024-09-22 22:24:35 +05:30
|
|
|
labelWidget: this.state.attrs.labelWidget,
|
2024-09-23 12:31:01 +05:30
|
|
|
size: toolBarAttrs.size,
|
2024-09-22 22:24:35 +05:30
|
|
|
|
|
|
|
|
...this.state.attrs,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderContent(){
|
|
|
|
|
return (
|
|
|
|
|
<div className="tw-w-flex tw-flex-col tw-w-full tw-h-full tw-rounded-md tw-overflow-hidden">
|
2024-09-25 17:27:12 +05:30
|
|
|
<div className="tw-p-2 tw-w-full tw-h-full tw-content-start " style={this.state.widgetInnerStyling}>
|
2024-09-22 22:24:35 +05:30
|
|
|
{/* {this.props.children} */}
|
|
|
|
|
<div className="tw-text-sm" style={{color: this.getAttrValue("styling.foregroundColor")}}>
|
|
|
|
|
{this.getAttrValue("labelWidget")}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default Label
|