|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2022 Joas Schilling <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Joas Schilling <[email protected]> |
|
7
|
|
|
* @author John Molakvoæ <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
namespace OCA\Theming\Themes; |
|
26
|
|
|
|
|
27
|
|
|
use OCA\Theming\Util; |
|
28
|
|
|
|
|
29
|
|
|
trait CommonThemeTrait { |
|
30
|
|
|
public Util $util; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Generate primary-related variables |
|
34
|
|
|
* This is shared between multiple themes because colorMainBackground and colorMainText |
|
35
|
|
|
* will change in between. |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function generatePrimaryVariables(string $colorMainBackground, string $colorMainText): array { |
|
38
|
|
|
$colorPrimaryLight = $this->util->mix($this->primaryColor, $colorMainBackground, -80); |
|
39
|
|
|
$colorPrimaryElement = $this->util->elementColor($this->primaryColor); |
|
40
|
|
|
$colorPrimaryElementLight = $this->util->mix($colorPrimaryElement, $colorMainBackground, -80); |
|
41
|
|
|
|
|
42
|
|
|
// primary related colours |
|
43
|
|
|
return [ |
|
44
|
|
|
'--color-primary' => $this->primaryColor, |
|
45
|
|
|
'--color-primary-text' => $this->util->invertTextColor($this->primaryColor) ? '#000000' : '#ffffff', |
|
46
|
|
|
'--color-primary-hover' => $this->util->mix($this->primaryColor, $colorMainBackground, 60), |
|
47
|
|
|
'--color-primary-light' => $colorPrimaryLight, |
|
48
|
|
|
'--color-primary-light-text' => $this->primaryColor, |
|
49
|
|
|
'--color-primary-light-hover' => $this->util->mix($colorPrimaryLight, $colorMainText, 90), |
|
50
|
|
|
'--color-primary-text-dark' => $this->util->darken($this->util->invertTextColor($this->primaryColor) ? '#000000' : '#ffffff', 7), |
|
51
|
|
|
|
|
52
|
|
|
// used for buttons, inputs... |
|
53
|
|
|
'--color-primary-element' => $colorPrimaryElement, |
|
54
|
|
|
'--color-primary-element-text' => $this->util->invertTextColor($colorPrimaryElement) ? '#000000' : '#ffffff', |
|
55
|
|
|
'--color-primary-element-hover' => $this->util->mix($colorPrimaryElement, $colorMainBackground, 60), |
|
56
|
|
|
'--color-primary-element-light' => $colorPrimaryElementLight, |
|
57
|
|
|
'--color-primary-element-light-text' => $colorPrimaryElement, |
|
58
|
|
|
'--color-primary-element-light-hover' => $this->util->mix($colorPrimaryElementLight, $colorMainText, 90), |
|
59
|
|
|
'--color-primary-element-text-dark' => $this->util->darken($this->util->invertTextColor($colorPrimaryElement) ? '#000000' : '#ffffff', 7), |
|
60
|
|
|
|
|
61
|
|
|
// to use like this: background-image: var(--gradient-primary-background); |
|
62
|
|
|
'--gradient-primary-background' => 'linear-gradient(40deg, var(--color-primary) 0%, var(--color-primary-hover) 100%)', |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|