Skip to content

Commit

Permalink
Added attribute binding
Browse files Browse the repository at this point in the history
  • Loading branch information
knowthelist committed Jan 16, 2024
1 parent 13db8da commit 705cff6
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 53 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ Just add some of the FTUI web components to your HTML code
Binding
------
no binding - fix value
- no binding - fix value
```html
<ftui-label color="danger">demo</ftui-label>
```
Input binding
--------
- Property binding:
bind a FHEM reading to a attribute. Changes of the reading changes the attribute
bind a FHEM reading to a property of an element. Changes of the reading changes the property
```html
<ftui-label get-color="dummy1:color">demo</ftui-label>
Expand All @@ -111,6 +112,14 @@ short format
<ftui-label [color]="dummy1:color">demo</ftui-label>
```
- Attribute binding:
Attribute binding helps you to set values for attributes directly.
```html
<ftui-label [attr.data-my]="dummy1:status">demo</ftui-label>
```
Output binding
--------
Expand Down
28 changes: 14 additions & 14 deletions controls_ftui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ UPD 2022-03-30_21:52:50 856 www/ftui/components/dropdown/dropdown.component.css
UPD 2022-02-15_18:26:02 2105 www/ftui/components/dropdown/dropdown.component.js
UPD 2022-10-09_21:18:08 4935 www/ftui/components/element.component.js
UPD 2022-02-06_23:45:56 758 www/ftui/components/grid/grid-header.component.js
UPD 2022-02-11_22:35:35 1992 www/ftui/components/grid/grid-tile.component.css
UPD 2023-03-31_07:06:15 2052 www/ftui/components/grid/grid-tile.component.css
UPD 2022-02-26_14:12:40 1074 www/ftui/components/grid/grid-tile.component.js
UPD 2023-01-10_22:05:45 4298 www/ftui/components/grid/grid.component.js
UPD 2022-10-30_15:58:22 1263 www/ftui/components/icon/icon.component.css
Expand All @@ -32,7 +32,7 @@ UPD 2021-02-03_14:48:37 8329 www/ftui/components/image/image_not_available.js
UPD 2022-01-24_22:06:30 2660 www/ftui/components/input/input.component.js
UPD 2022-02-01_22:51:33 1252 www/ftui/components/knob/knob.component.css
UPD 2022-02-01_14:10:29 14850 www/ftui/components/knob/knob.component.js
UPD 2022-12-12_21:22:57 3841 www/ftui/components/label/label.component.js
UPD 2024-01-16_22:33:24 3940 www/ftui/components/label/label.component.js
UPD 2021-02-01_19:44:36 1816 www/ftui/components/main/main.component.js
UPD 2023-01-18_22:53:32 2265 www/ftui/components/map/map.component.js
UPD 2021-11-21_18:01:44 180 www/ftui/components/medialist/album_icon.svg
Expand All @@ -45,7 +45,7 @@ UPD 2022-12-10_17:00:07 1642 www/ftui/components/meter/meter.component.css
UPD 2022-11-20_20:26:08 2213 www/ftui/components/meter/meter.component.js
UPD 2022-02-19_01:16:35 1084 www/ftui/components/nav/nav-link.component.js
UPD 2022-01-11_18:32:57 1477 www/ftui/components/popup/popup.component.css
UPD 2022-11-05_14:21:55 3388 www/ftui/components/popup/popup.component.js
UPD 2023-03-29_13:38:25 3388 www/ftui/components/popup/popup.component.js
UPD 2021-12-03_18:58:15 1347 www/ftui/components/rotor/rotor.component.css
UPD 2021-12-03_18:57:34 2220 www/ftui/components/rotor/rotor.component.js
UPD 2021-11-25_23:34:54 917 www/ftui/components/row/row.component.js
Expand Down Expand Up @@ -81,11 +81,11 @@ UPD 2022-02-07_00:30:28 1589 www/ftui/examples/binding.html
UPD 2020-12-31_16:39:02 913 www/ftui/examples/button-nice.html
UPD 2023-03-04_00:15:01 12665 www/ftui/examples/button.html
UPD 2022-03-10_17:58:47 3326 www/ftui/examples/chart.html
UPD 2022-02-08_19:44:11 1704 www/ftui/examples/chart2.html
UPD 2024-01-16_22:33:23 2212 www/ftui/examples/chart2.html
UPD 2022-01-06_22:08:43 1408 www/ftui/examples/checkbox.html
UPD 2021-11-30_17:17:52 9424 www/ftui/examples/circlemenu.html
UPD 2022-02-07_00:30:28 1620 www/ftui/examples/clock.html
UPD 2022-02-18_23:48:28 3845 www/ftui/examples/colorpicker.html
UPD 2024-01-16_22:33:23 3862 www/ftui/examples/colorpicker.html
UPD 2022-02-19_18:53:03 3832 www/ftui/examples/colors.html
UPD 2021-12-08_17:37:03 1865 www/ftui/examples/content.html
UPD 2022-02-07_00:30:28 919 www/ftui/examples/content2.html
Expand All @@ -104,9 +104,9 @@ UPD 2022-02-13_21:29:34 956 www/ftui/examples/contents/content-weather-day.html
UPD 2021-12-09_17:19:30 717 www/ftui/examples/contents/content-weather-item.html
UPD 2021-10-19_19:05:47 5317 www/ftui/examples/contents/content-weather.html
UPD 2022-03-06_19:45:21 810 www/ftui/examples/contents/mobile-color.html
UPD 2022-06-11_13:22:23 1464 www/ftui/examples/contents/mobile-power.html
UPD 2023-06-04_10:58:28 2118 www/ftui/examples/contents/mobile-power.html
UPD 2022-10-09_20:42:01 8248 www/ftui/examples/contents/mobile-shutter.html
UPD 2022-01-27_21:05:55 1723 www/ftui/examples/contents/mobile-solar.html
UPD 2023-06-04_11:00:44 1866 www/ftui/examples/contents/mobile-solar.html
UPD 2022-10-07_22:48:38 3397 www/ftui/examples/contents/mobile-temp.html
UPD 2022-06-19_16:52:05 2637 www/ftui/examples/contents/mobile-view-sonos.html
UPD 2022-10-24_22:52:16 1378 www/ftui/examples/contents/mobile-view-vacuum.html
Expand All @@ -118,7 +118,7 @@ UPD 2022-02-07_00:30:27 3812 www/ftui/examples/dropdown.html
UPD 2022-02-11_23:29:15 8028 www/ftui/examples/grid.html
UPD 2022-02-08_08:24:30 1038 www/ftui/examples/grid_resize.html
UPD 2022-02-08_08:24:28 982 www/ftui/examples/grid_responsive.html
UPD 2023-03-04_00:19:29 6867 www/ftui/examples/icon.html
UPD 2024-01-16_22:33:54 7382 www/ftui/examples/icon.html
UPD 2022-02-13_23:34:53 4118 www/ftui/examples/image.html
UPD 2021-11-06_00:29:33 2108 www/ftui/examples/input.html
UPD 2022-02-01_22:09:10 6532 www/ftui/examples/knob.html
Expand All @@ -129,14 +129,14 @@ UPD 2022-12-21_20:00:48 1946 www/ftui/examples/menu.html
UPD 2022-01-13_22:25:03 2315 www/ftui/examples/menu2.html
UPD 2023-03-04_00:19:15 3725 www/ftui/examples/meter.html
UPD 2022-01-31_15:27:11 3195 www/ftui/examples/mobile.html
UPD 2022-11-30_23:02:47 21394 www/ftui/examples/mobile_full.html
UPD 2024-01-16_22:42:14 21484 www/ftui/examples/mobile_full.html
UPD 2022-02-17_17:37:00 5457 www/ftui/examples/mobile_plain.html
UPD 2022-11-05_14:24:19 4695 www/ftui/examples/popup.html
UPD 2023-03-29_13:38:37 4695 www/ftui/examples/popup.html
UPD 2021-12-02_22:57:32 3576 www/ftui/examples/rotor.html
UPD 2021-11-30_17:17:52 2360 www/ftui/examples/segment.html
UPD 2023-03-03_19:04:49 4643 www/ftui/examples/slider.html
UPD 2022-02-07_00:30:28 1233 www/ftui/examples/speak.html
UPD 2022-12-08_21:55:39 20580 www/ftui/examples/swiper.html
UPD 2023-03-07_21:45:12 20580 www/ftui/examples/swiper.html
UPD 2022-11-04_20:10:56 1842 www/ftui/examples/switch.html
UPD 2022-02-01_22:19:05 2816 www/ftui/examples/tab-content.html
UPD 2021-12-08_23:45:05 2924 www/ftui/examples/tab-segment-local.html
Expand All @@ -147,7 +147,7 @@ UPD 2022-02-13_20:22:49 4259 www/ftui/examples/themes.html
UPD 2022-02-07_00:30:27 1568 www/ftui/examples/timeset.html
UPD 2022-10-30_15:54:15 4903 www/ftui/examples/weather.html
UPD 2022-11-19_19:16:10 15406 www/ftui/favicon.ico
UPD 2022-01-30_12:23:53 10900 www/ftui/ftui.css
UPD 2023-04-13_07:13:19 10900 www/ftui/ftui.css
UPD 2022-03-30_21:42:43 1326 www/ftui/ftui.js
UPD 2022-11-13_21:50:35 1881 www/ftui/icons/Celsius.svg
UPD 2022-11-13_21:50:37 1097 www/ftui/icons/Fahrenheit.svg
Expand Down Expand Up @@ -728,8 +728,8 @@ UPD 2021-02-04_22:43:17 8388 www/ftui/modules/circle-menu/circle-menu.js
UPD 2021-02-01_19:44:50 5063 www/ftui/modules/circle-menu/circle-menu.min.js
UPD 2022-05-25_18:05:01 14463 www/ftui/modules/ftui/fhem.service.js
UPD 2022-10-30_16:38:49 8285 www/ftui/modules/ftui/ftui.app.js
UPD 2022-10-09_20:49:31 12676 www/ftui/modules/ftui/ftui.binding.js
UPD 2022-04-09_20:43:58 14245 www/ftui/modules/ftui/ftui.helper.js
UPD 2024-01-16_22:13:11 12961 www/ftui/modules/ftui/ftui.binding.js
UPD 2023-05-09_22:35:26 14297 www/ftui/modules/ftui/ftui.helper.js
UPD 2020-12-31_16:39:06 9247 www/ftui/modules/hocon/hocon.js
UPD 2020-12-31_16:39:06 3192 www/ftui/modules/hocon/hocon.min.js
UPD 2021-10-13_09:24:35 65090 www/ftui/modules/iro.js/iro.js
Expand Down
3 changes: 2 additions & 1 deletion www/ftui/components/grid/grid-tile.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
justify-content: var(--grid-tile-justify-content, space-evenly);
width: 100%;
height: 100%;
min-height: 0;
box-sizing: border-box;
}

