The component file
The parts of a component file: server code, readme, settings form, styles, the look of the node and the browser script.
A component is one HTML file. Flow reads the parts of the file by their tags. Only <script total> is required; the other parts are optional.
<script total>
// Code that runs on the server
</script>
<readme>
Markdown that describes the component.
</readme>
<settings>
<!-- The settings form of a node -->
</settings>
<style>
/* Styles for the node and the settings form */
</style>
<body>
<!-- The look of the node on the canvas -->
</body>
<script>
// Code that runs in the designer, in the browser
</script>The parts
| Tag | What it holds |
|---|---|
<script total> | The server code. It sets the exports properties, such as the name and the inputs, and exports.make, which Flow runs for each node. See Component file reference. |
<readme> | The description in Markdown. The designer shows it under Read me, and the catalogue copies it. |
<settings> | The HTML of the settings form. A field with path="?.key" edits config.key of the node. See Configuration and the settings form. |
<style> | CSS for the node and the settings form. |
<body> | The HTML of the node on the canvas. Without it, the node shows its icon and name. |
<script> | JavaScript that runs in the designer for each node. See Status and the look of the node. |
A file without <script total> is not a component: Flow refuses it with the error Invalid component content.
Keywords
Flow replaces these keywords in <body> before it shows the node. CLASS is also replaced in <style> and in the browser script.
| Keyword | Replaced with |
|---|---|
$NAME | The name of the component. |
$ICON | The icon of the component, for example ti ti-print. |
$ID | The id of the component. |
$CONFIG | The path to the configuration of the node, to bind it in <body>. |
$STATUS | The path to the last status of the node, to bind it in <body>. |
CLASS | A class name that belongs to this component. Write .CLASS in your styles so they apply only to its nodes. |
The required properties
To install a component from a URL address or from a catalogue, Flow reads exports.name, exports.version and exports.icon from the file, and it refuses the file without them. Write each of these on one line that ends with a semicolon:
exports.id = 'uppercase';
exports.name = 'Uppercase';
exports.icon = 'ti ti-font';
exports.version = '1';The id identifies the component inside a FlowStream. When you install a file whose id is already installed, the new file replaces the old one.
Where Flow keeps the file
Flow stores the whole file inside the FlowStream that uses it. A component that you install in one FlowStream is not available in another one until you install it there too. When you export a FlowStream, its components go with it.