Просмотр исходного кода

WIP: apply bootstrap theme

* calculate app title font size dynamically
Yuki Takei 8 лет назад
Родитель
Сommit
472c9113f6
2 измененных файлов с 16 добавлено и 2 удалено
  1. 12 0
      lib/util/swigFunctions.js
  2. 4 2
      lib/views/layout/layout.html

+ 12 - 0
lib/util/swigFunctions.js

@@ -25,6 +25,18 @@ module.exports = function(crowi, app, req, locals) {
     return req.csrfToken;
     return req.csrfToken;
   };
   };
 
 
+  locals.getAppTitleFontSize = function(appTitle) {
+    let fontSize = 22;
+    if (appTitle.length < 13) { /* do nothing */ }
+    else if (appTitle.length < 21) {
+      fontSize -= 3 * (Math.floor((appTitle.length - 13) / 3) + 1);
+    }
+    else  {
+      fontSize = 11;
+    }
+    return fontSize;
+  }
+
   /**
   /**
    * return true if enabled
    * return true if enabled
    */
    */

+ 4 - 2
lib/views/layout/layout.html

@@ -138,13 +138,15 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
             </svg>
             </svg>
           </b>
           </b>
           <span class="hidden-xs" style="color: black">
           <span class="hidden-xs" style="color: black">
+            {% set appTitle = config.crowi['app:title'] | default('GROWI') %}
+            {% set appTitleFontSize = getAppTitleFontSize(appTitle) %}
             <!--This is dark logo text-->
             <!--This is dark logo text-->
             <!-- <img src="../plugins/images/agileadmin-text.png" alt="home" class="dark-logo" /> -->
             <!-- <img src="../plugins/images/agileadmin-text.png" alt="home" class="dark-logo" /> -->
             <!--This is light logo text-->
             <!--This is light logo text-->
             <!-- <img src="../plugins/images/agileadmin-text-dark.png" alt="home" class="light-logo" /> -->
             <!-- <img src="../plugins/images/agileadmin-text-dark.png" alt="home" class="light-logo" /> -->
             <svg xmlns="http://www.w3.org/2000/svg" class="light-logo-text">
             <svg xmlns="http://www.w3.org/2000/svg" class="light-logo-text">
-              <text x="0" y="35" font-size="30" font-weight="bold">
-                {% block title %}{{ config.crowi['app:title']|default('GROWI') }}{% endblock %}
+              <text x="0" y="{{22+appTitleFontSize/2}}" font-size="{{appTitleFontSize}}">
+                {% block title %}{{ appTitle }}{% endblock %}
               </text>
               </text>
             </svg>
             </svg>
           </span>
           </span>