1<?php 2 3namespace ComboStrap; 4 5/** 6 * Branding colors are the primary and secondary colors of the web site 7 * (for now) 8 * 9 * Don't confuse with {@link Brand} 10 */ 11class BrandingColors 12{ 13 14 /** 15 * Do we set also the branding color on 16 * other elements ? 17 */ 18 public const BRANDING_COLOR_INHERITANCE_ENABLE_CONF = "brandingColorInheritanceEnable"; 19 public const BRANDING_COLOR_INHERITANCE_ENABLE_CONF_DEFAULT = 1; 20 public const PRIMARY_COLOR_CONF = "primaryColor"; 21 22 const CANONICAL = "branding-colors"; 23 24 /** 25 * The attribute used in the model template data 26 * (used for css variables and other colors transformation) 27 */ 28 const PRIMARY_COLOR_TEMPLATE_ATTRIBUTE = 'primary-color'; 29 /** 30 * A color that is derived from the primary color 31 * where the contrast is good enought for reading 32 */ 33 const PRIMARY_COLOR_TEXT_ATTRIBUTE = "primary-color-text"; 34 /** 35 * The text color with a little bit more lightness 36 */ 37 const PRIMARY_COLOR_TEXT_HOVER_ATTRIBUTE = "primary-color-text-hover"; 38 public const SECONDARY_COLOR_TEMPLATE_ATTRIBUTE = 'secondary-color'; 39 40 public static function getCssFormControlFocusColor(ColorRgb $primaryColor): string 41 { 42 43 try { 44 $colorRgb = ColorSystem::toBackgroundColor($primaryColor); 45 } catch (ExceptionCompile $e) { 46 LogUtility::msg("Error on background color calculation"); 47 return ""; 48 } 49 50 return <<<EOF 51.form-control:focus { 52 border-color: $colorRgb; 53 box-shadow: 0 0 0 0.25rem rgb({$primaryColor->getRed()} {$primaryColor->getGreen()} {$primaryColor->getBlue()} / 25%); 54} 55.form-check-input:focus { 56 border-color: $colorRgb; 57 box-shadow: 0 0 0 0.25rem rgb({$primaryColor->getRed()} {$primaryColor->getGreen()} {$primaryColor->getBlue()} / 25%); 58} 59EOF; 60 61 62 } 63 64 65} 66