Passed
Push — master ( e1cb1b...9a76f0 )
by John
15:33 queued 17s
created

DarkHighContrastTheme   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 2 1
A getCustomCss() 0 2 1
A getCSSVariables() 0 32 1
A getTitle() 0 2 1
A getMediaQuery() 0 2 1
A getId() 0 2 1
A getEnableLabel() 0 2 1
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\ITheme;
28
29
class DarkHighContrastTheme extends DarkTheme implements ITheme {
30
31
	public function getId(): string {
32
		return 'dark-highcontrast';
33
	}
34
35
	public function getMediaQuery(): string {
36
		return '(prefers-color-scheme: dark) and (prefers-contrast: more)';
37
	}
38
39
	public function getTitle(): string {
40
		return $this->l->t('Dark theme with high contrast mode');
41
	}
42
43
	public function getEnableLabel(): string {
44
		return $this->l->t('Enable dark high contrast mode');
45
	}
46
47
	public function getDescription(): string {
48
		return $this->l->t('Similar to the high contrast mode, but with dark colours.');
49
	}
50
51
	/**
52
	 * Try to keep this consistent with HighContrastTheme
53
	 */
54
	public function getCSSVariables(): array {
55
		$variables = parent::getCSSVariables();
56
		$colorMainText = '#ffffff';
57
		$colorMainBackground = '#000000';
58
		$colorBoxShadowRGB = join(',', $this->util->hexToRGB($colorMainText));
59
60
		$variables['--color-main-background'] = $colorMainBackground;
61
		$variables['--color-main-text'] = $colorMainText;
62
63
		$variables['--color-background-dark'] = $this->util->lighten($colorMainBackground, 30);
64
		$variables['--color-background-darker'] = $this->util->lighten($colorMainBackground, 30);
65
66
		$variables['--color-placeholder-light'] = $this->util->lighten($colorMainBackground, 30);
67
		$variables['--color-placeholder-dark'] = $this->util->lighten($colorMainBackground, 45);
68
69
		$variables['--color-text-maxcontrast'] = $colorMainText;
70
		$variables['--color-text-light'] = $colorMainText;
71
		$variables['--color-text-lighter'] = $colorMainText;
72
73
		// used for the icon loading animation
74
		$variables['--color-loading-light'] = '#000000';
75
		$variables['--color-loading-dark'] = '#dddddd';
76
77
78
		$variables['--color-box-shadow-rgb'] = $colorBoxShadowRGB;
79
		$variables['--color-box-shadow'] = $colorBoxShadowRGB;
80
81
82
		$variables['--color-border'] = $this->util->lighten($colorMainBackground, 50);
83
		$variables['--color-border-dark'] = $this->util->lighten($colorMainBackground, 50);
84
85
		return $variables;
86
	}
87
88
	public function getCustomCss(): string {
89
		return "
90
		[class^='icon-'], [class*=' icon-'],
91
			.action,
92
			#appmenu li a,
93
			.menutoggle {
94
				opacity: 1 !important;
95
			}
96
		";
97
	}
98
}
99