File modules/cms/ui/themes/ThemeStyle.class.php

Last commit: Mon Feb 22 23:51:21 2021 +0100	Jan Dankert	Better look of styles.
1 <?php 2 3 4 namespace cms\ui\themes; 5 6 7 use cms\base\Configuration as C; 8 use util\text\Converter; 9 10 class ThemeStyle 11 { 12 private $name; 13 14 private $textColor = 'black'; 15 private $backgroundColor = '#d9d9d9'; 16 17 private $inactiveBackgroundColor; 18 19 private $mainTextColor ; 20 private $mainBackgroundColor; 21 private $mainTitleBackgroundColor; 22 private $mainTitleTextColor; 23 24 private $navBackgroundColor; 25 private $navTextColor; 26 private $navTitleBackgroundColor; 27 private $navTitleTextColor; 28 29 private $dialogTitleBackgroundColor; 30 private $dialogTitleTextColor; 31 private $dialogBackgroundColor; 32 private $dialogTextColor; 33 34 private $themeColor; 35 private $arrowColor; 36 private $imageColor; 37 38 private $noticeOkColor = '#00d95a'; 39 private $noticeInfoColor = '#86caff'; 40 private $noticeWarningColor = '#FBDE2D'; 41 private $noticeErrorColor = '#f54b07'; 42 43 private $transitionDuration = '0.2s'; 44 45 /** 46 * ThemeStyle constructor. 47 */ 48 public function __construct( $config ) 49 { 50 if ( is_string( $config ) ) 51 $config = C::subset('style')->get( $config,[]); // user style config 52 53 $this->setValues( $config ); 54 $this->fillMissingValues(); 55 } 56 57 58 59 protected function setValues( $styleConfig ) { 60 61 foreach( $styleConfig as $property=>$value ) { 62 $property = Converter::toCamelCase($property); 63 if ( property_exists($this,$property ) ) { 64 $this->$property = $value; 65 } 66 } 67 } 68 69 70 /** 71 * Fill empty values with a default value. 72 */ 73 protected function fillMissingValues() { 74 75 if ( ! $this->mainTitleBackgroundColor ) 76 $this->mainTitleBackgroundColor = $this->backgroundColor; 77 78 if ( ! $this->mainTitleTextColor ) 79 $this->mainTitleTextColor = $this->textColor; 80 81 if ( ! $this->mainBackgroundColor ) 82 $this->mainBackgroundColor = $this->backgroundColor; 83 84 if ( ! $this->mainTextColor ) 85 $this->mainTextColor = $this->textColor; 86 87 if ( ! $this->themeColor ) 88 $this->themeColor = $this->mainTitleBackgroundColor; 89 90 if ( ! $this->inactiveBackgroundColor ) 91 $this->inactiveBackgroundColor = $this->backgroundColor; 92 93 94 if ( ! $this->navTextColor ) 95 $this->navTextColor = $this->mainTextColor; 96 97 if ( ! $this->navBackgroundColor ) 98 $this->navBackgroundColor = $this->mainBackgroundColor; 99 100 if ( ! $this->navTitleTextColor ) 101 $this->navTitleTextColor= $this->navTextColor; 102 103 if ( ! $this->navTitleBackgroundColor ) 104 $this->navTitleBackgroundColor = $this->navBackgroundColor; 105 106 107 if ( ! $this->dialogTitleTextColor ) 108 $this->dialogTitleTextColor = $this->mainTitleTextColor; 109 110 if ( ! $this->dialogTitleBackgroundColor ) 111 $this->dialogTitleBackgroundColor = $this->mainTitleBackgroundColor; 112 113 if ( ! $this->dialogTextColor ) 114 $this->dialogTextColor = $this->mainTextColor; 115 116 if ( ! $this->dialogBackgroundColor ) 117 $this->dialogBackgroundColor = $this->mainBackgroundColor; 118 119 120 if ( ! $this->arrowColor ) 121 $this->arrowColor = $this->themeColor; 122 123 if ( ! $this->imageColor ) 124 $this->imageColor = $this->mainTitleTextColor; 125 } 126 127 128 129 public function getProperties() { 130 131 return get_object_vars($this); 132 } 133 134 /** 135 * Theme color. 136 * 137 * @return string 138 */ 139 public function getThemeColor() 140 { 141 return $this->themeColor; 142 } 143 }
Download modules/cms/ui/themes/ThemeStyle.class.php
History Mon, 22 Feb 2021 23:51:21 +0100 Jan Dankert Better look of styles. Sat, 13 Feb 2021 00:11:23 +0100 Jan Dankert New: Transition-Duration is controllable via style configuration. So there is no need for a dedicated FX on/off-switch in the profile. Fri, 12 Feb 2021 00:43:08 +0100 Jan Dankert New: Style colors; Fix: Mobile navigation, global search. Wed, 10 Feb 2021 22:04:26 +0100 Jan Dankert Provide the theme configuration through a class.