diff sat_templates/default/input/textbox.html @ 153:b84d20af0ed3

macros (field, form, textbox): general improvments: - use a generic "field" macro for most fields - added "required" class on input labels if suitable - extra kw args are used as input field attributes. Same thing for forms - better handling of id if label is missing - added blog_text macro in textbox for basic text blog input - textbox is more customisable (class and textarea class can be specified)
author Goffi <goffi@goffi.org>
date Thu, 21 Jun 2018 01:09:00 +0200
parents 33c7ce833d3f
children
line wrap: on
line diff
--- a/sat_templates/default/input/textbox.html	Thu Jun 21 01:02:33 2018 +0200
+++ b/sat_templates/default/input/textbox.html	Thu Jun 21 01:09:00 2018 +0200
@@ -1,5 +1,5 @@
 {% import 'input/form.html' as form with context %}
-{% import 'input/field.html' as field %}
+{% import 'input/field.html' as field with context %}
 
 {% macro head(service, node, type="textbox") %}
     {# include data needed to identify the node to use for commenting #}
@@ -12,22 +12,30 @@
     <input type="submit" value="{{label}}">
 {% endmacro %}
 
-{% macro textbox(service, node, action='', placeholder='', submit_label=_("Send"), type="textbox") %}
-    {# generic content area for comments/blog posts/etc. Only a body by default, but new elements can be
+{% macro textbox(service, node, action='', placeholder='',
+                 submit_label=_("Send"), type="textbox",
+                 class='', ta_class='') %}
+    {# generic content area for comments/blog posts/etc.
+       Only a body by default, but new elements can be
        added by using this macro with call #}
     {% set extra_content = caller() if caller is defined else '' %}
-    {% call form.form(action=action, class="textbox") %}
+    {% call form.form(action=action, class="textbox " + class) %}
         {{ head(service, node, type) }}
         {{ extra_content }}
-        {{ field.textarea("body", placeholder=placeholder, required=True) }}
+        {{ field.textarea("body", placeholder=placeholder, required=True,
+                          class=ta_class) }}
         {{ submit(label=submit_label) }}
     {% endcall %}
 {% endmacro %}
 
-{% macro comment(service, node, action='', placeholder=_("Your comment")) %}
+{% macro blog_text(service, node, action='', placeholder=_("Your comment")) %}
     {{ textbox(service, node, action=action, placeholder=placeholder, type="comment") }}
 {% endmacro %}
 
+{% macro comment(service, node, action='', placeholder=_("Your comment"), class='box--medium') %}
+    {{ textbox(service, node, action=action, placeholder=placeholder, type="comment", class=class) }}
+{% endmacro %}
+
 {% macro comment_or_login(service, node, action='', placeholder=none) %}
     {# show comment form a a message asking to log in
        login is checked using profile #}