:host([is-row]) .content {
Expand Down
8 changes: 6 additions & 2 deletions www/ftui/components/label/label.component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Label component for FTUI version 3
*
* Copyright (c) 2019-2020 Mario Stephan <[email protected]>
* Copyright (c) 2019-2024 Mario Stephan <[email protected]>
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
*
* https://github.com/knowthelist/ftui
Expand Down Expand Up @@ -30,7 +30,11 @@ export class FtuiLabel extends FtuiElement {
--color-base: currentColor;
color: var(--color-base);
white-space: nowrap;
display: flex;
align-items: center;
justify-content: center;
}
:host([align-items=baseline]) { align-items: baseline;}
:host(:empty:not([text])) slot[name="unit"],
:host([text=""]) slot[name="unit"] { visibility: hidden; }
:host slot[name="unit"] { margin-left: 0.15em; display: initial; }
Expand All @@ -41,7 +45,7 @@ export class FtuiLabel extends FtuiElement {
height: .75em; border-radius: 2em;
opacity: .3; animation: fading 1.5s infinite;
min-width: 4em; }
:host([size="10"]),:host([size="11"]),:host([size="12"]),:host([thin]) {
:host([thin]) {
font-family: "HelveticaNeue-UltraLight", "Segoe UI", "Roboto Light", "San Francisco", sans-serif;
line-height: 0.8em; }
@keyframes fading {
Expand Down
16 changes: 15 additions & 1 deletion www/ftui/examples/chart2.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Version: 3.0.0
*
* Copyright (c) 2020 Mario Stephan <[email protected]>
* Copyright (c) 2020-2024 Mario Stephan <[email protected]>
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
* https://github.com/knowthelist/ftui
*/
Expand Down Expand Up @@ -56,6 +56,20 @@

</ftui-grid-tile>

<ftui-grid-tile row="3" col="1" height="2" width="3">
<header>Current</header>

<ftui-chart y-label="KWh"
y-min="0" y-max="10" unit="week">
<ftui-chart-data type="bar"
log="FileLog_StromRechner"
spec="4:StromRechner.Stromzaehler_state_EnergyDayLast::"
></ftui-chart-data>
<ftui-chart-controls units="week, 30d"></ftui-chart-controls>
</ftui-chart>

</ftui-grid-tile>

</ftui-grid>

</body>
Expand Down
20 changes: 10 additions & 10 deletions www/ftui/examples/colorpicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Version: 3.0.0
*
* Copyright (c) 2020 Mario Stephan <[email protected]>
* Copyright (c) 2020-2024 Mario Stephan <[email protected]>
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
* https://github.com/knowthelist/ftui
*/
Expand Down Expand Up @@ -45,7 +45,7 @@
<ftui-grid-tile row="1" col="3" height="1" width="1">
<header>HUE-DEVICE</header>

<ftui-colorpicker [hex]="HUEDevice6:rgb" (hex)="replace('#','') | HUEDevice6:rgb"
<ftui-colorpicker [hex]="HUEDevice20:rgb" (hex)="replace('#','') | HUEDevice20:rgb"
layout="wheel,valueSlider"></ftui-colorpicker>

</ftui-grid-tile>
Expand All @@ -62,7 +62,7 @@
<ftui-row>

<ftui-column width="10%" height="70%"><span>R</span><span>G</span><span>B</span></ftui-column>
<ftui-colorpicker [hex]="HUEDevice6:rgb" (hex)="replace('#','') | HUEDevice6:rgb"
<ftui-colorpicker [hex]="HUEDevice20:rgb" (hex)="replace('#','') | HUEDevice20:rgb"
layout="redSlider, greenSlider, blueSlider"></ftui-colorpicker>

</ftui-row>
Expand All @@ -72,20 +72,20 @@
<header>HORIZONTAL</header>

<ftui-colorpicker direction="horizontal" layout="hueSlider, valueSlider"
[hex]="HUEDevice6:rgb" (hex)="replace('#','') | HUEDevice6:rgb"></ftui-colorpicker>
[hex]="HUEDevice20:rgb" (hex)="replace('#','') | HUEDevice20:rgb"></ftui-colorpicker>
</ftui-grid-tile>


<ftui-grid-tile row="2" col="3" height="1" width="1">
<header>SAT/BRI/HUE</header>

<ftui-colorpicker direction="horizontal" layout="hueSlider,saturationSlider,valueSlider"
[hue]="HUEDevice6:hue | divide(182.0425) | toInt() | "
[saturation]="HUEDevice6:sat | divide(2.55) | toInt()"
[brightness]="HUEDevice6:bri | divide(2.55) | toInt()"
(hue)="multiply(182.0425) | toInt() | HUEDevice6:hue"
(saturation)="multiply(2.55) | toInt() | HUEDevice6:sat"
(brightness)="multiply(2.55) | toInt() | HUEDevice6:bri">
[hue]="HUEDevice20:hue | divide(182.0425) | toInt() | "
[saturation]="HUEDevice20:sat | divide(2.55) | toInt()"
[brightness]="HUEDevice20:bri | divide(2.55) | toInt()"
(hue)="multiply(182.0425) | toInt() | HUEDevice20:hue"
(saturation)="multiply(2.55) | toInt() | HUEDevice20:sat"
(brightness)="multiply(2.55) | toInt() | HUEDevice20:bri">
</ftui-colorpicker>
</ftui-grid-tile>

Expand Down
29 changes: 22 additions & 7 deletions www/ftui/examples/contents/mobile-power.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
</ftui-view-sheet>

<ftui-view-section>
<ftui-label slot="header" text="Energy"></ftui-label>

<ftui-label slot="header" text="Energy Used"></ftui-label>
<ftui-view-item>Total
<ftui-label [text]="Stromzaehler"></ftui-label>
</ftui-view-item>
Expand All @@ -28,15 +27,31 @@
</ftui-view-section>

<ftui-view-section>
<ftui-label slot="header" text="Cost"></ftui-label>
<ftui-label slot="header" text="Energy Paid"></ftui-label>
<ftui-view-item>Total
<ftui-label [text]="SmartMeter:GS303_Total_in"></ftui-label>
</ftui-view-item>
<ftui-view-item>Today
<ftui-label [text]="StromRechner:Stromzaehler_state_EnergyCostDay | fix(2)" unit=" "></ftui-label>
<ftui-label [text]="StromRechnerIn:SmartMeter_GS303_Total_in_EnergyDay" unit=" KWh"></ftui-label>
</ftui-view-item>
<ftui-view-item>Yesterday
<ftui-label [text]="StromRechner:Stromzaehler_state_EnergyCostDayLast | fix(2)" unit=" "></ftui-label>
</ftui-view-item>
<ftui-label [text]="StromRechnerIn:SmartMeter_GS303_Total_in_EnergyDayLast" unit=" KWh"></ftui-label>
</ftui-view-item>
<ftui-view-item>Month
<ftui-label [text]="StromRechner:Stromzaehler_state_EnergyCostMonth | fix(2)" unit=""></ftui-label>
<ftui-label [text]="StromRechnerIn:SmartMeter_GS303_Total_in_EnergyMonth" unit=" KWh"></ftui-label>
</ftui-view-item>
</ftui-view-section>

<ftui-view-section>
<ftui-label slot="header" text="Cost"></ftui-label>
<ftui-view-item>Today
<ftui-label [text]="StromRechnerIn:SmartMeter_GS303_Total_in_EnergyCostDay | fix(2)" unit=""></ftui-label>
</ftui-view-item>
<ftui-view-item>Saved
<ftui-label [text]="StromRechner:gespart | fix(2)" unit=""></ftui-label>
</ftui-view-item>
<ftui-view-item>Given Away
<ftui-label [text]="StromRechnerOut:SmartMeter_GS303_Total_out_EnergyCostDay | fix(2)" unit=""></ftui-label>
</ftui-view-item>
</ftui-view-section>

3 changes: 3 additions & 0 deletions www/ftui/examples/contents/mobile-solar.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<ftui-view-item>Energy today
<ftui-label [text]="PVConverter:Eac_today" unit="KWh"></ftui-label>
</ftui-view-item>
<ftui-view-item>Energy Given Away
<ftui-label [text]="SmartMeter:GS303_Total_out | fix(1)"" unit="KWh"></ftui-label>
</ftui-view-item>
</ftui-view-section>

<ftui-view-section>
Expand Down
22 changes: 19 additions & 3 deletions www/ftui/examples/icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Version: 3.0.0
*
* Copyright (c) 2015-2019 Mario Stephan <[email protected]>
* Copyright (c) 2015-2024 Mario Stephan <[email protected]>
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
* https://github.com/knowthelist/ftui
*/
Expand All @@ -21,7 +21,11 @@
<link href="favicon.ico" rel="icon" type="image/x-icon" />

<meta name='viewport' content='width=device-width'>

<style>
[data-val1="on"][data-val2="on"] {
color: var(--success-color);
}
</style>
<!-- when serving the page with other web servers, e.g. lighttpd -->
<!-- <meta name="fhemweb_url" content="http://fhem.local:8083/fhem/"> -->
<title>FTUI Example Icon</title>
Expand All @@ -45,7 +49,7 @@

<ftui-column>
<!-- binding short-->
<ftui-icon [name]="dummy1 | map('on:lightbulb-on, off:lightbulb')" [rgb]="HUEDevice6:rgb">
<ftui-icon [name]="dummy1 | map('on:lightbulb-on, off:lightbulb')" [rgb]="HUEDevice20:rgb">
</ftui-icon>

<ftui-label [text]="dummy1"></ftui-label>
Expand Down Expand Up @@ -187,6 +191,18 @@
<ftui-label [text]="AgroWeather:wind" unit="km/h"></ftui-label>
</ftui-grid-tile>

<ftui-grid-tile row="7" col="13" height="4" width="2">
<header>attribute-binding Logic-OR</header>
<!-- color change via Style rule-->
<ftui-icon name="file"
[attr.data-val1]="local:val1"
[attr.data-val2]="local:val2">
</ftui-icon>
<ftui-switch [(value)]="local:val1"></ftui-switch>
<ftui-switch [(value)]="local:val2"></ftui-switch>
</ftui-grid-tile>


</ftui-grid>
</body>

Expand Down
Loading

0 comments on commit 705cff6

Please sign in to comment.