1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-13 05:06:30 +04:00

JS: Update and fix docs, fix Number.toString() with decimals (#4168)

* Update and fix JS docs

This could really use some automation, atleast for API reference
There are TypeScript definitions and typedocs, we don't need to be monkeys copying and reformatting this to API reference by hand

* Fix bugged character

* JS: Fix Number.toString() with decimals

* Fix

* Forgot this one

* docs: mention per-view child format

* Added @portasynthinca3 to docs' codeowners

* Updated CODEOWNERS

---------

Co-authored-by: Anna Antonenko <portasynthinca3@gmail.com>
Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
WillyJL
2025-04-01 11:02:12 +00:00
committed by GitHub
parent 933134ed94
commit d34ff3310d
19 changed files with 675 additions and 45 deletions

View File

@@ -173,6 +173,11 @@ triggered when the back key is pressed.
<br>
### viewDispatcher.currentView
The `View` object currently being shown.
<br>
## ViewFactory
When you import a module implementing a view, a `ViewFactory` is instantiated. For example, in the example above, `loadingView`, `submenuView` and `emptyView` are view factories.
@@ -183,8 +188,40 @@ Creates an instance of a `View`.
<br>
### ViewFactory.make(props)
Creates an instance of a `View` and assigns initial properties from `props`.
### ViewFactory.makeWith(props, children)
Creates an instance of a `View` and assigns initial properties from `props` and optionally a list of children.
**Parameters**
- `props`: simple key-value object, e.g. `{ header: "Header" }`
- `children`: optional array of children, e.g. `[ { element: "button", button: "right", text: "Back" } ]`
## View
When you call `ViewFactory.make()` or `ViewFactory.makeWith()`, a `View` is instantiated. For example, in the example above, `views.loading`, `views.demos` and `views.empty` are views.
<br>
### View.set(property, value)
Assign value to property by name.
**Parameters**
- `property`: name of the property to change
- `value`: value to assign to the property
<br>
### View.addChild(child)
Adds a child to the `View`.
**Parameters**
- `child`: the child to add, e.g. `{ element: "button", button: "right", text: "Back" }`
The format of the `child` parameter depends on the type of View that you're working with. Look in the View documentation.
### View.resetChildren()
Removes all children from the `View`.
### View.setChildren(children)
Removes all previous children from the `View` and assigns new children.
**Parameters**
- `children`: the array of new children, e.g. `[ { element: "button", button: "right", text: "Back" } ]`