mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-21 21:57:38 +08:00
Refactoring
This commit is contained in:
74
js/template/PinTemplate.js
Normal file → Executable file
74
js/template/PinTemplate.js
Normal file → Executable file
@@ -1,38 +1,38 @@
|
||||
import html from "./html"
|
||||
import sanitizeText from "./sanitizeText"
|
||||
import Template from "./Template"
|
||||
|
||||
/**
|
||||
* @typedef {import("../graph/GraphPin").default} GraphPin
|
||||
*/
|
||||
export default class PinTemplate extends Template {
|
||||
|
||||
/**
|
||||
* Computes the html content of the pin.
|
||||
* @param {GraphPin} pin Pin entity
|
||||
* @returns The result html
|
||||
*/
|
||||
render(pin) {
|
||||
if (pin.isInput()) {
|
||||
return html`
|
||||
<span class="ueb-node-value-icon ${pin.isConnected() ? 'ueb-node-value-fill' : ''}"></span>
|
||||
${sanitizeText(pin.getPinDisplayName())}
|
||||
`
|
||||
} else {
|
||||
return html`
|
||||
${sanitizeText(pin.getPinDisplayName())}
|
||||
<span class="ueb-node-value-icon ${pin.isConnected() ? 'ueb-node-value-fill' : ''}"></span>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the style to the element.
|
||||
* @param {GraphPin} pin Element of the graph
|
||||
*/
|
||||
apply(pin) {
|
||||
super.apply(pin)
|
||||
pin.classList.add("ueb-node-" + pin.isInput() ? "input" : "output", "ueb-node-value-" + sanitizeText(pin.getType()))
|
||||
pin.clickableElement = pin.querySelector(".ueb-node-value-icon")
|
||||
}
|
||||
import html from "./html"
|
||||
import sanitizeText from "./sanitizeText"
|
||||
import Template from "./Template"
|
||||
|
||||
/**
|
||||
* @typedef {import("../graph/GraphPin").default} GraphPin
|
||||
*/
|
||||
export default class PinTemplate extends Template {
|
||||
|
||||
/**
|
||||
* Computes the html content of the pin.
|
||||
* @param {GraphPin} pin Pin entity
|
||||
* @returns The result html
|
||||
*/
|
||||
render(pin) {
|
||||
if (pin.isInput()) {
|
||||
return html`
|
||||
<span class="ueb-node-value-icon ${pin.isConnected() ? 'ueb-node-value-fill' : ''}"></span>
|
||||
${sanitizeText(pin.getPinDisplayName())}
|
||||
`
|
||||
} else {
|
||||
return html`
|
||||
${sanitizeText(pin.getPinDisplayName())}
|
||||
<span class="ueb-node-value-icon ${pin.isConnected() ? 'ueb-node-value-fill' : ''}"></span>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the style to the element.
|
||||
* @param {GraphPin} pin Element of the graph
|
||||
*/
|
||||
apply(pin) {
|
||||
super.apply(pin)
|
||||
pin.classList.add("ueb-node-" + pin.isInput() ? "input" : "output", "ueb-node-value-" + sanitizeText(pin.getType()))
|
||||
pin.clickableElement = pin.querySelector(".ueb-node-value-icon")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user