]> source.dussan.org Git - nextcloud-server.git/commitdiff
Font fixes and design update for theme picker
authorJohn Molakvoæ <skjnldsv@protonmail.com>
Wed, 20 Apr 2022 07:55:41 +0000 (09:55 +0200)
committerJohn Molakvoæ <skjnldsv@protonmail.com>
Thu, 21 Apr 2022 07:31:07 +0000 (09:31 +0200)
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
20 files changed:
apps/settings/src/components/PersonalInfo/ProfileSection/ProfilePreviewCard.vue
apps/theming/appinfo/routes.php
apps/theming/fonts/OpenDyslexic-Bold.otf [new file with mode: 0644]
apps/theming/fonts/OpenDyslexic-Bold.ttf [new file with mode: 0644]
apps/theming/fonts/OpenDyslexic-Bold.woff [new file with mode: 0644]
apps/theming/fonts/OpenDyslexic-Regular.otf [new file with mode: 0644]
apps/theming/fonts/OpenDyslexic-Regular.ttf [new file with mode: 0644]
apps/theming/fonts/OpenDyslexic-Regular.woff [new file with mode: 0644]
apps/theming/img/dark-highcontrast.jpg [new file with mode: 0644]
apps/theming/img/highcontrast.jpg
apps/theming/img/opendyslexic.jpg
apps/theming/lib/Controller/ThemingController.php
apps/theming/lib/ITheme.php
apps/theming/lib/Service/ThemeInjectionService.php
apps/theming/lib/Themes/DarkHighContrastTheme.php
apps/theming/lib/Themes/DefaultTheme.php
apps/theming/lib/Themes/DyslexiaFont.php
apps/theming/lib/Themes/HighContrastTheme.php
apps/theming/src/UserThemes.vue
apps/theming/src/components/ItemPreview.vue

