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

HighContrastTheme   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

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

7 Methods

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