Hi guys,
I am writing this post because recently i used it and feel
must share it,
Here I am creating a VF with some colored arrow on page (Created by using CSS) and color of arrows automatically changes according to the color and style of the Custom-Tab,
Here I am creating a VF with some colored arrow on page (Created by using CSS) and color of arrows automatically changes according to the color and style of the Custom-Tab,
This requirement is mainly needed when you are creating a detail VF page
Now magic is to use arrow
color same as the Tab color of your object.
I achieved this using Javascript and CSS,
Here is the VF page code:-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Custom_Object__c" sidebar="false" showHeader="false" id="ThePage"> | |
<style> | |
.txt{ | |
font-size: large; | |
} | |
.txtSelected{ | |
color: white; | |
} | |
.txt:hover{ | |
background-color: #EDF4F5; | |
cursor: pointer; | |
} | |
.arrow-right { | |
border-top: 10px solid transparent; | |
border-bottom: 10px solid transparent; | |
border-left: 10px solid; | |
} | |
</style> | |
<script type="text/javascript"> | |
// Method for dynamic pick color from Tab style. | |
window.onload = function(){ | |
// Get Color of the Tab. | |
// "secondaryPalette" is the Standard CSS, | |
// i am taking the color code form Standart CSS. | |
var elementByCssName = document.getElementsByClassName("secondaryPalette")[1]; | |
var colorValue = window.getComputedStyle(elementByCssName, null).getPropertyValue("border-color"); | |
// Hide PageBlock. | |
// the page block i am using only for color code or you can avoid it. | |
var PageBk = document.getElementById("ThePage:blk"); | |
PageBk.style.display = "none"; | |
// now, set arror and highlight color. | |
var arrorsElts = document.getElementsByClassName("arrow-right"); | |
for(var i = 0; i < arrorsElts.length; i++){ | |
arrorsElts[i].style.color = colorValue; | |
} | |
var selectedElt = document.getElementsByClassName("txtSelected"); | |
for(var i = 0; i < selectedElt.length; i++){ | |
selectedElt[i].style.background = colorValue; | |
} | |
} | |
</script> | |
<div> | |
<table style="margin: 0 auto;"> | |
<tr> | |
<td> | |
<div class="txt"> | |
Created | |
</div> | |
</td> | |
<td> | |
<div class ="arrow-right"></div> | |
</td> | |
<td> | |
<div class="txt"> | |
Sent to Vendor | |
</div> | |
</td> | |
<td> | |
<div class ="arrow-right"></div> | |
</td> | |
<td> | |
<div class="txt"> | |
Partially Received | |
</div> | |
</td> | |
<td> | |
<div class ="arrow-right"></div> | |
</td> | |
<td> | |
<div class="txt"> | |
Received | |
</div> | |
</td> | |
<td> | |
<div class ="arrow-right"></div> | |
</td> | |
<td> | |
<div class="txt txtSelected"> | |
Cancelled | |
</div> | |
</td> | |
</tr> | |
</table> | |
</div> | |
<apex:pageBlock id="blk"> | |
</apex:pageBlock> | |
</apex:page> |
Screen Shots:
Setup -> Create -> Tabs -> Custom_Object__c
Here is the new Tab style and color:-
arrows and highlighted section color changes automatically.
Hope it will help u guys, Happy Coding....:)