[frio] Add scheme accent feature

- Add new accented scheme light
- Add first accent blue
This commit is contained in:
Hypolite Petovan 2020-08-19 22:58:00 -04:00
parent 91a1e5df91
commit cb588eb535
7 changed files with 78 additions and 22 deletions

View 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],

View 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 . '" />';
?>

View 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;

View File

@ -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;

View 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;

View 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}}

View 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;