HighContrastTheme.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Theming\Themes;
  8. use OCA\Theming\ITheme;
  9. class HighContrastTheme extends DefaultTheme implements ITheme {
  10. public function getId(): string {
  11. return 'light-highcontrast';
  12. }
  13. public function getTitle(): string {
  14. return $this->l->t('High contrast mode');
  15. }
  16. public function getEnableLabel(): string {
  17. return $this->l->t('Enable high contrast mode');
  18. }
  19. public function getDescription(): string {
  20. return $this->l->t('A high contrast mode to ease your navigation. Visual quality will be reduced but clarity will be increased.');
  21. }
  22. public function getMediaQuery(): string {
  23. return '(prefers-contrast: more)';
  24. }
  25. /**
  26. * Keep this consistent with other HighContrast Themes
  27. */
  28. public function getCSSVariables(): array {
  29. $defaultVariables = parent::getCSSVariables();
  30. $colorMainText = '#000000';
  31. $colorMainBackground = '#ffffff';
  32. $colorMainBackgroundRGB = join(',', $this->util->hexToRGB($colorMainBackground));
  33. $colorError = '#D10000';
  34. $colorWarning = '#995900';
  35. $colorSuccess = '#207830';
  36. $colorInfo = '#006DA8';
  37. $primaryVariables = $this->generatePrimaryVariables($colorMainBackground, $colorMainText, true);
  38. return array_merge(
  39. $defaultVariables,
  40. $primaryVariables,
  41. [
  42. '--color-primary-element-text-dark' => $primaryVariables['--color-primary-element-text'],
  43. '--color-main-background' => $colorMainBackground,
  44. '--color-main-background-rgb' => $colorMainBackgroundRGB,
  45. '--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), 1)',
  46. '--color-main-text' => $colorMainText,
  47. '--color-background-dark' => $this->util->darken($colorMainBackground, 20),
  48. '--color-background-darker' => $this->util->darken($colorMainBackground, 20),
  49. '--color-main-background-blur' => $colorMainBackground,
  50. '--filter-background-blur' => 'none',
  51. '--color-placeholder-light' => $this->util->darken($colorMainBackground, 30),
  52. '--color-placeholder-dark' => $this->util->darken($colorMainBackground, 45),
  53. '--color-text-maxcontrast' => $colorMainText,
  54. '--color-text-maxcontrast-background-blur' => $colorMainText,
  55. '--color-text-light' => $colorMainText,
  56. '--color-text-lighter' => $colorMainText,
  57. '--color-error' => $colorError,
  58. '--color-error-rgb' => join(',', $this->util->hexToRGB($colorError)),
  59. '--color-error-hover' => $this->util->darken($colorError, 8),
  60. '--color-error-text' => $this->util->darken($colorError, 17),
  61. '--color-warning' => $colorWarning,
  62. '--color-warning-rgb' => join(',', $this->util->hexToRGB($colorWarning)),
  63. '--color-warning-hover' => $this->util->darken($colorWarning, 7),
  64. '--color-warning-text' => $this->util->darken($colorWarning, 13),
  65. '--color-info' => $colorInfo,
  66. '--color-info-rgb' => join(',', $this->util->hexToRGB($colorInfo)),
  67. '--color-info-hover' => $this->util->darken($colorInfo, 7),
  68. '--color-info-text' => $this->util->darken($colorInfo, 15),
  69. '--color-success' => $colorSuccess,
  70. '--color-success-rgb' => join(',', $this->util->hexToRGB($colorSuccess)),
  71. '--color-success-hover' => $this->util->darken($colorSuccess, 7),
  72. '--color-success-text' => $this->util->darken($colorSuccess, 14),
  73. '--color-favorite' => '#936B06',
  74. '--color-scrollbar' => 'auto',
  75. // used for the icon loading animation
  76. '--color-loading-light' => '#dddddd',
  77. '--color-loading-dark' => '#000000',
  78. '--color-box-shadow-rgb' => $colorMainText,
  79. '--color-box-shadow' => $colorMainText,
  80. '--color-border' => $this->util->darken($colorMainBackground, 50),
  81. '--color-border-dark' => $this->util->darken($colorMainBackground, 50),
  82. '--color-border-maxcontrast' => $this->util->darken($colorMainBackground, 56),
  83. ]
  84. );
  85. }
  86. public function getCustomCss(): string {
  87. return "
  88. [class^='icon-'], [class*=' icon-'],
  89. .action,
  90. #appmenu li a,
  91. .menutoggle {
  92. opacity: 1 !important;
  93. }
  94. #app-navigation {
  95. border-right: 1px solid var(--color-border);
  96. }
  97. ";
  98. }
  99. }