1
0

DarkHighContrastTheme.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 DarkHighContrastTheme extends DarkTheme implements ITheme {
  10. public function getId(): string {
  11. return 'dark-highcontrast';
  12. }
  13. public function getTitle(): string {
  14. return $this->l->t('Dark theme with high contrast mode');
  15. }
  16. public function getEnableLabel(): string {
  17. return $this->l->t('Enable dark high contrast mode');
  18. }
  19. public function getDescription(): string {
  20. return $this->l->t('Similar to the high contrast mode, but with dark colours.');
  21. }
  22. public function getMediaQuery(): string {
  23. return '(prefers-color-scheme: dark) and (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 = '#ffffff';
  31. $colorMainBackground = '#000000';
  32. $colorMainBackgroundRGB = join(',', $this->util->hexToRGB($colorMainBackground));
  33. $colorError = '#ff5252';
  34. $colorWarning = '#ffcc00';
  35. $colorSuccess = '#42a942';
  36. $colorInfo = '#38c0ff';
  37. return array_merge(
  38. $defaultVariables,
  39. $this->generatePrimaryVariables($colorMainBackground, $colorMainText, true),
  40. [
  41. '--color-main-background' => $colorMainBackground,
  42. '--color-main-background-rgb' => $colorMainBackgroundRGB,
  43. '--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), 1)',
  44. '--color-main-text' => $colorMainText,
  45. '--color-background-dark' => $this->util->lighten($colorMainBackground, 25),
  46. '--color-background-darker' => $this->util->lighten($colorMainBackground, 25),
  47. '--color-main-background-blur' => $colorMainBackground,
  48. '--filter-background-blur' => 'none',
  49. '--color-placeholder-light' => $this->util->lighten($colorMainBackground, 30),
  50. '--color-placeholder-dark' => $this->util->lighten($colorMainBackground, 45),
  51. '--color-text-maxcontrast' => $colorMainText,
  52. '--color-text-maxcontrast-background-blur' => $colorMainText,
  53. '--color-text-light' => $colorMainText,
  54. '--color-text-lighter' => $colorMainText,
  55. '--color-error' => $colorError,
  56. '--color-error-rgb' => join(',', $this->util->hexToRGB($colorError)),
  57. '--color-error-hover' => $this->util->lighten($colorError, 10),
  58. '--color-error-text' => $this->util->lighten($colorError, 25),
  59. '--color-warning' => $colorWarning,
  60. '--color-warning-rgb' => join(',', $this->util->hexToRGB($colorWarning)),
  61. '--color-warning-hover' => $this->util->lighten($colorWarning, 10),
  62. '--color-warning-text' => $this->util->lighten($colorWarning, 10),
  63. '--color-success' => $colorSuccess,
  64. '--color-success-rgb' => join(',', $this->util->hexToRGB($colorSuccess)),
  65. '--color-success-hover' => $this->util->lighten($colorSuccess, 10),
  66. '--color-success-text' => $this->util->lighten($colorSuccess, 35),
  67. '--color-info' => $colorInfo,
  68. '--color-info-rgb' => join(',', $this->util->hexToRGB($colorInfo)),
  69. '--color-info-hover' => $this->util->lighten($colorInfo, 10),
  70. '--color-info-text' => $this->util->lighten($colorInfo, 20),
  71. '--color-scrollbar' => 'auto',
  72. // used for the icon loading animation
  73. '--color-loading-light' => '#000000',
  74. '--color-loading-dark' => '#dddddd',
  75. '--color-box-shadow-rgb' => $colorMainText,
  76. '--color-box-shadow' => $colorMainText,
  77. '--color-border' => $this->util->lighten($colorMainBackground, 50),
  78. '--color-border-dark' => $this->util->lighten($colorMainBackground, 50),
  79. '--color-border-maxcontrast' => $this->util->lighten($colorMainBackground, 55),
  80. ]
  81. );
  82. }
  83. public function getCustomCss(): string {
  84. return "
  85. [class^='icon-'], [class*=' icon-'],
  86. .action,
  87. #appmenu li a,
  88. .menutoggle {
  89. opacity: 1 !important;
  90. }
  91. #app-navigation {
  92. border-right: 1px solid var(--color-border);
  93. }
  94. div.crumb {
  95. filter: brightness(150%);
  96. }
  97. ";
  98. }
  99. }