Skip to content

Commit bebecb4

Browse files
authored
UI: Detail how implicit prop are named for action groups (openhab#1514)
* UI: Detail how implicit prop are named for action groups Add CSS-Tricks almanac link, a good CSS reference. Signed-off-by: Yannick Schaus <[email protected]> * Remove duplicated paragraph Signed-off-by: Yannick Schaus <[email protected]> * Fix errors, non-existent NUMBER prop type Signed-off-by: Yannick Schaus <[email protected]>
1 parent 36cb424 commit bebecb4

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

ui/building-pages.md

+57-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ props:
7474
context: item
7575
description: Choose an item for this prop
7676
- name: prop3
77-
type: NUMBER
77+
type: INTEGER
7878
advanced: true
7979
...
8080
tags: ["tag1", "tag2"]
@@ -236,6 +236,60 @@ props:
236236
actionPropsParameterGroup: myaction
237237
```
238238

239+
<details class="custom-block details">
240+
<summary>How the implicit props are named</summary>
241+
242+
The property names will be in the following format: `{groupName}_{actionPropName}`
243+
244+
The list of `actionPropNames` can be found in the Component Reference (they’re always the same), for instance in the [oh-button](./components/oh-button.html#action) reference.
245+
246+
:warning: The `groupName` prefix is the name of the parameter group, but occurrences of the word "action" will be removed from it.
247+
If you name the parameter group `action` there won't be a prefix anymore so the underscore will be removed too.
248+
249+
Examples:
250+
251+
| Group Name | Prop Name Examples |
252+
|------------|--------------------|
253+
| action | `action, actionItem, actionCommand, actionCommandAlt` |
254+
| tapAction | `tap_action, tap_actionItem, tap_actionCommand, tap_actionCommandAlt` |
255+
| sceneOne | `sceneOne_action, sceneOne_actionItem, sceneOne_actionCommand, sceneOne_actionCommandAlt` |
256+
257+
You can dump the `props` objects in JSON to verify the names like in the following example (or just use `=JSON.stringify(props)` wherever you can display text in your widget):
258+
259+
```yaml
260+
uid: dump_props_as_json
261+
props:
262+
parameterGroups:
263+
- name: sceneOne
264+
context: action
265+
label: Scene One
266+
- name: sceneTwo
267+
context: action
268+
label: Scene Two
269+
- name: tapAction
270+
context: action
271+
label: Tap Action
272+
- name: action
273+
context: action
274+
label: Tap Action
275+
parameters:
276+
- name: prop1
277+
label: Prop 1
278+
type: TEXT
279+
description: A text prop
280+
tags: []
281+
component: f7-row
282+
config:
283+
tag: pre
284+
slots:
285+
default:
286+
- component: Label
287+
config:
288+
text: =JSON.stringify(props, null, 4)
289+
```
290+
291+
</details>
292+
239293
:::
240294

241295
## Variables
@@ -313,7 +367,8 @@ slots:
313367

314368
Applying CSS properties like `border-color` directly on components is sometimes enough; but contrary to CSS variables like `--f7-button-border-color` which will be inherited to descendants in the tree, either by your own components or by f7 components (or their OH derivatives) that make use of these variables, they will only work on the element where you put the style configuration.
315369

316-
There are hundreds of [CSS properties](https://www.w3schools.com/cssref/) you can use to design your widgets. Use the resources at [W3Schools](https://www.w3schools.com/css/default.asp) to learn more about CSS techniques - these examples will provide code in HTML and classes definitions but you can most of the time adapt them for usage in components' YAML definitions.
370+
There are hundreds of [CSS properties](https://www.w3schools.com/cssref/) you can use to design your widgets.
371+
Use the resources at [W3Schools](https://www.w3schools.com/css/default.asp) or the [CSS-Tricks Properties Almanac](https://css-tricks.com/almanac/properties/) to learn more about CSS properties and techniques - these resources will provide code in HTML and classes definitions but you can most of the time adapt them for usage in components' YAML definitions.
317372

318373
While the Layout components (`oh-block`, `oh-grid-row`, `oh-grid-col`) can help you with the placement of your widgets, to lay out sub-components _within_ a widget, you shouldn't use them because they include design mode controls that you don't need.
319374
While can use their `f7-block`, `f7-row` and `f7-col` equivalents instead, in many cases this is still "overkill": consider applying directly the Flexbox or Grid properties to the components.

0 commit comments

Comments
 (0)