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