mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #32195 from nextcloud/feat/system-theme
This commit is contained in:
commit
9a832df62f
9 changed files with 97 additions and 6 deletions
13
apps/theming/img/default-source.svg
Normal file
13
apps/theming/img/default-source.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<svg width="800" height="500" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Use this file to generate the default.jpg theme preview -->
|
||||
|
||||
<!-- Half rectangle light mask -->
|
||||
<defs><mask id="a"><path d="M0 0h800L0 500Z" fill="#fff"/></mask></defs>
|
||||
<!-- Dark and light images link -->
|
||||
<image width="800" height="500" xlink:href="dark.jpg"/>
|
||||
<image width="800" height="500" xlink:href="light.jpg" mask="url(#a)" fill="#fff"/>
|
||||
<!-- White opacity layer -->
|
||||
<path fill="#fff" opacity=".35" d="M0 0h800v500H0z"/>
|
||||
<!-- Moon/sun icon -->
|
||||
<path d="M358.82 162.36a58 58 0 0 0-26.63 48.81c0 20.6 10.74 38.6 26.9 48.81A48.85 48.85 0 0 1 310 211.17a48.82 48.81 0 0 1 48.82-48.81m102.69 13.3 12.7 12.7L336 326.55l-12.7-12.7 138.2-138.18m-54.85 21.57-13.14-8.26-12.78 8.88 3.73-15.1-12.34-9.4 15.53-1.06 5.15-14.65 5.95 14.47 15.35.27-11.98 10.02 4.53 14.83m-29.3 32.04-10.29-6.48-9.94 6.92 3.02-11.72-9.68-7.36 12.07-.8 4-11.45 4.53 11.27 12.07.27-9.32 7.72 3.55 11.63m83.52 35.14a48.82 48.81 0 0 1-48.82 48.82 48.7 48.7 0 0 1-28.93-9.5l68.25-68.25a48.7 48.7 0 0 1 9.5 28.93m-39.06 58.4 24.59-10.2-2.13 29.73-22.46-19.53m38.44-23.96 10.2-24.59L490 296.82l-29.73 2.04m10.2-44.02-10.11-24.68L490 232.3l-19.53 22.55m-92.75 57.78 24.59 10.2-22.46 19.44z" stroke="#000"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 382 KiB After Width: | Height: | Size: 56 KiB |
BIN
apps/theming/img/light.jpg
Normal file
BIN
apps/theming/img/light.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 382 KiB |
|
|
@ -29,6 +29,7 @@ use OCA\Theming\Themes\DarkTheme;
|
|||
use OCA\Theming\Themes\DefaultTheme;
|
||||
use OCA\Theming\Themes\DyslexiaFont;
|
||||
use OCA\Theming\Themes\HighContrastTheme;
|
||||
use OCA\Theming\Themes\LightTheme;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
|
|
@ -43,6 +44,7 @@ class ThemesService {
|
|||
public function __construct(IUserSession $userSession,
|
||||
IConfig $config,
|
||||
DefaultTheme $defaultTheme,
|
||||
LightTheme $lightTheme,
|
||||
DarkTheme $darkTheme,
|
||||
HighContrastTheme $highContrastTheme,
|
||||
DarkHighContrastTheme $darkHighContrastTheme,
|
||||
|
|
@ -53,6 +55,7 @@ class ThemesService {
|
|||
// Register themes
|
||||
$this->themesProviders = [
|
||||
$defaultTheme->getId() => $defaultTheme,
|
||||
$lightTheme->getId() => $lightTheme,
|
||||
$darkTheme->getId() => $darkTheme,
|
||||
$highContrastTheme->getId() => $highContrastTheme,
|
||||
$darkHighContrastTheme->getId() => $darkHighContrastTheme,
|
||||
|
|
|
|||
|
|
@ -67,15 +67,15 @@ class DefaultTheme implements ITheme {
|
|||
}
|
||||
|
||||
public function getTitle(): string {
|
||||
return $this->l->t('Light theme');
|
||||
return $this->l->t('System default theme');
|
||||
}
|
||||
|
||||
public function getEnableLabel(): string {
|
||||
return $this->l->t('Enable the default light theme');
|
||||
return $this->l->t('Enable the system default');
|
||||
}
|
||||
|
||||
public function getDescription(): string {
|
||||
return $this->l->t('The default light appearance.');
|
||||
return $this->l->t('Using the default system appearance.');
|
||||
}
|
||||
|
||||
public function getMediaQuery(): string {
|
||||
|
|
|
|||
61
apps/theming/lib/Themes/LightTheme.php
Normal file
61
apps/theming/lib/Themes/LightTheme.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @author Joas Schilling <coding@schilljs.com>
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCA\Theming\Themes;
|
||||
|
||||
use OCA\Theming\ImageManager;
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCA\Theming\Util;
|
||||
use OCA\Theming\ITheme;
|
||||
use OCA\Theming\Themes\DefaultTheme;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class LightTheme extends DefaultTheme implements ITheme {
|
||||
|
||||
public function getId(): string {
|
||||
return 'light';
|
||||
}
|
||||
|
||||
public function getType(): int {
|
||||
return ITheme::TYPE_THEME;
|
||||
}
|
||||
|
||||
public function getTitle(): string {
|
||||
return $this->l->t('Light theme');
|
||||
}
|
||||
|
||||
public function getEnableLabel(): string {
|
||||
return $this->l->t('Enable the default light theme');
|
||||
}
|
||||
|
||||
public function getDescription(): string {
|
||||
return $this->l->t('The default light appearance.');
|
||||
}
|
||||
|
||||
public function getMediaQuery(): string {
|
||||
return '(prefers-color-scheme: light)';
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ use OCA\Theming\Themes\DefaultTheme;
|
|||
use OCA\Theming\Themes\DyslexiaFont;
|
||||
use OCA\Theming\Themes\HighContrastTheme;
|
||||
use OCA\Theming\Service\ThemesService;
|
||||
use OCA\Theming\Themes\LightTheme;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCS\OCSBadRequestException;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -63,6 +64,7 @@ class UserThemeControllerTest extends TestCase {
|
|||
|
||||
$this->themes = [
|
||||
'default' => $this->createMock(DefaultTheme::class),
|
||||
'light' => $this->createMock(LightTheme::class),
|
||||
'dark' => $this->createMock(DarkTheme::class),
|
||||
'highcontrast' => $this->createMock(HighContrastTheme::class),
|
||||
'dark-highcontrast' => $this->createMock(DarkHighContrastTheme::class),
|
||||
|
|
@ -91,6 +93,7 @@ class UserThemeControllerTest extends TestCase {
|
|||
public function dataTestThemes() {
|
||||
return [
|
||||
['default'],
|
||||
['light'],
|
||||
['dark'],
|
||||
['highcontrast'],
|
||||
['dark-highcontrast'],
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use OCA\Theming\Themes\DefaultTheme;
|
|||
use OCA\Theming\Themes\DyslexiaFont;
|
||||
use OCA\Theming\Themes\HighContrastTheme;
|
||||
use OCA\Theming\Service\ThemesService;
|
||||
use OCA\Theming\Themes\LightTheme;
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCA\Theming\Util;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
|
@ -81,6 +82,7 @@ class ThemesServiceTest extends TestCase {
|
|||
public function testGetThemes() {
|
||||
$expected = [
|
||||
'default',
|
||||
'light',
|
||||
'dark',
|
||||
'highcontrast',
|
||||
'dark-highcontrast',
|
||||
|
|
@ -92,6 +94,7 @@ class ThemesServiceTest extends TestCase {
|
|||
|
||||
public function dataTestEnableTheme() {
|
||||
return [
|
||||
['default', [], ['default']],
|
||||
['dark', [], ['dark']],
|
||||
['dark', ['dark'], ['dark']],
|
||||
['opendyslexic', ['dark'], ['dark', 'opendyslexic']],
|
||||
|
|
@ -207,6 +210,14 @@ class ThemesServiceTest extends TestCase {
|
|||
$this->config,
|
||||
$l10n,
|
||||
),
|
||||
'light' => new LightTheme(
|
||||
$util,
|
||||
$this->themingDefaults,
|
||||
$urlGenerator,
|
||||
$imageManager,
|
||||
$this->config,
|
||||
$l10n,
|
||||
),
|
||||
'dark' => new DarkTheme(
|
||||
$util,
|
||||
$this->themingDefaults,
|
||||
|
|
|
|||
|
|
@ -97,15 +97,15 @@ class DefaultThemeTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetTitle() {
|
||||
$this->assertEquals('Light theme', $this->defaultTheme->getTitle());
|
||||
$this->assertEquals('System default theme', $this->defaultTheme->getTitle());
|
||||
}
|
||||
|
||||
public function testGetEnableLabel() {
|
||||
$this->assertEquals('Enable the default light theme', $this->defaultTheme->getEnableLabel());
|
||||
$this->assertEquals('Enable the system default', $this->defaultTheme->getEnableLabel());
|
||||
}
|
||||
|
||||
public function testGetDescription() {
|
||||
$this->assertEquals('The default light appearance.', $this->defaultTheme->getDescription());
|
||||
$this->assertEquals('Using the default system appearance.', $this->defaultTheme->getDescription());
|
||||
}
|
||||
|
||||
public function testGetMediaQuery() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue