From cb588eb53512625f8f47f21c1d227da8f2288da5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 19 Aug 2020 22:58:00 -0400 Subject: [PATCH] [frio] Add scheme accent feature - Add new accented scheme light - Add first accent blue --- view/theme/frio/config.php | 30 +++++++++++++------- view/theme/frio/php/default.php | 14 ++++----- view/theme/frio/php/scheme.php | 5 +++- view/theme/frio/scheme/light.php | 20 +++++++++++++ view/theme/frio/style.php | 2 ++ view/theme/frio/templates/theme_settings.tpl | 28 +++++++++++++++++- view/theme/frio/theme.php | 1 + 7 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 view/theme/frio/scheme/light.php diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 64809f399..b93848cfe 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -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], diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php index 7cbfdacfe..ca661c283 100644 --- a/view/theme/frio/php/default.php +++ b/view/theme/frio/php/default.php @@ -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 ''; ?> diff --git a/view/theme/frio/php/scheme.php b/view/theme/frio/php/scheme.php index 42fc21ab8..ced19327e 100644 --- a/view/theme/frio/php/scheme.php +++ b/view/theme/frio/php/scheme.php @@ -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 index 000000000..767abb244 --- /dev/null +++ b/view/theme/frio/scheme/light.php @@ -0,0 +1,20 @@ + + * 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; diff --git a/view/theme/frio/style.php b/view/theme/frio/style.php index 99e705a96..b70f5657a 100644 --- a/view/theme/frio/style.php +++ b/view/theme/frio/style.php @@ -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; diff --git a/view/theme/frio/templates/theme_settings.tpl b/view/theme/frio/templates/theme_settings.tpl index 5eee8346d..564f90fde 100644 --- a/view/theme/frio/templates/theme_settings.tpl +++ b/view/theme/frio/templates/theme_settings.tpl @@ -1,7 +1,33 @@ -{{include file="field_select.tpl" field=$scheme}} +
+ + +
+ +{{if $scheme_accent}} +
+

+ +
+{{/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}} diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index e555f7f20..8c40dadd8 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -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;