Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 240 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187.1K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 443 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Conditional colors for fontawesome in Card List

I want to use fontawesome icons in a card list but I want to change the color of the icon depending on certain conditions. How can I do this within the Apex framework?
Answers
-
Jon Barwell wrote: I want to use fontawesome icons in a card list but I want to change the color of the icon depending on certain conditions. How can I do this within the Apex framework?
What is the card list based on? Is is static or dynamic?
The basic approach would be to implement the conditional logic using CASE expressions in a dynamic list query to return class/colour information in the image/class or custom attribute columns. A custom list template and style sheet might also be required to apply the necessary colours.
-
I am going to create a dynamic list.
I have included the following as inline CSS to test
*.icon-red {color: red}
*.icon-green {color: green}
And then in the SQL query I was using
'fa-check icon-green' AS image
to set the check icon to green to test but it stays the default color.
What am I doing wrong?
-
Remove asterisk from CSS selectors and try to add !important after color, for example:
.icon-red {color: red !important}
.icon-green {color: green !important}
You can use some browser developer tool (like FireBug) to see/debug which style is used for icon color.
-
Jon Barwell wrote: I am going to create a dynamic list. I have included the following as inline CSS to test *.icon-red {color: red} *.icon-green {color: green} And then in the SQL query I was using 'fa-check icon-green' AS image to set the check icon to green to test but it stays the default color. What am I doing wrong?
Your CSS rules are being overridden by theme rules with a higher specificity. You can try using the !important directive to overcome this, but I suspect the results may still not be what you are looking for.
.icon-red {color: red !important} .icon-green {color: green !important}
The cards list is quite a complicated component, with some of the presentation determined by fixed classes in the template and some that is modifiable through the List Template Options in the list definition. We therefore need to know which options are being used, and what values are being generated in the region source. Obviously the best way to do this is to create and share an example on apex.oracle.com.
-
Thanks for reply. Based on your response my alternative is to use icon view in the interactive report as I want my solution to be simple and use standard functionality where possible. I have a fixed list of objectives that specific users have to achieve and I wanted to change the icons like a traffic light to indicate their level of monthly achievements. Your explanation of thow the Cards List works has convinced me that this is not the correct solution.
Thanks,
Jon
-
I've taken a closer look at the Cards list option, and implemented a "traffic light" RAG colour scheme using a new template option and custom CSS.
1. Create a copy of the Cards list template called Cards w/ RAG colors.
2. Add a new template option to the Cards w/ RAG colors template:
Sequence: 20
Group: Color Accents
Display name: Use RAG Colors
Option Identifier: USE_RAG_COLORS
CSS classes: t-Cards--RAG
3. Add the custom CSS for the RAG colours to the template Inline CSS property:
.t-Card--RAG .RAG-red .t-Card-icon .t-Icon, .t-Cards--RAG .RAG-red .t-Card .t-Card-icon .t-Icon { background-color: #c0504d; } .t-Card--RAG .RAG-amber .t-Card-icon .t-Icon, .t-Cards--RAG .RAG-amber .t-Card .t-Card-icon .t-Icon { background-color: #f79646; } .t-Card--RAG .RAG-green .t-Card-icon .t-Icon, .t-Cards--RAG .RAG-green .t-Card .t-Card-icon .t-Icon { background-color: #9bbb59; }
4. Compute the "traffic light" RAG class conditionally in the list source query, returning the value in the list's
attribute4
position, which the template uses to apply a class to the list entry via the #A04# substitution string:select ... , case when d.employees < 3 then 'RAG-red' when d.employees < 7 then 'RAG-amber' else 'RAG-green' end attribute4 ...
-
Works brilliantly :-)
Thanks
Jon