]> git.mxchange.org Git - friendica.git/commitdiff
[frio] Add scheme accent feature
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 20 Aug 2020 02:58:00 +0000 (22:58 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 20 Aug 2020 03:12:48 +0000 (23:12 -0400)
- Add new accented scheme light
- Add first accent blue

view/theme/frio/config.php
view/theme/frio/php/default.php
view/theme/frio/php/scheme.php
view/theme/frio/scheme/light.php [new file with mode: 0644]
view/theme/frio/style.php
view/theme/frio/templates/theme_settings.tpl
view/theme/frio/theme.php

index 64809f399bf596f69b62435247528368693e2a30..b93848cfe0c2cdc35211f07e223a0a273f58c948 100644 (file)
@@ -34,6 +34,7 @@ function theme_post(App $a)
        if (isset($_POST['frio-settings-submit'])) {
                foreach ([
                        'scheme',
+                       'scheme_accent',
                        'nav_bg',
                        'nav_icon_color',
                        'link_color',
@@ -63,6 +64,7 @@ function theme_admin_post(App $a)
        if (isset($_POST['frio-settings-submit'])) {
                foreach ([
                        'scheme',
+                       'scheme_accent',
                        'nav_bg',
                        'nav_icon_color',
                        'link_color',
@@ -92,6 +94,7 @@ function theme_content(App $a)
        $node_scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'scheme'));
 
        $arr['scheme']           = DI::pConfig()->get(local_user(), 'frio', 'scheme', DI::pConfig()->get(local_user(), 'frio', 'schema', $node_scheme));
+       $arr['scheme_accent']    = DI::pConfig()->get(local_user(), 'frio', 'scheme_accent'   , DI::config()->get('frio', 'scheme_accent'));
        $arr['share_string']     = '';
        $arr['nav_bg']           = DI::pConfig()->get(local_user(), 'frio', 'nav_bg'          , DI::config()->get('frio', 'nav_bg'));
        $arr['nav_icon_color']   = DI::pConfig()->get(local_user(), 'frio', 'nav_icon_color'  , DI::config()->get('frio', 'nav_icon_color'));
@@ -112,6 +115,7 @@ function theme_admin(App $a)
        $arr = [];
 
        $arr['scheme']           = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
+       $arr['scheme_accent']    = DI::config()->get('frio', 'scheme_accent');
        $arr['share_string']     = '';
        $arr['nav_bg']           = DI::config()->get('frio', 'nav_bg');
        $arr['nav_icon_color']   = DI::config()->get('frio', 'nav_icon_color');
@@ -134,16 +138,16 @@ function frio_form($arr)
        $scheme_info = get_scheme_info($arr['scheme']);
        $disable = $scheme_info['overwrites'];
 
-       $scheme_choices = [];
-       $scheme_choices['---'] = DI::l10n()->t('Custom');
-       $files = glob('view/theme/frio/scheme/*.php');
-       if ($files) {
-               foreach ($files as $file) {
-                       $f = basename($file, '.php');
-                       if ($f != 'default') {
-                               $scheme_name = ucfirst($f);
-                               $scheme_choices[$f] = $scheme_name;
-                       }
+       $schemes = [
+               'light' => DI::l10n()->t('Light (Accented)'),
+       ];
+
+       $legacy_schemes = [];
+       foreach (glob('view/theme/frio/scheme/*.php') ?: [] as $file) {
+               $scheme = basename($file, '.php');
+               if (!in_array($scheme, ['default', 'light', 'dark', 'black'])) {
+                       $scheme_name = ucfirst($scheme);
+                       $legacy_schemes[$scheme] = $scheme_name;
                }
        }
 
@@ -153,7 +157,11 @@ function frio_form($arr)
        $ctx = [
                '$submit'           => DI::l10n()->t('Submit'),
                '$title'            => DI::l10n()->t('Theme settings'),
-               '$scheme'           => ['frio_scheme', DI::l10n()->t('Select color scheme'), $arr['scheme'], '', $scheme_choices],
+               '$custom'           => DI::l10n()->t('Custom'),
+               '$legacy'           => DI::l10n()->t('Legacy'),
+               '$accented'         => DI::l10n()->t('Accented'),
+               '$scheme'           => ['frio_scheme', DI::l10n()->t('Select color scheme'), $arr['scheme'], $schemes, $legacy_schemes],
+               '$scheme_accent'    => !$scheme_info['accented'] ? '' : ['frio_scheme_accent', DI::l10n()->t('Select scheme accent'), $arr['scheme_accent'], ['blue' => DI::l10n()->t('Blue'), 'red' => DI::l10n()->t('Red'), 'purple' => DI::l10n()->t('Purple'), 'green' => DI::l10n()->t('Green'), 'pink' => DI::l10n()->t('Pink')]],
                '$share_string'     => $arr['scheme'] != '---' ? '' : ['frio_share_string', DI::l10n()->t('Copy or paste schemestring'), $arr['share_string'], DI::l10n()->t('You can copy this string to share your theme with others. Pasting here applies the schemestring'), false, false],
                '$nav_bg'           => array_key_exists('nav_bg', $disable) ? '' : ['frio_nav_bg', DI::l10n()->t('Navigation bar background color'), $arr['nav_bg'], '', false],
                '$nav_icon_color'   => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', DI::l10n()->t('Navigation bar icon color '), $arr['nav_icon_color'], '', false],
index 7cbfdacfe75b5971329e778913d3ca75949864e1..ca661c2830f227186d4f5d4ed29befcf6ce83562 100644 (file)
@@ -63,19 +63,15 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
                if ($scheme && is_string($scheme) && $scheme != '---') {
                        if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
                                $schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
+                               $scheme_accent =
+                                       DI::pConfig()->get($uid, 'frio', 'scheme_accent') ?:
+                                               DI::config()->get('frio', 'scheme_accent') ?: FRIO_SCHEME_ACCENT_BLUE;
+
                                require_once $schemefile;
                        }
-               } else {
-                       $nav_bg = DI::pConfig()->get($uid, 'frio', 'nav_bg');
-               }
-
-               if (empty($nav_bg)) {
-                       $nav_bg = DI::config()->get('frio', 'nav_bg');
                }
 
-               if (empty($nav_bg) || !is_string($nav_bg)) {
-                       $nav_bg = "#708fa0";
-               }
+               $nav_bg = $nav_bg ?: DI::pConfig()->get($uid, 'frio', 'nav_bg', DI::config()->get('frio', 'nav_bg', '#708fa0'));
 
                echo '<meta name="theme-color" content="' . $nav_bg . '" />';
 ?>
index 42fc21ab8b67f879b44da2ea66f22b4ee5d4d53e..ced19327e8becd9b4dc78d7ce2cce7f461572ba4 100644 (file)
@@ -52,7 +52,8 @@ function get_scheme_info($scheme)
                'description' => '',
                'author' => [],
                'version' => '',
-               'overwrites' => []
+               'overwrites' => [],
+               'accented' => false,
        ];
 
        if (!is_file($themepath . 'scheme/' . $scheme . '.php')) return $info;
@@ -84,6 +85,8 @@ function get_scheme_info($scheme)
                                        foreach ($theme_settings as $key => $value) {
                                                $info['overwrites'][$value] = true;
                                        }
+                               } elseif ($k == 'accented') {
+                                       $info['accented'] = $v && $v != 'false' && $v != 'no';
                                } else {
                                        if (array_key_exists($k, $info)) {
                                                $info[$k] = $v;
diff --git a/view/theme/frio/scheme/light.php b/view/theme/frio/scheme/light.php
new file mode 100644 (file)
index 0000000..767abb2
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Name: Light
+ * Licence: AGPL
+ * Author: Hypolite Petovan <hypolite@friendica.mrpetovan.com>
+ * Overwrites: nav_bg, nav_icon_color, link_color, background_color, login_bg_color, contentbg_transp
+ * Accented: yes
+ */
+
+require_once 'view/theme/frio/php/PHPColors/Color.php';
+
+$accentColor = new Color($scheme_accent);
+
+$nav_bg = '#' . $accentColor->darken(10);
+$menu_background_hover_color = '#' . $accentColor->darken(5);
+$nav_icon_color = "#fff";
+$link_color = '#' . $accentColor->getHex();
+$background_color = "#ededed";
+$login_bg_color = "#ededed";
+$contentbg_transp = 100;
index 99e705a9614e37b3d820d55370997e83465341c0..b70f5657ab4e0fee6aa8ad941e1f1234fee263c7 100644 (file)
@@ -34,6 +34,7 @@ DI::config()->load('frio');
 
 // Default to hard-coded values for empty settings
 $scheme           = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
+$scheme_accent    = DI::config()->get('frio', 'scheme_accent')    ?: FRIO_SCHEME_ACCENT_BLUE;
 $nav_bg           = DI::config()->get('frio', 'nav_bg')           ?: '#708fa0';
 $nav_icon_color   = DI::config()->get('frio', 'nav_icon_color')   ?: '#ffffff';
 $link_color       = DI::config()->get('frio', 'link_color')       ?: '#6fdbe8';
@@ -57,6 +58,7 @@ if ($uid) {
 
        // Only override display settings that have actually been set
        $scheme           = DI::pConfig()->get($uid, 'frio', 'scheme', DI::pConfig()->get($uid, 'frio', 'schema')) ?: $scheme;
+       $scheme_accent    = DI::pConfig()->get($uid, 'frio', 'scheme_accent')    ?: $scheme_accent;
        $nav_bg           = DI::pConfig()->get($uid, 'frio', 'nav_bg')           ?: $nav_bg;
        $nav_icon_color   = DI::pConfig()->get($uid, 'frio', 'nav_icon_color')   ?: $nav_icon_color;
        $link_color       = DI::pConfig()->get($uid, 'frio', 'link_color')       ?: $link_color;
index 5eee8346d857bfdf5577dac132bb84c84dc99193..564f90fde612004df653e77a26396236d34b3ffe 100644 (file)
@@ -1,7 +1,33 @@
 <script src="{{$baseurl}}/view/theme/quattro/jquery.tools.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}" ></script>
 
-{{include file="field_select.tpl" field=$scheme}}
+<div class="form-group field select">
+       <label for="id_{{$scheme.0}}">{{$scheme.1}}</label>
+       <select name="{{$scheme.0}}" id="id_{{$scheme.0}}" class="form-control">
+               <option value="---" {{if '---' == $scheme.2}}selected="selected"{{/if}}>{{$custom}}</option>
+               <optgroup label="{{$accented}}">
+       {{foreach $scheme.3 as $value => $label}}
+                       <option value="{{$value}}" {{if $value == $scheme.2}}selected="selected"{{/if}}>{{$label}}</option>
+       {{/foreach}}
+               </optgroup>
+               <optgroup label="{{$legacy}}">
+       {{foreach $scheme.4 as $value => $label}}
+                       <option value="{{$value}}" {{if $value == $scheme.2}}selected="selected"{{/if}}>{{$label}}</option>
+       {{/foreach}}
+               </optgroup>
+       </select>
+</div>
+
+{{if $scheme_accent}}
+<div class="form-group">
+       <p><label>{{$scheme_accent.1}}</label></p>
+       <label class="radio-inline">
+               <input type="radio" name="{{$scheme_accent.0}}" value="{{$smarty.const.FRIO_SCHEME_ACCENT_BLUE}}" {{if $scheme_accent.2 == $smarty.const.FRIO_SCHEME_ACCENT_BLUE}} checked{{/if}}>
+               <span style="border-radius: 10px; background-color: {{$smarty.const.FRIO_SCHEME_ACCENT_BLUE}}; width: 20px; display: inline-block">&nbsp;</span>
+               {{$scheme_accent.3.blue}}
+       </label>
+</div>
+{{/if}}
 
 {{if $share_string}}{{include file="field_input.tpl" field=$share_string}}{{/if}}
 {{if $nav_bg}}{{include file="field_colorinput.tpl" field=$nav_bg}}{{/if}}
index e555f7f2032b0f584de659f0483139d8de82a5a8..8c40dadd814a332396ba0618fbf00598363d80a4 100644 (file)
@@ -21,6 +21,7 @@ use Friendica\Model\Contact;
 use Friendica\Module;
 use Friendica\Util\Strings;
 
+const FRIO_SCHEME_ACCENT_BLUE   = '#1e87c2';
 function frio_init(App $a)
 {
        global $frio;