Hi there AppWorks fans,
Welcome to a new installment of AppWorks tips.
A simple feature explained on this week of this new year, but it can be a challenging task when you don’t know where to start looking. What am I talking about? Well, have you ever wondered why you don’t see any nice icons when you stack panels on top of each other (to get tabs) in a layout? I don’t have a clue why that is!? Only, our end-users like to have a fancy User-Xperience and this falls, or stands with proper icons, coloring, and logically placed elements. Long, long time ago we already played with a ‘Theme’ type of document with CSS (or better LESS) in this post. I use my own post as start point for this post…
Let get right into it…
We directly dive into our workspace/project where we have a simple ‘Project’ entity available with just one prj_name
property; As great low-code developer you updated all the generated BBs nicely with your own naming standards and saved the entity in a folder with name entities
. With this prototype ready, create an instance in runtime and open/view it with the default generated layout.
To make this view a bit nicer, we can add an icon to our form! Open the layout lyt_default
of the entity and update the setting of the form panel. Simple and efficient like this:
Don’t ask me why it’s called ‘Chrome’ as this option also works in ‘Edge’!
The end-result?
Now, move back to that lyt_default
layout in the designer and stack a second form panel onto the current form. This makes a tab-panel in your layout. You will that see the ‘Full-Chrome’ option grayed out on both tabs. This is the view after a publication:
WHAT? Where are my nice end-user icons? Yes, that’s what we would like to solve in this post!
The solvation-part
Let’s do one step back…Remove the tabbed form (from the layout), republish again, and check the icon element from the “Developer tools” <F12>
perspective:
For some strange reason I first needed to remove both forms from the layout and add a new one to reconstruct the icon in runtime…It is what it is!
This is the HTML-snipped loading an SVG image:
1 | <panel-header class="emp-panel-header au-target" ref="panelHeader" au-target-id="1167" style="display: block;"> |
Now, return to the stacked form option again, do a publication, and check the tab in runtime via the developer tools. The tab icons are gone, but let’s CSS-hack the icons back into place by adding a style rule:
A little CSS background on
label#tab-header-0
label
is the HTML-element#tab-header-0
is theid
attribute in the html element; A CSS-selector on ID-value!- You can also do a CSS-selector on CLASS-value:
label.nav-label
; Watch the difference in#
/.
- Get more specific with a CSS-selector on attribute-value:
label.nav-label[title="Form"]
With this commented knowledge in mind, we can easily produce something like this:
1 | label.nav-label[title="Form"] { |
Now you guess what should be place between those quotation marks for the url("")
!? to have a result like this:
It’s a party! 🎉
The answer to that question is off course the value of that
src
attribute of our HTML snipped from above. This value starts withdata:image/svg+xml;...
.
The “advanced” theme document
All nice and great what we did in the previous section, but this is not a solid solution! After a refresh of the page, our changes are gone. So, how to use this CSS part nicely in our solution? Well, that will be our document of type ‘Theme’…Aha! I already referred to it in the intro of this post…
I have a theme document with thm_default
in the theme
folder of my solution. Open it and jump to the ‘Advanced’ tab. You see some CSS variable definitions starting with @
(This is a LESS feature) and after this you will see the body{}
CSS part. Scroll all the way down (to the end) and add your own CSS part outside the body-part. Save it and publish it; this will result in a custom.css
behind URL: http://192.168.56.107:8080/home/appworks_tips/themes/custom.css
.
Have a refresh in runtime and check the result. Use an incognito tab if you don’t see the result directly!
For those innovative people
We now reused the data:image/svg+xml;...
string for our image, but how about the popular icons from fontawesome? You can download the SVG file, save it in an ‘assets’ folder of the project, and publish it into runtime via a document of type ‘Web Library Definition’; Have a read about WLD here. You’re CSS part will look like this:
1 | label.nav-label[title="Form"] { |
Don’t want SVG? Convert the SVG to PNG on svgtopng.com.
Ohw yeah! That’s a nice iconized “DONE”. We again see what a little CSS powder can do for our end-users. It’s a small thing but trust me this will improve UX overall for the AppWorks runtime. There is nothing more to tell, just try out these kinds of small tweaks yourself and validate the benefits before you dive into a full-blown custom UI on itself with all the fancy JavaScript frameworks these days. Stay with your roots and pick the fruits of simplicity! Have a great weekend…cheers.
Don’t forget to subscribe to get updates on the activities happening on this site. Have you noticed the quiz where you find out if you are also “The AppWorks guy”?