HighContrastTheme.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author John Molakvoæ <skjnldsv@protonmail.com>
  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. use OCA\Theming\ITheme;
  27. class HighContrastTheme extends DefaultTheme implements ITheme {
  28. public function getId(): string {
  29. return 'light-highcontrast';
  30. }
  31. public function getTitle(): string {
  32. return $this->l->t('High contrast mode');
  33. }
  34. public function getEnableLabel(): string {
  35. return $this->l->t('Enable high contrast mode');
  36. }
  37. public function getDescription(): string {
  38. return $this->l->t('A high contrast mode to ease your navigation. Visual quality will be reduced but clarity will be increased.');
  39. }
  40. public function getMediaQuery(): string {
  41. return '(prefers-contrast: more)';
  42. }
  43. /**
  44. * Keep this consistent with other HighContrast Themes
  45. */
  46. public function getCSSVariables(): array {
  47. $defaultVariables = parent::getCSSVariables();
  48. $colorMainText = '#000000';
  49. $colorMainBackground = '#ffffff';
  50. $colorMainBackgroundRGB = join(',', $this->util->hexToRGB($colorMainBackground));
  51. $colorError = '#D10000';
  52. $colorWarning = '#995900';
  53. $colorSuccess = '#207830';
  54. $colorInfo = '#006DA8';
  55. $primaryVariables = $this->generatePrimaryVariables($colorMainBackground, $colorMainText, true);
  56. return array_merge(
  57. $defaultVariables,
  58. $primaryVariables,
  59. [
  60. '--color-primary-element-text-dark' => $primaryVariables['--color-primary-element-text'],
  61. '--color-main-background' => $colorMainBackground,
  62. '--color-main-background-rgb' => $colorMainBackgroundRGB,
  63. '--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), 1)',
  64. '--color-main-text' => $colorMainText,
  65. '--color-background-dark' => $this->util->darken($colorMainBackground, 20),
  66. '--color-background-darker' => $this->util->darken($colorMainBackground, 20),
  67. '--color-main-background-blur' => $colorMainBackground,
  68. '--filter-background-blur' => 'none',
  69. '--color-placeholder-light' => $this->util->darken($colorMainBackground, 30),
  70. '--color-placeholder-dark' => $this->util->darken($colorMainBackground, 45),
  71. '--color-text-maxcontrast' => $colorMainText,
  72. '--color-text-maxcontrast-background-blur' => $colorMainText,
  73. '--color-text-light' => $colorMainText,
  74. '--color-text-lighter' => $colorMainText,
  75. '--color-error' => $colorError,
  76. '--color-error-rgb' => join(',', $this->util->hexToRGB($colorError)),
  77. '--color-error-hover' => $this->util->darken($colorError, 8),
  78. '--color-error-text' => $this->util->darken($colorError, 17),
  79. '--color-warning' => $colorWarning,
  80. '--color-warning-rgb' => join(',', $this->util->hexToRGB($colorWarning)),
  81. '--color-warning-hover' => $this->util->darken($colorWarning, 7),
  82. '--color-warning-text' => $this->util->darken($colorWarning, 13),
  83. '--color-info' => $colorInfo,
  84. '--color-info-rgb' => join(',', $this->util->hexToRGB($colorInfo)),
  85. '--color-info-hover' => $this->util->darken($colorInfo, 7),
  86. '--color-info-text' => $this->util->darken($colorInfo, 15),
  87. '--color-success' => $colorSuccess,
  88. '--color-success-rgb' => join(',', $this->util->hexToRGB($colorSuccess)),
  89. '--color-success-hover' => $this->util->darken($colorSuccess, 7),
  90. '--color-success-text' => $this->util->darken($colorSuccess, 14),
  91. '--color-favorite' => '#936B06',
  92. '--color-scrollbar' => $this->util->darken($colorMainBackground, 25),
  93. // used for the icon loading animation
  94. '--color-loading-light' => '#dddddd',
  95. '--color-loading-dark' => '#000000',
  96. '--color-box-shadow-rgb' => $colorMainText,
  97. '--color-box-shadow' => $colorMainText,
  98. '--color-border' => $this->util->darken($colorMainBackground, 50),
  99. '--color-border-dark' => $this->util->darken($colorMainBackground, 50),
  100. '--color-border-maxcontrast' => $this->util->darken($colorMainBackground, 56),
  101. ]
  102. );
  103. }
  104. public function getCustomCss(): string {
  105. return "
  106. [class^='icon-'], [class*=' icon-'],
  107. .action,
  108. #appmenu li a,
  109. .menutoggle {
  110. opacity: 1 !important;
  111. }
  112. #app-navigation {
  113. border-right: 1px solid var(--color-border);
  114. }
  115. ";
  116. }
  117. }