### Initialize Noodl Platform for Node.js
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-platform/README.md
Similar to Electron, this TypeScript snippet illustrates the initial setup for the Noodl platform in a Node.js application. It requires importing `@noodl/platform-node` at the start to enable Node-specific functionalities. After this, common modules like `filesystem` and `platform` can be imported from the main `@noodl/platform` package.
```ts
// Setup the platform before anything else is loading
// This is a problem since we are calling the platform when importing
import "@noodl/platform-node";
// Then import the platform etc via:
import { filesystem, platform } from "@noodl/platform";
```
--------------------------------
### Build and Run Noodl Editor from Source
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/README.md
These npm commands are used for managing the Noodl Editor when building from source. `npm install` sets up all necessary project dependencies. `npm start` builds production versions of the cloud and React runtimes and then starts the Noodl Editor. `npm run dev` starts the editor with development versions of the runtimes, watching for file changes for a quicker development workflow. `npm run test:editor` executes the test suite specifically for the Noodl Editor.
```bash
# Install all dependencies
npm install
# Start the Noodl Editor and build a production version of the cloud and react runtime (useful when running Noodl from source but want to deploy to production)
npm start
# Start the Noodl Editor and watch the filesystem for changes to the runtimes. Development versions of the runtimes, not meant for production (mostly due to source maps and file size)
# This is ideal for a quick workflow when doing changes on the runtimes.
npm run dev
# Start Noodl Editor test runner
npm run test:editor
```
--------------------------------
### Check Page Router start page in OpenNoodl (JSON)
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Illustrates how to verify the designated start page for a Page Router node. This ensures the correct initial navigation path.
```JSON
{
"path": "/App:%Group:%Router",
"paramseq": {
"pages": {
"startPage": "/Page 2"
}
}
}
```
--------------------------------
### Install OpenNoodl on Arch Linux
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/README.md
This command demonstrates how to install OpenNoodl on Arch Linux using the `yay` AUR helper. It fetches and installs the `opennoodl` package from the Arch User Repository, making the application available on your system.
```bash
yay -S opennoodl
```
--------------------------------
### Install Noodl Platform for Node.js
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-platform/README.md
This command shows how to install the necessary Noodl platform packages for a Node.js environment. It uses `npm` to install both the core `@noodl/platform` package and the Node-specific `@noodl/platform-node` package, making them available for use in your project.
```shell
$ npm install @noodl/platform @noodl/platform-node
```
--------------------------------
### APIDOC: Tutorial Condition Path Syntax
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Defines the syntax for specifying paths to nodes within the tutorial condition system. Paths start with the component name and can include tokens for labels (`#label`), types (`%type`), or child indices (`index`). The first part is always a component, followed by root node matching, and then child node matching.
```APIDOC
Path Syntax:
- `/Main:%Group`: "/Main" component -> Any root node with the type "Group". Picks the first if multiple.
- `/Main:%Group:%Button`: "/Main" component -> Any root node with the type "Group" -> First child with the type "Button".
- `/Main:#Some Label`: "/Main" component -> A root node with the label "Some Label".
- `/Main:#Some Label:0`: "/Main" component -> A root node with the label "Some Label" -> First child.
- `/Main:#Some Label:%Button`: "/Main" component -> A root node with the label "Some Label" -> First child with the type "Button".
- `/#Sheet A/Comp A:JavaScriptFunction`: Sheet "Sheet A" component "Comp A" -> A root node with the type "Function" (refer to project.json for node types).
```
--------------------------------
### Apache License 2.0 Boilerplate Notice
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/src/assets/OpenSans/LICENSE.txt
This snippet provides the standard boilerplate notice for applying the Apache License, Version 2.0 to a work. It includes placeholders for the copyright year and owner, and outlines the terms under which the work is licensed. This text should be enclosed in the appropriate comment syntax for the file format where it is applied.
```Text
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
--------------------------------
### Perform Noodl JSON Storage Operations
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-platform/README.md
This TypeScript example demonstrates common operations with Noodl's `JSONStorage` for persistent configuration. It shows how to retrieve data using `get()`, store data using `set()`, and remove data using `remove()`, all of which return Promises indicating completion or providing the retrieved content.
```ts
import { JSONStorage } from "@noodl/platform";
JSONStorage.get("my-key").then((content) => {
// content = json file
});
JSONStorage.set("my-key", { key: "value" }).then(() => {
// done
});
JSONStorage.remove("my-key").then(() => {
// done
});
```
--------------------------------
### JavaScript Initialization for OpenNoodl Runtime
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-viewer-react/static/viewer/index.html
This JavaScript code initializes the Noodl runtime environment. It sets up a global `Noodl` object to define modules and renders the Noodl React application into the 'root' DOM element once the document is fully loaded. It includes placeholders for module dependencies and main module code.
```JavaScript
window.__noodl_modules = [];
window.Noodl = {
defineModule: function (m) {
window.__noodl_modules.push(m);
},
deployed: false,
Env: {}
};
document.addEventListener("DOMContentLoaded", function () {
const root = document.getElementById('root');
window.Noodl._viewerReact.render(root, __noodl_modules, { isLocal: true });
});
```
--------------------------------
### Storybook MDX Documentation Setup for Color Palettes
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-core-ui/src/stories/design-tokens/_01_colors.stories.mdx
This snippet demonstrates the setup of a Storybook MDX page for documenting design tokens, specifically color palettes. It includes importing necessary Storybook components and custom React components to render theme and base color sheets, along with setting page metadata.
```JavaScript
import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs/blocks';
import { ThemeColorPaletteSheet, BaseColorPaletteSheet } from './_01_colors_palettes';
```
--------------------------------
### Check connection between OpenNoodl nodes (JSON)
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Provides an example of verifying a connection between two specific nodes, identifying the source and target ports involved in the connection.
```JSON
{
"from": "/My component:%Model2",
"to": "/My component::%Image",
"hasconnection": "prop-url,src"
}
```
--------------------------------
### Check state node parameters in OpenNoodl (JSON)
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
An example of checking specific state parameters within a state node. This snippet shows how to verify the presence of certain states and their associated values.
```JSON
{
"path": "/App:#root:1",
"paramseq": {
"paramseq": {
"states": "Visible,Hidden",
"values": "Opacity"
}
}
}
```
--------------------------------
### Basic CSS Styling for OpenNoodl Application
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-viewer-react/static/viewer/index.html
This CSS defines the fundamental layout and appearance for an OpenNoodl web application. It includes reset styles, body and root container properties, image drag prevention, box-sizing, tap highlight prevention, and custom font definitions for 'Open Sans' from local assets.
```CSS
body { margin: 0; padding: 0; background-color: white; }
.body-scroll { overflow: hidden auto; }
img { -webkit-user-drag: none; }
* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
#root { display: flex; width: 100%; height: 100%; overflow: hidden; position: fixed; }
.body-scroll > #root { width: 100%; height: auto; min-height: 100vh; flex-direction: column; overflow: initial; position: initial; }
@font-face { font-family: "Open Sans"; src: url(ndl_assets/OpenSans-Regular.ttf); }
@font-face { font-family: "Open Sans"; src: url(ndl_assets/OpenSans-Bold.ttf); font-weight: bold; }
```
--------------------------------
### Retrieve Noodl Platform Build Number
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-platform/README.md
This TypeScript example demonstrates how to access platform-specific information, specifically retrieving the application's build number. It imports the `platform` module from `@noodl/platform` and uses its `getBuildNumber()` method, which returns a Promise that resolves with the version string.
```ts
import { platform } from "@noodl/platform";
platform.getBuildNumber().then((version) => {});
```
--------------------------------
### Display Poppins Font Typography Example in Storybook
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-core-ui/src/stories/design-tokens/_02_typography.stories.mdx
This snippet uses Storybook's `Typeset` component to visually demonstrate the 'Poppins' font family. Similar to the Inter font example, it displays a range of font sizes from 12 to 48 pixels with a font weight of 500 and the same sample text.
```JSX
```
--------------------------------
### Display Inter Font Typography Example in Storybook
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-core-ui/src/stories/design-tokens/_02_typography.stories.mdx
This snippet uses Storybook's `Typeset` component to visually demonstrate the 'Inter' font family. It showcases a range of font sizes from 12 to 48 pixels with a fixed font weight of 500 and a sample text.
```JSX
```
--------------------------------
### HTML Template for a Tutorial Step Without Conditions
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Outlines the HTML structure for a tutorial step that automatically displays its popup content without requiring specific user actions. It includes a `data-template="item"` for the tutorial bar entry and a `data-template="popup"` for the associated content.
```HTML
...header text and stuff ...
Some text
... popup content ...
```
```HTML
The node graph
The node graph
Some text
```
--------------------------------
### HTML Template for a Tutorial Step with Conditions
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Describes the HTML structure for a tutorial step that only activates its popup when specified conditions are met. The `data-conditions` attribute holds a JSON array of conditions, and a `lesson-checkmark` span can be used for visual feedback.
```HTML
...header text and stuff ...
Some text
... popup content ...
```
```HTML
Drag the text node back to make it visible again
```
--------------------------------
### JavaScript Entry Point for Noodl Application Rendering
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-viewer-react/static/deploy/index.html
This JavaScript code snippet serves as the main entry point for a Noodl application. It waits for the DOM to be fully loaded, then retrieves the 'root' element and uses the Noodl viewer's React renderer to deploy the application with provided modules and project data.
```JavaScript
<%modules_dependencies%> <%index_js%> <%modules_main%> document.addEventListener("DOMContentLoaded", function () { const root = document.getElementById("root"); window.Noodl._viewerReact.renderDeployed(root, __noodl_modules, window.projectData); });
```
--------------------------------
### Initialize Noodl Platform for Electron
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-platform/README.md
This snippet demonstrates how to set up the Noodl platform for Electron applications. It involves importing the `@noodl/platform-electron` package early in the application's lifecycle to ensure platform-specific features are available. Subsequently, core modules like `filesystem` and `platform` can be imported from `@noodl/platform`.
```ts
// Setup the platform before anything else is loading
// This is a problem since we are calling the platform when importing
import "@noodl/platform-electron";
// Then import the platform etc via:
import { filesystem, platform } from "@noodl/platform";
```
--------------------------------
### HTML Template for a Modal Popup Tutorial Step
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Defines the HTML structure for a tutorial step that appears as a full-screen modal popup. This type of step requires user dismissal to proceed and is often used for initial explanations or important announcements. The `data-template="popup"` attribute identifies the content as a modal.
```HTML
... any html ...
```
```HTML
Welcome to this tutorial
You're going to learn some awesome stuff
```
--------------------------------
### HTML Template for Custom Width Tutorial Step
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Illustrates how to set a custom width for a tutorial item using an inline `style` attribute. This is useful for accommodating longer text or specific layout requirements within the tutorial bar, overriding the standard size.
```HTML
```
--------------------------------
### Check Page Input parameters and connections in OpenNoodl (JSON)
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Shows how to verify the existence of specific page input parameters and their connections to other nodes. For multiple parameters, the order in the comma-separated list is important.
```JSON
[
{
"path": "/Page 1:%PageInputs",
"paramseq": {
"pathParams": "myPageInput"
}
},
{
"from": "/Page 1:%PageInputs",
"to": "/Page 1:%Page:%Text",
"hasconnection": "pm-myPageInput,text"
}
]
```
--------------------------------
### Check node parameters in OpenNoodl (JSON)
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/docs/interactive-lessons.md
Demonstrates how to verify the values of one or more parameters on a specific node, as defined in the `project.json` file. This is useful for ensuring node configuration.
```JSON
{
"path": "/App:#root:1",
"paramseq": {
"color": "#000000",
"width": { "value": 300, "unit": "px" },
"alignX": "center",
"alignY": "center",
"sizeMode": "contentSize"
}
}
```
--------------------------------
### Initialize Noodl Editor Bundle
Source: https://github.com/the-low-code-foundation/opennoodl/blob/main/packages/noodl-editor/src/editor/index.html
This JavaScript snippet determines the base path for the Noodl editor bundle. In development mode (when `process.env.devMode` is 'yes'), it points to a local server; otherwise, it uses a relative path. It then dynamically injects a script tag into the document to load the `index.bundle.js` file, ensuring the Noodl editor is loaded correctly.
```JavaScript
const path = process.env.devMode !== 'yes' ? '.' : 'http://localhost:8080/src/editor'; document.write("