index 4cc0d50346a9d34ca19843886a6f4ef416f8a045..ef12d511fb94d4d3c15ad832592187db4cd4429b 100644 (file)
@@ -161,6 +161,8 @@ export default {
        &__header {
                height: 70px;
                border-radius: var(--border-radius-large) var(--border-radius-large) 0 0;
+               background-color: var(--color-primary);
+               background-image: linear-gradient(40deg, var(--color-primary) 0%, var(--color-primary-element-light) 100%);
 
                span {
                        bottom: 0;
index c9a99a409ef09a55e7a4d297fc84b050fdbdee35..fa8dde9078696a67c793728f2a71337b51646221 100644 (file)
@@ -45,7 +45,7 @@ return [
                        'verb' => 'POST'
                ],
                [
-                       'name' => 'Theming#getThemeVariables',
+                       'name' => 'Theming#getThemeStylesheet',
                        'url' => '/theme/{themeId}.css',
                        'verb' => 'GET',
                ],
diff --git a/apps/theming/fonts/OpenDyslexic-Bold.otf b/apps/theming/fonts/OpenDyslexic-Bold.otf
new file mode 100644 (file)
index 0000000..4c492e2
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Bold.otf differ
diff --git a/apps/theming/fonts/OpenDyslexic-Bold.ttf b/apps/theming/fonts/OpenDyslexic-Bold.ttf
new file mode 100644 (file)
index 0000000..7c97eb4
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Bold.ttf differ
diff --git a/apps/theming/fonts/OpenDyslexic-Bold.woff b/apps/theming/fonts/OpenDyslexic-Bold.woff
new file mode 100644 (file)
index 0000000..755476f
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Bold.woff differ
diff --git a/apps/theming/fonts/OpenDyslexic-Regular.otf b/apps/theming/fonts/OpenDyslexic-Regular.otf
new file mode 100644 (file)
index 0000000..1226d2a
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Regular.otf differ
diff --git a/apps/theming/fonts/OpenDyslexic-Regular.ttf b/apps/theming/fonts/OpenDyslexic-Regular.ttf
new file mode 100644 (file)
index 0000000..e784934
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Regular.ttf differ
diff --git a/apps/theming/fonts/OpenDyslexic-Regular.woff b/apps/theming/fonts/OpenDyslexic-Regular.woff
new file mode 100644 (file)
index 0000000..fdf9e37
Binary files /dev/null and b/apps/theming/fonts/OpenDyslexic-Regular.woff differ
diff --git a/apps/theming/img/dark-highcontrast.jpg b/apps/theming/img/dark-highcontrast.jpg
new file mode 100644 (file)
index 0000000..5fce8ef
Binary files /dev/null and b/apps/theming/img/dark-highcontrast.jpg differ
index 8c55a7358b98b1d108dc6fc8be408a93818297cf..e9087e898eed08475faa95646ba02ca26dc4bc35 100644 (file)
Binary files a/apps/theming/img/highcontrast.jpg and b/apps/theming/img/highcontrast.jpg differ
index db8e60f36588e2949eaa99f9ef131a7f2ecbe2fc..f56ea33e6c420522adee293c9293dec0dbfd38a1 100644 (file)
Binary files a/apps/theming/img/opendyslexic.jpg and b/apps/theming/img/opendyslexic.jpg differ
index 1cd269f9bff2ed5f5d9c9b7f854bfa7f9d8c49d4..ff30e27f7215bafbe9611f197ab6c28ffaa5a51a 100644 (file)
@@ -55,6 +55,7 @@ use OCP\IL10N;
 use OCP\IRequest;
 use OCP\ITempManager;
 use OCP\IURLGenerator;
+use ScssPhp\ScssPhp\Compiler;
 
 /**
  * Class ThemingController
@@ -309,13 +310,14 @@ class ThemingController extends Controller {
         *
         * @return FileDisplayResponse|NotFoundResponse
         */
-       public function getThemeVariables(string $themeId, bool $plain = false) {
+       public function getThemeStylesheet(string $themeId, bool $plain = false, bool $withCustomCss = false) {
                $themes = $this->themesService->getThemes();
                if (!in_array($themeId, array_keys($themes))) {
                        return new NotFoundResponse();
                }
 
                $theme = $themes[$themeId];
+               $customCss  = $theme->getCustomCss();
 
                // Generate variables
                $variables = '';
@@ -325,10 +327,12 @@ class ThemingController extends Controller {
 
                // If plain is set, the browser decides of the css priority
                if ($plain) {
-                       $css = ":root { $variables }";
+                       $css = ":root { $variables } " . $customCss;
                } else { 
                        // If not set, we'll rely on the body class
-                       $css = "body[data-theme-$themeId] { $variables }";
+                       $compiler = new Compiler();
+                       $compiledCss = $compiler->compileString("body[data-theme-$themeId] { $variables $customCss }");
+                       $css = $compiledCss->getCss();;
                }
 
                try {
index 20508fac4e8a37d11f142ff3d525b9ceae39e6ff..a5c9cdf26a6231c762abc2726b32131a81105310 100644 (file)
@@ -86,4 +86,14 @@ interface ITheme {
         * @since 25.0.0
         */
        public function getCSSVariables(): array;
+
+       /**
+        * Return the custom css necessary for that app
+        * ⚠️ Warning, should be used slightly.
+        * Theoretically, editing the variables should be enough.
+        *
+        * @return string
+        * @since 25.0.0
+        */
+       public function getCustomCss(): string;
 }
index e00839c21c5611fd4dbaa613a94dd90bf386f944..81edc19bc4b73f7b1930d31b0ac2eb88e8ac067d 100644 (file)
@@ -75,7 +75,7 @@ class ThemeInjectionService {
         * @param string $media media query to use in the <link> element
         */
        private function addThemeHeader(string $themeId, bool $plain = true, string $media = null) {
-               $linkToCSS = $this->urlGenerator->linkToRoute('theming.Theming.getThemeVariables', [
+               $linkToCSS = $this->urlGenerator->linkToRoute('theming.Theming.getThemeStylesheet', [
                        'themeId' => $themeId,
                        'plain' => $plain,
                ]);
index 8d0b134c75f22d9fcee1a4daeceba417a7e35fda..62b7d4f6358ba772346e7ce753b27e1cfe3b98e0 100644 (file)
@@ -26,7 +26,7 @@ namespace OCA\Theming\Themes;
 
 use OCA\Theming\ITheme;
 
-class DarkHighContrastTheme extends HighContrastTheme implements ITheme {
+class DarkHighContrastTheme extends DarkTheme implements ITheme {
 
        public function getId(): string {
                return 'dark-highcontrast';
@@ -48,12 +48,51 @@ class DarkHighContrastTheme extends HighContrastTheme implements ITheme {
                return $this->l->t('Similar to the high contrast mode, but with dark colours.');
        }
 
+       /**
+        * Try to keep this consistent with HighContrastTheme
+        */
        public function getCSSVariables(): array {
                $variables = parent::getCSSVariables();
+               $colorMainText = '#ffffff';
+               $colorMainBackground = '#000000';
+               $colorBoxShadowRGB = join(',', $this->util->hexToRGB($colorMainText));
 
-               // FIXME …
-               $variables = $variables;
+               $variables['--color-main-background'] = $colorMainBackground;
+               $variables['--color-main-text'] = $colorMainText;
+
+               $variables['--color-background-dark'] = $this->util->lighten($colorMainBackground, 30);
+               $variables['--color-background-darker'] = $this->util->lighten($colorMainBackground, 30);
+
+               $variables['--color-placeholder-light'] = $this->util->lighten($colorMainBackground, 30);
+               $variables['--color-placeholder-dark'] = $this->util->lighten($colorMainBackground, 45);
+
+               $variables['--color-text-maxcontrast'] = $colorMainText;
+               $variables['--color-text-light'] = $colorMainText;
+               $variables['--color-text-lighter'] = $colorMainText;
+
+               // used for the icon loading animation
+               $variables['--color-loading-light'] = '#000000';
+               $variables['--color-loading-dark'] = '#dddddd';
+
+
+               $variables['--color-box-shadow-rgb'] = $colorBoxShadowRGB;
+               $variables['--color-box-shadow'] = $colorBoxShadowRGB;
+
+
+               $variables['--color-border'] = $this->util->lighten($colorMainBackground, 50);
+               $variables['--color-border-dark'] = $this->util->lighten($colorMainBackground, 50);
 
                return $variables;
        }
+
+       public function getCustomCss(): string {
+               return "
+               [class^='icon-'], [class*=' icon-'],
+                       .action,
+                       #appmenu li a,
+                       .menutoggle {
+                               opacity: 1 !important;
+                       }
+               ";
+       }
 }
index 3b194a36546c86b71061bd41e56d4aa9caa516b1..7561bb16ecdc61fbb1d377eb6f7bac2d24f036f0 100644 (file)
@@ -35,7 +35,6 @@ use OCP\IURLGenerator;
 class DefaultTheme implements ITheme {
        public Util $util;
        public ThemingDefaults $themingDefaults;
-       public IURLGenerator $urlGenerator;
        public ImageManager $imageManager;
        public IConfig $config;
        public IL10N $l;
@@ -196,4 +195,8 @@ class DefaultTheme implements ITheme {
 
                return $variables;
        }
+
+       public function getCustomCss(): string {
+               return '';
+       }
 }
index 460147b9fa3e4349c02d8c92f0bdf7f1e3bf0702..50284d33b9ddb519ee5e1fd022cc7d17edb3e664 100644 (file)
@@ -58,18 +58,27 @@ class DyslexiaFont extends DefaultTheme implements ITheme {
 
                return $variables;
        }
-}
 
-// @font-face {
-//     font-family: 'OpenDyslexic';
-//     font-style: normal;
-//     font-weight: 400;
-//     src: url('../fonts/OpenDyslexic-Regular.woff') format('woff');
-// }
+       public function getCustomCss(): string {
+               return "
+                       @font-face {
+                               font-family: 'OpenDyslexic';
+                               font-style: normal;
+                               font-weight: 400;
+                               src: url('../fonts/OpenDyslexic-Regular.woff') format('woff'),
+                                        url('../fonts/OpenDyslexic-Regular.otf') format('opentype'),
+                                        url('../fonts/OpenDyslexic-Regular.ttf') format('truetype');
+                       }
+                       
+                       @font-face {
+                               font-family: 'OpenDyslexic';
+                               font-style: normal;
+                               font-weight: 700;
+                               src: url('../fonts/OpenDyslexic-Bold.woff') format('woff'),
+                                        url('../fonts/OpenDyslexic-Bold.otf') format('opentype'),
+                                        url('../fonts/OpenDyslexic-Bold.ttf') format('truetype');
+                       }
+               ";
+       }
+}
 
-// @font-face {
-//     font-family: 'OpenDyslexic';
-//     font-style: normal;
-//     font-weight: 700;
-//     src: url('../fonts/OpenDyslexic-Bold.woff') format('woff');
-// }
index 67276e4ef00c200424b0e6900d51af356673c07f..77239f2076c24b3dcd1e66961f7cfd68d8864519 100644 (file)
@@ -50,10 +50,42 @@ class HighContrastTheme extends DefaultTheme implements ITheme {
 
        public function getCSSVariables(): array {
                $variables = parent::getCSSVariables();
+               $colorMainText = '#000000';
+               $colorMainBackground = '#ffffff';
 
-               // FIXME …
-               $variables = $variables;
+               $variables['--color-main-background'] = $colorMainBackground;
+               $variables['--color-main-text'] = $colorMainText;
+
+               $variables['--color-background-dark'] = $this->util->darken($colorMainBackground, 30);
+               $variables['--color-background-darker'] = $this->util->darken($colorMainBackground, 30);
+
+               $variables['--color-placeholder-light'] = $this->util->darken($colorMainBackground, 30);
+               $variables['--color-placeholder-dark'] = $this->util->darken($colorMainBackground, 45);
+
+               $variables['--color-text-maxcontrast'] = 'var(--color-main-text)';
+               $variables['--color-text-light'] = 'var(--color-main-text)';
+               $variables['--color-text-lighter'] = 'var(--color-main-text)';
+
+               // used for the icon loading animation
+               $variables['--color-loading-light'] = '#dddddd';
+               $variables['--color-loading-dark'] = '#000000';
+
+               $variables['--color-box-shadow'] = 'var(--color-main-text)';
+
+               $variables['--color-border'] = $this->util->darken($colorMainBackground, 50);
+               $variables['--color-border-dark'] = $this->util->darken($colorMainBackground, 50);
 
                return $variables;
        }
+
+       public function getCustomCss(): string {
+               return "
+                       [class^='icon-'], [class*=' icon-'],
+                       .action,
+                       #appmenu li a,
+                       .menutoggle {
+                               opacity: 1 !important;
+                       }
+               ";
+       }
 }
index 78115021412d99c1d0492f82ec8f52a79a468f00..1fd6cb208662d30cf931fae573d21b0a1e6d62a0 100644 (file)
@@ -1,5 +1,5 @@
 <template>
-       <SettingsSection class="theming" :title="t('themes', 'Appaerance and accessibility')">
+       <SettingsSection class="theming" :title="t('themes', 'Appearance and accessibility')">
                <p v-html="description" />
                <p v-html="descriptionDetail" />
 
@@ -166,9 +166,20 @@ export default {
        }
 
        &__preview-list {
+               --gap: 30px;
+
+               display: grid;
+               margin-top: var(--gap);
+               column-gap: var(--gap);
+               row-gap: var(--gap);
+               grid-template-columns: 1fr 1fr;
+       }
+}
+
+@media (max-width: 1440px) {
+       .theming__preview-list {
                display: flex;
                flex-direction: column;
-               max-width: 800px;
        }
 }
 
index 997d66a037edaccd5e472060f8f0eece6850ccf6..0ed7dfc7858e37d8e5a6a34041096db01c09a30e 100644 (file)
@@ -75,13 +75,15 @@ export default {
 }
 </script>
 <style lang="scss" scoped>
+// We make previews on 16/10 screens
+$ratio: 16;
 
 .theming__preview {
+       --ratio: 16;
        position: relative;
        display: flex;
        justify-content: flex-start;
-       height: 140px;
-       margin-top: 3em;
+       max-width: 800px;
 
        &,
        * {
@@ -89,9 +91,10 @@ export default {
        }
 
        &-image {
-               flex-basis: 200px;
+               flex-basis: calc(16px * var(--ratio));
                flex-shrink: 0;
-               margin-right: 30px;
+               height: calc(10px * var(--ratio));
+               margin-right: var(--gap);
                border-radius: var(--border-radius);
                background-repeat: no-repeat;
                background-position: top left;
@@ -108,12 +111,12 @@ export default {
        }
 }
 
-@media (max-width: (1024 / 2)) {
+@media (max-width: (1024px / 1.5)) {
        .theming__preview {
-               display: unset;
+               flex-direction: column;
 
                &-image {
-                       height: 150px;
+                       margin: 0;
                }
        }
 }