Hi, I recently started creating custom widgets by myself, and now I came to a point where I don’t know how to do it.
In this topic, OH3 Livio Energy Summary Animated I found out that you can create any HTML structure by using f7-rows with a tag. Now, my plan was to recreate the remote control of my TV as a custom widget that also includes curved text.
My idea was to do the curved text with a SVG like the linked widget was done, but here comes the problem.
With f7-rows, you can create any HTML-object with any properties, but I could not find out how to get actual text in there:
<text> How to get text here? </text>
Do you know if and how this is possible?
Here is the code of my test widget. To get the text displayed, I used the onclick function for testing purposes. Of course, I would like to do this without any user interaction and have it displayed by default. (The onload function unfortunately does not work.)
The only way I can think of off the top of my head to use strictly MainUI components to build curved text would be to use a repeater on a character array to produce and element with each character and use css to turn and place each element. It’s probably fewer lines of yaml and a
more “native” solution, but not necessarily a better solution. What you’ve got works pretty well.
At present I don’t think this is possible just with the available widgets. There are plenty of uses for such a feature within the f7 components and the community is building more and more advanced widgets, however, so it might be worth a pull request or feature request on github. I could envision something simple like the Label component only which doesn’t wrap the given text in a div element. Or even just a setting on the Label component that strips the div.
onload works within widgets, but not every element triggers an onload event. One of those, however is style which is otherwise completely innocuous, so you can use the same f7 tag technique to add an f7-row with a style tag and set onload.
The only way I can think of off the top of my head to use strictly MainUI components to build curved text would be to use a repeater on a character array to produce and element with each character and use css to turn and place each element.
Maybe I will try that out and if I manage to do it, the code will be shared here.
so it might be worth a pull request or feature request on github.
I have never used github yet, but this might be a reason to get started and test it out.
For the record, the addition of text to an svg is now possible in the newest milestone (3.4M4) without the ugly js hack. In fact, the creation of svgs and straight html is now much easier. See the new docs here about html tags and the new Content component: