From 751954c340fdc58edf1ccdf1b9eaee0d2d34ef14 Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Tue, 24 Nov 2026 23:14:10 +0100 Subject: [PATCH] feat(options): logo section as 3 columns (file/margin/per-device) in Top-of-page tab Prompt M: per logo position (left=brand, center, right) the options page now shows one column with vertical separators and an
below: file dropdown with 'No logo' (off) first, top margin as plain number 0-100, and 'Show logo on' with computer/tablet/mobile checkboxes. New option keys per position: logofile, logotopmargin, showon{computer,tablet,mobile}; old keys (brandlogo/centerlogo/rightlogo, *logohideonsmall, shared logotopmargin) removed from config.xml. Views map the checkboxes to Bootstrap display classes per breakpoint and emit per-logo padding-top; variants/build.php migrates the old json keys to the new ones. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- config.xml | 40 +++++++---- options/options.twig | 84 ++++++++++++++++++++++-- variants/build.php | 40 +++++++++++ views/layout_survey_list.twig | 2 +- views/subviews/header/custom_header.twig | 15 ++++- views/subviews/header/nav_bar.twig | 51 ++++++++++---- 6 files changed, 197 insertions(+), 35 deletions(-) diff --git a/config.xml b/config.xml index 1a8a09c..ebc5646 100644 --- a/config.xml +++ b/config.xml @@ -95,20 +95,34 @@ enable + HOUSE-STYLE: logos, background image and bodybackgroundcolor are set per + variant via variants/.json --> - on - ./files/logo.png - on - off - ./files/logo.png - on - off - ./files/logo2.png - on - 15px + + ./files/logo.png + 15 + on + on + off + off + 15 + on + on + off + off + 15 + on + on + off on scroll tile diff --git a/options/options.twig b/options/options.twig index e1c8151..d2f69de 100644 --- a/options/options.twig +++ b/options/options.twig @@ -144,13 +144,21 @@ {% set aTopOfPageKeys = [ 'headerbackgroundcolor', 'navbarfontcolor', 'headersticky', 'headerstickycomputer', 'headerstickytablet', 'headerstickymobile', - 'brandlogo', 'brandlogofile', 'brandlogohideonsmall', - 'centerlogo', 'centerlogofile', 'centerlogohideonsmall', - 'rightlogo', 'rightlogofile', 'rightlogohideonsmall', - 'logotopmargin', + 'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile', + 'centerlogofile', 'centerlogotopmargin', 'centershowoncomputer', 'centershowontablet', 'centershowonmobile', + 'rightlogofile', 'rightlogotopmargin', 'rightshowoncomputer', 'rightshowontablet', 'rightshowonmobile', 'progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor' ] %} +{# Prompt M: the logo keys are rendered as ONE dedicated 3-column block (triggered at + the first logo key, 'brandlogofile') and skipped in the generic per-key loop. #} +{% set aLogoKeys = [ + 'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile', + 'centerlogofile', 'centerlogotopmargin', 'centershowoncomputer', 'centershowontablet', 'centershowonmobile', + 'rightlogofile', 'rightlogotopmargin', 'rightshowoncomputer', 'rightshowontablet', 'rightshowonmobile' +] %} +{% set aLogoPositions = ['brand', 'center', 'right'] %} + {# Tab list: FIRST the "Fonts" tab (where the default/base font is chosen and the per-element font overrides live), then the "Top of the page" tab (keys = aTopOfPageKeys), then one tab per remaining category from config.xml like the @@ -217,6 +225,73 @@ {% for key in aTabKeys %} {% set attr = aOptionAttributes.optionAttributes[key] ?? null %} {% if attr is not null %} + {% if tab.id == 'top-of-page' and key == 'brandlogofile' %} + {# PROMPT M: dedicated 3-column logo block (left/center/right), vertical + borders between columns, hr below. Per column, top to bottom: + file dropdown ("No logo" first), margin 0-100px, "Show logo on" + with 3 device checkboxes. Labels above controls (Prompt G), + server-side checked/selected/value like the generic renderer. #} +
+
+ {% for pos in aLogoPositions %} + {% set fkey = pos ~ 'logofile' %} + {% set mkey = pos ~ 'logotopmargin' %} + {% set fattr = aOptionAttributes.optionAttributes[fkey] %} + {% set mattr = aOptionAttributes.optionAttributes[mkey] %} + {% set fcv = bGeneralInherit ? 'inherit' : (aCurrentOptions[fkey] is defined ? aCurrentOptions[fkey] : (oParentOptions[fkey] is defined ? oParentOptions[fkey] : '')) %} + {% set mcv = bGeneralInherit ? 'inherit' : (aCurrentOptions[mkey] is defined ? aCurrentOptions[mkey] : (oParentOptions[mkey] is defined ? oParentOptions[mkey] : '')) %} +
+ {# 1. logo file dropdown, "No logo" (value off) first #} +
+ + + +
+ {# 2. margin between logo and top of screen, 0-100 px #} +
+ + +
+ {# 3. "Show logo on" per device #} +
+ {{ gT("Show logo on") }} + {% for dev in ['computer', 'tablet', 'mobile'] %} + {% set ckey = pos ~ 'showon' ~ dev %} + {% set cattr = aOptionAttributes.optionAttributes[ckey] %} + {% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %} +
+ +
+ +
+
+ {% endfor %} +
+
+ {% endfor %} +
+

+
+ {% elseif key not in aLogoKeys %} {# server-side current value for this option (checked/selected/value) #} {% set currentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[key] is defined ? aCurrentOptions[key] : (oParentOptions[key] is defined ? oParentOptions[key] : '')) %} {# parent != '': this field is only visible when the parent option is "on" @@ -353,6 +428,7 @@ {% endif %} + {% endif %} {% endif %} {% endfor %} diff --git a/variants/build.php b/variants/build.php index 82d6a82..0384ae6 100644 --- a/variants/build.php +++ b/variants/build.php @@ -228,6 +228,46 @@ if (!empty($definition['fontOptions']) && (empty($definition['options']) || !isset($definition['options']['font']))) { $definition['options']['font'] = preg_replace('/[^a-z0-9_]/i', '_', (string) $definition['fontOptions'][0]['value']); } +// --- Prompt M migration: map the OLD logo json keys to the NEW per-logo keys --- +// Old model: logo ("on"/"off") + logofile (path) + logohideonsmall +// ("on" = hide below the md breakpoint) + one shared logotopmargin ("15px"). +// New model: logofile ("off" = no logo, path = show), logotopmargin (plain +// number 0-100), showon{computer,tablet,mobile} ("on"/"off"). +// The old keys are removed from the json options afterwards, so the unknown-key +// check below does not fail on them. +$logoPositions = ['brand', 'center', 'right']; +if (!isset($definition['options']) || !is_array($definition['options'])) { + $definition['options'] = []; +} +if (isset($definition['options']['logotopmargin'])) { + $margin = preg_replace('/[^0-9]/', '', (string) $definition['options']['logotopmargin']); + if ($margin === '') { + $margin = '15'; + } + foreach ($logoPositions as $p) { + $definition['options'][$p . 'logotopmargin'] = $margin; + } + unset($definition['options']['logotopmargin']); +} +foreach ($logoPositions as $pos) { + $oldOn = $pos . 'logo'; + $oldHide = $pos . 'logohideonsmall'; + if (isset($definition['options'][$oldOn]) && $definition['options'][$oldOn] === 'off') { + // old "off" wins over any file: in the new model the logo is hidden via logofile = "off" + $definition['options'][$pos . 'logofile'] = 'off'; + } + unset($definition['options'][$oldOn]); + if (isset($definition['options'][$oldHide])) { + // old hideonsmall "on" = hide on mobile only -> showonmobile "off"; + // old "off" = never hide -> show on all devices + $showEverywhere = ($definition['options'][$oldHide] !== 'on'); + $definition['options'][$pos . 'showoncomputer'] = 'on'; + $definition['options'][$pos . 'showontablet'] = 'on'; + $definition['options'][$pos . 'showonmobile'] = $showEverywhere ? 'on' : 'off'; + unset($definition['options'][$oldHide]); + } +} + $optionsNode = $xpath->query('//options')->item(0); if ($optionsNode === null) { fwrite(STDERR, "No section found in mother config\n"); diff --git a/views/layout_survey_list.twig b/views/layout_survey_list.twig index a92b049..4a2e067 100644 --- a/views/layout_survey_list.twig +++ b/views/layout_survey_list.twig @@ -92,7 +92,7 @@ NOTE: Feel free to ask for functions, variables, etc, that you feel are missing {{ include('./subviews/header/head.twig') }} + class=" {{ aSurveyInfo.class.body }} font-{{ aSurveyInfo.options.font }} lang-{{ aSurveyInfo.languagecode }} {{ aSurveyInfo.surveyformat }} {% if( aSurveyInfo.options.brandlogofile|default('off') not in ['off', '', 'inherit']) %}brand-logo{% endif %}" {{ aSurveyInfo.attr.body }} > {# This used for the pjax system #}
diff --git a/views/subviews/header/custom_header.twig b/views/subviews/header/custom_header.twig index 20e3282..4843cb7 100644 --- a/views/subviews/header/custom_header.twig +++ b/views/subviews/header/custom_header.twig @@ -65,7 +65,7 @@ background-color: {{ aSurveyInfo.options.privacybackgroundcolor }}; } - {% if ( aSurveyInfo.options.brandlogo == "on" ) %} + {% if ( aSurveyInfo.options.brandlogofile|default('off') not in ['off', '', 'inherit'] ) %} body .top-container { margin-top: 0; } @@ -166,8 +166,17 @@ {% endif %} {% endif %} - #survey-nav .logo-container > img { - padding-top: {{ aSurveyInfo.options.logotopmargin }}; + {# Prompt M: per-logo top margin (options logotopmargin hold a plain px + number 0-100; the "px" unit is added here. |replace({'px':''}) guards + against a legacy stored value that still carries the unit. #} + #survey-nav .logo-left > img { + padding-top: {{ aSurveyInfo.options.brandlogotopmargin|default('15')|replace({'px': ''}) }}px; + } + #survey-nav .logo-center > img { + padding-top: {{ aSurveyInfo.options.centerlogotopmargin|default('15')|replace({'px': ''}) }}px; + } + #survey-nav .logo-right > img { + padding-top: {{ aSurveyInfo.options.rightlogotopmargin|default('15')|replace({'px': ''}) }}px; } #survey-nav .navbar-nav > li > a, diff --git a/views/subviews/header/nav_bar.twig b/views/subviews/header/nav_bar.twig index a8f0346..773b9d0 100644 --- a/views/subviews/header/nav_bar.twig +++ b/views/subviews/header/nav_bar.twig @@ -16,6 +16,26 @@ See: https://getbootstrap.com/components/#navbar For the survey navigator ("Next", "Back", etc.), see: navigation/navigator.twig #} +{# Prompt M: per-device visibility of a logo as Bootstrap display classes. + Options per position: showoncomputer (default on), showontablet + (default on), showonmobile (default off). Breakpoints are Bootstrap's: + mobile < 768px (< md), tablet 768-991px (md..lg), computer >= 992px (>= lg). + A plain div is block at every size, so each range needs its explicit class. #} +{% macro logoVisibilityClasses(options, pos) -%} + {%- set c = (options[pos ~ 'showoncomputer']|default('on')) == 'on' -%} + {%- set t = (options[pos ~ 'showontablet']|default('on')) == 'on' -%} + {%- set m = (options[pos ~ 'showonmobile']|default('off')) == 'on' -%} + {%- if c and t and m -%} + {%- elseif m and t -%}d-lg-none + {%- elseif m and c -%}d-md-none d-lg-block + {%- elseif m -%}d-md-none + {%- elseif t and c -%}d-none d-md-block + {%- elseif c -%}d-none d-lg-block + {%- elseif t -%}d-none d-md-block d-lg-none + {%- else -%}d-none + {%- endif -%} +{%- endmacro %} +{% import _self as navmacros %} {% if not aSurveyInfo.popupPreview %} {% set navClass = "navbar-light bg-light" %} {% if( aSurveyInfo.template == "bootswatch") %} @@ -28,7 +48,15 @@ For the survey navigator ("Next", "Back", etc.), see: navigation/navigator.twig or (aSurveyInfo.aQuestionIndex.bShow == true and aSurveyInfo.format != 'A') or (aSurveyInfo.alanguageChanger.show) %} - {% set showRightLogo = (aSurveyInfo.options.rightlogo == "on" and imageSrc(aSurveyInfo.options.rightlogofile)) %} + {# THEME ADDITION (Prompt M): per-logo file option (logofile; "off" or + empty = no logo). The old on/off keys (brandlogo/centerlogo/rightlogo) + are gone — the file option alone decides whether a logo shows. #} + {% set brandLogoFile = aSurveyInfo.options.brandlogofile|default('off') %} + {% set centerLogoFile = aSurveyInfo.options.centerlogofile|default('off') %} + {% set rightLogoFile = aSurveyInfo.options.rightlogofile|default('off') %} + {% set showBrandLogo = (brandLogoFile not in ['off', '', 'inherit'] and imageSrc(brandLogoFile)) %} + {% set showCenterLogo = (centerLogoFile not in ['off', '', 'inherit'] and imageSrc(centerLogoFile)) %} + {% set showRightLogo = (rightLogoFile not in ['off', '', 'inherit'] and imageSrc(rightLogoFile)) %} {# THEME ADDITION: font for the header / top menu (config.xml option "headerfont", type fontselect). "base" = same as the base font: no extra class, the navbar inherits the body font (body gets font-). Applied on #survey-nav, @@ -41,11 +69,6 @@ For the survey navigator ("Next", "Back", etc.), see: navigation/navigator.twig the media queries instead. Before a reset the old behaviour (always fixed-top) is kept as fallback. #} {% set bStickyConfigured = aSurveyInfo.options.headerstickycomputer is defined %} - {# Per-logo "hide on small screens" (Bootstrap classes d-none d-md-block). - Default (option missing or "on") keeps the logo hidden below the md breakpoint. #} - {% set hideSmallLeft = (aSurveyInfo.options.brandlogohideonsmall != "off") %} - {% set hideSmallCenter = (aSurveyInfo.options.centerlogohideonsmall != "off") %} - {% set hideSmallRight = (aSurveyInfo.options.rightlogohideonsmall != "off") %}