ConsoleCommand
2 years ago
Dimension
2 years ago
API.php
2 years ago
AggregatedMetric.php
2 years ago
ArchivedMetric.php
2 years ago
Archiver.php
2 years ago
Categories.php
2 years ago
ComponentFactory.php
2 years ago
ComputedMetric.php
2 years ago
ConsoleCommand.php
2 years ago
Controller.php
2 years ago
ControllerAdmin.php
2 years ago
Dependency.php
2 years ago
LogTablesProvider.php
2 years ago
Manager.php
2 years ago
Menu.php
2 years ago
MetadataLoader.php
2 years ago
Metric.php
2 years ago
PluginException.php
2 years ago
ProcessedMetric.php
2 years ago
ReleaseChannels.php
2 years ago
Report.php
2 years ago
ReportsProvider.php
2 years ago
RequestProcessors.php
2 years ago
Segment.php
2 years ago
SettingsProvider.php
2 years ago
Tasks.php
2 years ago
ThemeStyles.php
2 years ago
ViewDataTable.php
2 years ago
Visualization.php
2 years ago
WidgetsProvider.php
2 years ago
ThemeStyles.php
170 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | * |
| 9 | */ |
| 10 | namespace Piwik\Plugin; |
| 11 | |
| 12 | use Piwik\Piwik; |
| 13 | class ThemeStyles |
| 14 | { |
| 15 | // to maintain BC w/ old names that were defined in LESS |
| 16 | private static $propertyNamesToLessVariableNames = ['fontFamilyBase' => 'theme-fontFamily-base', 'colorBrand' => 'theme-color-brand', 'colorBrandContrast' => 'theme-color-brand-contrast', 'colorText' => 'theme-color-text', 'colorTextLight' => 'theme-color-text-light', 'colorTextLighter' => 'theme-color-text-lighter', 'colorTextContrast' => 'theme-color-text-contrast', 'colorLink' => 'theme-color-link', 'colorBaseSeries' => 'theme-color-base-series', 'colorHeadlineAlternative' => 'theme-color-headline-alternative', 'colorHeaderBackground' => 'theme-color-header-background', 'colorHeaderText' => 'theme-color-header-text', 'colorMenuContrastText' => 'theme-color-menu-contrast-text', 'colorMenuContrastTextSelected' => 'theme-color-menu-contrast-textSelected', 'colorMenuContrastTextActive' => 'theme-color-menu-contrast-textActive', 'colorMenuContrastBackground' => 'theme-color-menu-contrast-background', 'colorWidgetExportedBackgroundBase' => 'theme-color-widget-exported-background-base', 'colorWidgetTitleText' => 'theme-color-widget-title-text', 'colorWidgetTitleBackground' => 'theme-color-widget-title-background', 'colorBackgroundBase' => 'theme-color-background-base', 'colorBackgroundTinyContrast' => 'theme-color-background-tinyContrast', 'colorBackgroundLowContrast' => 'theme-color-background-lowContrast', 'colorBackgroundContrast' => 'theme-color-background-contrast', 'colorBackgroundHighContrast' => 'theme-color-background-highContrast', 'colorBorder' => 'theme-color-border', 'colorCode' => 'theme-color-code', 'colorCodeBackground' => 'theme-color-code-background', 'colorWidgetBackground' => 'theme-color-widget-background', 'colorWidgetBorder' => 'theme-color-widget-border']; |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | public $fontFamilyBase = '-apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Cantarell, \'Helvetica Neue\', sans-serif'; |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | public $colorBrand = '#43a047'; |
| 25 | /** |
| 26 | * @var string |
| 27 | */ |
| 28 | public $colorBrandContrast = '#fff'; |
| 29 | /** |
| 30 | * @var string |
| 31 | */ |
| 32 | public $colorText = '#212121'; |
| 33 | /** |
| 34 | * @var string |
| 35 | */ |
| 36 | public $colorTextLight = '#444'; |
| 37 | /** |
| 38 | * @var string |
| 39 | */ |
| 40 | public $colorTextLighter = '#666666'; |
| 41 | /** |
| 42 | * @var string |
| 43 | */ |
| 44 | public $colorTextContrast = '#37474f'; |
| 45 | /** |
| 46 | * @var string |
| 47 | */ |
| 48 | public $colorLink = '#1976D2'; |
| 49 | /** |
| 50 | * @var string |
| 51 | */ |
| 52 | public $colorBaseSeries = '#ee3024'; |
| 53 | /** |
| 54 | * @var string |
| 55 | */ |
| 56 | public $colorHeadlineAlternative = '#4E4E4E'; |
| 57 | /** |
| 58 | * @var string |
| 59 | */ |
| 60 | public $colorHeaderBackground = '#3450A3'; |
| 61 | /** |
| 62 | * @var string |
| 63 | */ |
| 64 | public $colorHeaderText = '#fff'; |
| 65 | /** |
| 66 | * @var string |
| 67 | */ |
| 68 | public $colorMenuContrastText; |
| 69 | /** |
| 70 | * @var string |
| 71 | */ |
| 72 | public $colorMenuContrastTextSelected; |
| 73 | /** |
| 74 | * @var string |
| 75 | */ |
| 76 | public $colorMenuContrastTextActive = '#3450A3'; |
| 77 | /** |
| 78 | * @var string |
| 79 | */ |
| 80 | public $colorMenuContrastBackground; |
| 81 | /** |
| 82 | * @var string |
| 83 | */ |
| 84 | public $colorWidgetExportedBackgroundBase; |
| 85 | /** |
| 86 | * @var string |
| 87 | */ |
| 88 | public $colorWidgetTitleText; |
| 89 | /** |
| 90 | * @var string |
| 91 | */ |
| 92 | public $colorWidgetTitleBackground; |
| 93 | /** |
| 94 | * @var string |
| 95 | */ |
| 96 | public $colorBackgroundBase = '#eff0f1'; |
| 97 | /** |
| 98 | * @var string |
| 99 | */ |
| 100 | public $colorBackgroundTinyContrast = '#f2f2f2'; |
| 101 | /** |
| 102 | * @var string |
| 103 | */ |
| 104 | public $colorBackgroundLowContrast = '#d9d9d9'; |
| 105 | /** |
| 106 | * @var string |
| 107 | */ |
| 108 | public $colorBackgroundContrast = '#fff'; |
| 109 | /** |
| 110 | * @var string |
| 111 | */ |
| 112 | public $colorBackgroundHighContrast = '#202020'; |
| 113 | /** |
| 114 | * @var string |
| 115 | */ |
| 116 | public $colorBorder = '#cccccc'; |
| 117 | /** |
| 118 | * @var string |
| 119 | */ |
| 120 | public $colorCode = '#f3f3f3'; |
| 121 | /** |
| 122 | * @var string |
| 123 | */ |
| 124 | public $colorCodeBackground = '#4d4d4d'; |
| 125 | /** |
| 126 | * @var string |
| 127 | */ |
| 128 | public $colorWidgetBackground; |
| 129 | /** |
| 130 | * @var string |
| 131 | */ |
| 132 | public $colorWidgetBorder; |
| 133 | public function __construct() |
| 134 | { |
| 135 | $this->colorMenuContrastText = $this->colorText; |
| 136 | $this->colorMenuContrastTextSelected = $this->colorMenuContrastText; |
| 137 | $this->colorMenuContrastBackground = $this->colorBackgroundContrast; |
| 138 | $this->colorWidgetExportedBackgroundBase = $this->colorBackgroundContrast; |
| 139 | $this->colorWidgetTitleText = $this->colorText; |
| 140 | $this->colorWidgetTitleBackground = $this->colorBackgroundContrast; |
| 141 | $this->colorWidgetBackground = $this->colorBackgroundContrast; |
| 142 | $this->colorWidgetBorder = $this->colorBackgroundTinyContrast; |
| 143 | } |
| 144 | /** |
| 145 | * @return ThemeStyles |
| 146 | */ |
| 147 | public static function get() |
| 148 | { |
| 149 | $result = new self(); |
| 150 | /** |
| 151 | * @ignore |
| 152 | */ |
| 153 | Piwik::postEvent('Theme.configureThemeVariables', [$result]); |
| 154 | return $result; |
| 155 | } |
| 156 | public function toLessCode() |
| 157 | { |
| 158 | $result = ''; |
| 159 | foreach (get_object_vars($this) as $name => $value) { |
| 160 | $varName = isset(self::$propertyNamesToLessVariableNames[$name]) ? self::$propertyNamesToLessVariableNames[$name] : $this->getGenericThemeVarName($name); |
| 161 | $result .= "@{$varName}: {$value};\n"; |
| 162 | } |
| 163 | return $result; |
| 164 | } |
| 165 | private function getGenericThemeVarName($propertyName) |
| 166 | { |
| 167 | return 'theme-' . $propertyName; |
| 168 | } |
| 169 | } |
| 170 |