The default styles can be loaded by simply importing them (when using webpack or a similar bundler):
import "@baklavajs/plugin-renderer-vue/dist/styles.css";
Most colors can be customized by changing variables. The default values can be found at variables.scss. To override values, create a scss file with the following contents:
@import "@baklavajs/plugin-renderer-vue/dist/styles/variables.scss";
// change variables here
@import "@baklavajs/plugin-renderer-vue/dist/styles/styles.scss";
Now you can import the scss file in your main.js/index.js file.
The grid background can be configured using the [backgroundGrid
](!!API%{ "module": "@baklavajs/plugin-renderer-vue", "type": "class", "name": "ViewPlugin", "field": "backgroundGrid"}%) property of the ViewPlugin
. You can configure these variables:
gridSize
: The size of the main grid cells in pixels (default:100
)gridDivision
: How many sub-cells the main grid should be divided into when zoomed above thesubGridVisibleThreshold
(default:5
)subGridVisibleThreshold
: When the zoom factor is larger than this threshold, the sub grid appears (default0.6
)
To do more customization, like basic layout changes or conditional colors, you can use CSS and the following classes:
.node
: Base class for nodes.--type-{NodeType}
: Every node has this modifier withNodeType
being the type specified in the class of the node (or in the parameter of the constructor of theNodeBuilder
).--selected
: Applied whenever a node is selected- You can provide a
customClasses
property in the node to add additional classes:
// NodeBuilder
new NodeBuilder("MyNode", { customClasses: "class-one class-two" }).build();
// Node Class
class MyNode extends Node {
constructor() {
super();
this.customClasses = "class-one class-two";
}
}
.node-interface
: Base class for node interfaces.--input
or.--output
: These classes are also assigned to every node interface, depending on whether an interface is an input interface or an output interface.__port
: Assigned to the "dot" of a node interface.__port-{PortType}
: When the node interface has a type (through theinterface-types
plugin), this class is assigned. Note, however, that the color is set using thestyle
property and can therefore not be changed through CSS but instead only through theinterface-types
plugin.
.node-option
: Base class for node options.connection
: Base class for connections
The ViewPlugin
class provides hooks for rendering. The hooks provide the rendered Vue component as an argument, which you can use to make changes:
this.viewPlugin.hooks.renderNode.tap(this, (node) => {
if (node.data.type === "TestNode") {
node.$el.style.backgroundColor = "red";
}
return node;
});
If these options don't fulfill your needs for customization, you can provide custom components to the renderer-vue
plugin. This can be done for the following components:
- Node (default component)
- Node Option (default component)
- Node Interface (default component)
- Connection (default component)
- Temporary Connection (default component)
- Context Menu (default component)
- Sidebar (default component)
To override the default components, change the respective property of the ViewPlugin
s components
property:
import MyNodeComponent from "MyNodeComponent.vue";
viewPlugin.components.node = MyNodeComponent;
To see, what props the individual components receive, have a look at the default implementations of the components.