Skip to content

Commit a1ba0bb

Browse files
committed
feat(theming): add option for reduce animation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 6c362cb commit a1ba0bb

4 files changed

Lines changed: 67 additions & 0 deletions

File tree

apps/theming/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
'OCA\\Theming\\Themes\\DyslexiaFont' => $baseDir . '/../lib/Themes/DyslexiaFont.php',
4040
'OCA\\Theming\\Themes\\HighContrastTheme' => $baseDir . '/../lib/Themes/HighContrastTheme.php',
4141
'OCA\\Theming\\Themes\\LightTheme' => $baseDir . '/../lib/Themes/LightTheme.php',
42+
'OCA\\Theming\\Themes\\ReducedMotion' => $baseDir . '/../lib/Themes/ReducedMotion.php',
4243
'OCA\\Theming\\ThemingDefaults' => $baseDir . '/../lib/ThemingDefaults.php',
4344
'OCA\\Theming\\Util' => $baseDir . '/../lib/Util.php',
4445
);

apps/theming/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ComposerStaticInitTheming
5454
'OCA\\Theming\\Themes\\DyslexiaFont' => __DIR__ . '/..' . '/../lib/Themes/DyslexiaFont.php',
5555
'OCA\\Theming\\Themes\\HighContrastTheme' => __DIR__ . '/..' . '/../lib/Themes/HighContrastTheme.php',
5656
'OCA\\Theming\\Themes\\LightTheme' => __DIR__ . '/..' . '/../lib/Themes/LightTheme.php',
57+
'OCA\\Theming\\Themes\\ReducedMotion' => __DIR__ . '/..' . '/../lib/Themes/ReducedMotion.php',
5758
'OCA\\Theming\\ThemingDefaults' => __DIR__ . '/..' . '/../lib/ThemingDefaults.php',
5859
'OCA\\Theming\\Util' => __DIR__ . '/..' . '/../lib/Util.php',
5960
);

apps/theming/lib/Service/ThemesService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCA\Theming\Themes\DyslexiaFont;
1515
use OCA\Theming\Themes\HighContrastTheme;
1616
use OCA\Theming\Themes\LightTheme;
17+
use OCA\Theming\Themes\ReducedMotion;
1718
use OCP\IConfig;
1819
use OCP\IUser;
1920
use OCP\IUserSession;
@@ -33,6 +34,7 @@ public function __construct(
3334
HighContrastTheme $highContrastTheme,
3435
DarkHighContrastTheme $darkHighContrastTheme,
3536
DyslexiaFont $dyslexiaFont,
37+
ReducedMotion $motionSickness,
3638
) {
3739

3840
// Register themes
@@ -43,6 +45,7 @@ public function __construct(
4345
$highContrastTheme->getId() => $highContrastTheme,
4446
$darkHighContrastTheme->getId() => $darkHighContrastTheme,
4547
$dyslexiaFont->getId() => $dyslexiaFont,
48+
$motionSickness->getId() => $motionSickness,
4649
];
4750
}
4851

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
namespace OCA\Theming\Themes;
9+
10+
use OCA\Theming\ITheme;
11+
use OCP\IL10N;
12+
13+
class ReducedMotion implements ITheme {
14+
15+
public function __construct(
16+
private IL10N $l,
17+
) {
18+
}
19+
20+
public function getCustomCss(): string
21+
{
22+
return '';
23+
}
24+
25+
public function getMeta(): array
26+
{
27+
return [];
28+
}
29+
30+
public function getId(): string {
31+
return 'reduced-motion';
32+
}
33+
34+
public function getType(): int {
35+
return ITheme::TYPE_FONT;
36+
}
37+
38+
public function getTitle(): string {
39+
return $this->l->t('Reduced motion');
40+
}
41+
42+
public function getEnableLabel(): string {
43+
return $this->l->t('Motion sickness reduction');
44+
}
45+
46+
public function getDescription(): string {
47+
return $this->l->t('Prevents animations, such as scaling or panning large objects, that can trigger discomfort for those with vestibular motion disorders.');
48+
}
49+
50+
public function getCSSVariables(): array {
51+
$variables = [
52+
'--animation-quick' => '0',
53+
'--animation-slow' => '0',
54+
];
55+
56+
return $variables;
57+
}
58+
59+
public function getMediaQuery(): string {
60+
return '(prefers-reduced-motion: reduce)';
61+
}
62+
}

0 commit comments

Comments
 (0)