@** * Yobi, Project Hosting SW * * Copyright 2014 NAVER Corp. * http://yobi.io * * @author Jihan Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **@ @(labels:List[models.IssueLabel]) @getLabelTextColorFromBgColor(bgColor: String) = @{ def parseFromRGB(bgColor:String):Map[String,Int] = { val start = bgColor.indexOf('(') + 1 val end = bgColor.indexOf(')') val baseColor = bgColor.substring(start, end).split(",") scala.collection.Map( "R" -> Integer.parseInt(baseColor(0), 10), "G" -> Integer.parseInt(baseColor(1), 10), "B" -> Integer.parseInt(baseColor(2), 10) ) } def parseFromHex(bgColor:String):Map[String,Int] = { val paramColor: String = if ((bgColor indexOf "#") != 0) "#" + bgColor else bgColor val baseColor: String = if ((paramColor.length == 4)) "#" + (paramColor.substring(1) * 2) + (paramColor.substring(2) * 2) + (paramColor.substring(3) * 2) else paramColor if(baseColor.length == 7){ scala.collection.Map( "R" -> Integer.parseInt(baseColor.substring(1, 3), 16), "G" -> Integer.parseInt(baseColor.substring(3, 5), 16), "B" -> Integer.parseInt(baseColor.substring(5, 7), 16) ) } else { getDefaultRGB } } def getDefaultRGB: Map[String,Int] = { scala.collection.Map("R" -> 255, "G" -> 255, "B" -> 255) } val YCC_DARK = 192 val RGB = bgColor.toLowerCase() match { case s if s.startsWith("rgb") => parseFromRGB(s) case s if s.matches("^[#]*[0-9a-z]+$") => parseFromHex(s) case _ => getDefaultRGB } val colorSpace = (RGB.get("R") * 0.21) + (RGB.get("G") * 0.72) + (RGB.get("B") * 0.07) if ((colorSpace > YCC_DARK)) "dimgray" else "white" } @for(label <- labels){ .issue-label[data-label-id="@label.id"]{ box-shadow: inset 2px 0 0px @label.color; -webkit-box-shadow: inset 2px 0 0px @label.color; -moz-box-shadow: inset 2px 0 0px @label.color; } .issue-label.active[data-label-id="@label.id"]{ background-color: @label.color; color: @getLabelTextColorFromBgColor(label.color); } }