Can the list of css classes for a dashboard element be tweeked to include the element label (or name, or icon)?
This would allow custom css for each button.
For example I have two buttons "Power" and "Up". The HTML produced for each one is
<button class="md-raised md-button md-ink-ripple" ...
If it was eg
<button class="md-raised md-button md-ink-ripple Up" ... I could increase the font size in the Up button through CSS
I know it's possible to create a button entirely in a template node but my use of templates isn't that advanced yet, I only define CSS there.
Thanks for that suggestion Steve.
It is a viable work-around. Using
[node-id="d516453f.5bb218"] > button i {
font-size:86px !important;
} I can change font size on that specific button:
Are node ids static? If I imported the flow from a backup would I still have the same ids?
Incidentally the colour and background colour in your example can also be specified (better?) by means of msg.background = "#ff0000"
and background {{background}} in the node properties
Of course you can use #xxxxxxx colours but if you want it dynamic (sent from a msg), you might as well use JQuery & a ui-template script to set the $('.selector').css("name", "value") of the item.
Was that a question? No, just commenting that those two style elements (for a button at least) can also be set in other ways:
From Help for ui_button
The colours of the text and background may be set. They can also be set by a message property by setting the field to the name of the property, for example {{background}} . You don't need to prepend the msg. part of the property name.
The label and icon can also be set by a message property by setting the field to the name of the property, for example {{topic}} or {{myicon}} .
"JQuery & a ui-template script to set the $('.selector').css("name", "value")" goes over my head, sorry!
I seem to remember seeing a pattern in some JQuery UI widgets - they have a class or className option that gets appended to the classlist when the widget is instantiated. This permits you to fine tune styling of the element after creation. (though I cant find an example right now - doh)
Maybe a field in the node properties in the editor - "CSS Class"?
Just thinking about buttons, that would mean I could easily have round and square buttons, backgrounds etc on the same dashboard.
There would have be to be a template node of course but it would only require CSS, and could be in the page header.
The concept of having class for every item is in straight conflict with css specification so should be avoided. The id may be under discussion but not the class.
Button with Id 123 should have same class as button with id 234. That way. Value (name, label or what ever kind) based commonness should be kept as id related. And if there is name based structure for those, that will be helpful for overrides.
To have different types of buttons with different classes (provided by one widget) to drive their look it may be the thing of widget configuration so the class is created. But it is all advanced stuff. The user without any experience of HTML and CSS just can't use them as they are things based on at least some knowledge on that area. Providing such advanced stuff falls on area of distraction rather on being helpful.
Also the id has higher specificity in CSS hierarchy so it will be much easier to to have effect on current dashboard structure. But that is just small technical limitation to get over.