Mercurial > libervia-templates
changeset 66:9834106678da
base: menu implementation:
2 menus are now handled: main menu and category menu (for submenus relative to a page).
Main menu is displayed on the side bar on big screen.
Added menu for tickets.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Dec 2017 00:46:42 +0100 |
parents | dd15b6c0b1d3 |
children | 3a9dae71aa6c |
files | default/base/base.html default/components/common.html default/input/xmlui.html default/static/styles.css default/static/ticket.css default/ticket/create.html default/ticket/item.html default/ticket/overview.html |
diffstat | 8 files changed, 243 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/default/base/base.html Wed Nov 15 08:52:14 2017 +0100 +++ b/default/base/base.html Fri Dec 01 00:46:42 2017 +0100 @@ -1,4 +1,5 @@ {% set embedded = True %} {# embedded is set to avoid including base.html several times if a generic page is included (e.g. blog/articles.html) #} +{% import 'components/common.html' as component with context %} {{ script.include('css') }} {# css.js is a common script, so it's useful to import it here #} <!DOCTYPE html> <html> @@ -35,36 +36,37 @@ {{ script.generate_scripts() }} </head> <body> - - <header> - {% if confirm %} - {# confirmation message used when post data has been handled correctly #} - {% block confirm %} - <div class="box post_confirm"> - {% block confirm_message %} - {% trans %}Your data has been sent correctly.{% endtrans %} - {% endblock confirm_message %} - </div> - {% endblock confirm %} - {% endif %} + {% if main_menu is defined %} + {% block main_menu %} + {{ component.menu(main_menu, class="main_menu") }} + {% endblock main_menu %} + {% endif %} - {% if menus %} - {% block menu %} - <nav class="menu"> - <ul> - {% for url,label,cls in menus %} - <li><a class="menu_item button {{cls}}" {{ {'href': url}|xmlattr }}>{{ label }}</a></li> - {% endfor %} - </ul> - </nav> - {% endblock menu %} - {% endif %} - </header> + <div id='main_area'> + <header> + {% if confirm %} + {# confirmation message used when post data has been handled correctly #} + {% block confirm %} + <div class="box post_confirm"> + {% block confirm_message %} + {% trans %}Your data has been sent correctly.{% endtrans %} + {% endblock confirm_message %} + </div> + {% endblock confirm %} + {% endif %} - <div id="body"> - {% block body %} - {% endblock body %} + </header> + + <div id="body"> + {% block category_menu scoped %} + {% if category_menu is defined %} + {{ component.menu(category_menu, class="category_menu") }} + {% endif %} + {% endblock category_menu %} + {% block body %} + {% endblock body %} + </div> + <footer>{% block footer %}{% trans app_name=C.APP_NAME %}Powered by {{app_name}}{% endtrans %}{% endblock %}</footer> </div> - <footer>{% block footer %}{% trans app_name=C.APP_NAME %}Powered by {{app_name}}{% endtrans %}{% endblock %}</footer> </body> </html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/components/common.html Fri Dec 01 00:46:42 2017 +0100 @@ -0,0 +1,19 @@ +{# menu labels, map from menu names to labels #} +{% set ml = { + 'login': _('Session') if profile is defined else _('Log in'), + 'blog_view': _('Blog'), + 'merge-requests_list': _('Merge requests'), + 'merge-request_new': _('Create new merge request'), + 'tickets_list': _('Tickets'), + 'ticket_new': _('Create new ticket'), +} %} + +{% macro menu(menus, class='') %} + <nav class="menu {{class}}"> + <ul> + {% for name,url in menus %} + <li><a class="menu_item button {{name}}" {{ {'href': url}|xmlattr }}>{{ml[name]}}</a></li> + {% endfor %} + </ul> + </nav> +{% endmacro %}
--- a/default/input/xmlui.html Wed Nov 15 08:52:14 2017 +0100 +++ b/default/input/xmlui.html Fri Dec 01 00:46:42 2017 +0100 @@ -14,18 +14,18 @@ {% macro generate_widget(wid, config, id=none) %} {% if wid.type == 'text' %} - {{ text_widget(wid, config, id=id) }} + {{ text_widget(wid, config, id=id) }} {% elif wid.type == 'label' %} {{ label_widget(wid, config) }} {% elif wid.type == 'string' %} - {{ string_widget(wid, config, id=id) }} + {{ string_widget(wid, config, id=id) }} {% elif wid.type == 'jid' %} {# TODO: proper JID widget #} - {{ string_widget(wid, config, id=id) }} + {{ string_widget(wid, config, id=id) }} {% elif wid.type == 'textbox' %} - {{ textbox_widget(wid, config, id=id) }} + {{ textbox_widget(wid, config, id=id) }} {% elif wid.type == 'list' %} - {{ list_widget(wid, config, id=id) }} + {{ list_widget(wid, config, id=id) }} {% endif %} {% endmacro %} @@ -161,7 +161,7 @@ {{- wid|item_filter(config.filters) -}} </textarea> {% else %} - <p class="xmlui_widget xmlui_textbox" {{ {'id':id}|xmlattr }}> + <p class="xmlui_widget xmlui_textbox" {{ {'id':id}|xmlattr }}> {{- wid|item_filter(config.filters) -}} </p> {% endif %} @@ -177,7 +177,7 @@ {% endfor %} </select> {% else %} - <div class="xmlui_widget xmlui_list" {{ {'id':id}|xmlattr }}> + <div class="xmlui_widget xmlui_list" {{ {'id':id}|xmlattr }}> {% for value,label in wid.items %} <span class="xmlui_list_item value_{{value|attr_escape}}"> {{- label -}}
--- a/default/static/styles.css Wed Nov 15 08:52:14 2017 +0100 +++ b/default/static/styles.css Fri Dec 01 00:46:42 2017 +0100 @@ -3,11 +3,23 @@ } body { + margin: 0; + padding: 0; display: flex; height: 100vh; flex-direction: column; box-sizing: border-box; - margin: 0; +} + +#main_side_bar { + +} + +#main_area { + flex: 1; + display: flex; + flex-direction: column; + box-sizing: border-box; } #body { @@ -23,19 +35,7 @@ .box { background-color: #edf2ff; border-radius: 0; -} - -@media (min-width: 500px) { - html { - background-size: auto; - } - body { - padding: 8px; - } - .box { - border-radius: 1em; - box-shadow: 10px 10px 16px -5px rgba(0,0,0,0.5); - } + border-color: silver; } .title { @@ -53,48 +53,164 @@ margin: 1.5em auto; } -/* generic */ +/*** Generic ***/ .button:hover { background-color: #bc0000; } -/* Menus */ +/*** Messages ***/ + +.message_info { + max-width: 500px; + margin: 0 auto; + padding: 1em; + text-align: justify; +} + +.message_info pre { + background: #ddd; + padding: 1em; +} + +/*** Menus ***/ .menu ul { display: flex; - justify-content: center; + padding: 0; margin-top: 8px; - padding: 0; list-style: none; } -.menu li { +.menu a { + display: block; + color: inherit; + text-decoration: none; + font-variant: small-caps; +} + +.main_menu { + min-width: 200px; + /* background-color: #eaeaea; */ + background-color: #333; + color: white; +} + +.main_menu ul { + flex-direction: row; + flex-wrap: wrap; +} + +.main_menu li { + flex: 1; + padding: 0; + margin: 0 1em; +} + +.main_menu a { + display: inline; + white-space: nowrap; +} + +.main_menu a:hover { + background-color: initial; + text-shadow: 1px 1px 2px; + font-weight: bold; +} + +.category_menu ul { + justify-content: center; +} + +.category_menu li { margin: 0.5em; text-align: center; } -.menu a { - color: inherit; - text-decoration: none; - border: solid 1px; - padding: 0.5em; - font-variant: small-caps; - border-radius: 1em; - background: #eee; +.category_menu a { + border: solid 1px; + padding: 0.5em; + border-radius: 0.2em; + background: #eee; +} + +/*** containers ***/ + +/* tabs */ + +.tab_container { + max-width: 1000px; + margin: 0 auto; +} + +.tab_header { + background-color: white; + border-bottom: 1px solid lightgrey; +} + +.tab_header ul { + display: flex; + margin: 0; + padding: 0; + list-style: none; + background-color: white; +} + +.tab_page { + box-sizing: border-box; + padding-top: 2em; + border: 1px solid lightgrey; + border-top: none; + display: None; } -.menu a:hover { +.tab_page.clicked { + display: block; +} + +.tab_button { + display: inline; + color: grey; + background-color: white; + border-top: 1px solid lightgrey; + border-left: 1px solid lightgrey; + border-bottom: 1px solid lightgrey; + padding: 0 1em; + cursor: pointer; + /* we go down by 1px to remove bottom border from .tab_header */ + margin-bottom: -1px; } -/* Forms */ +.tab_button.clicked { + /* background: lightgrey; */ + color: inherit; + border-bottom: none; +} + +li.tab_button:last-child { + border-right: 1px solid lightgrey; +} + +.tab_button input { + display: None; +} + +.tab_button label { + margin: 1em; +} + +.tab_button input:checked + label { + font-weight: bold; +} + +/*** Forms ***/ .form_submit { margin: 1em auto 0; display: block; } -/* XMLUI */ +/*** XMLUI ***/ .xmlui_cont_vertical>* { display: block; @@ -118,3 +234,32 @@ color: inherit; text-decoration: inherit; } + +@media (min-width: 500px) { + html { + background-size: auto; + } + + body { + flex-direction: row; + } + + #main_area { + overflow: auto; + } + + .box { + border-radius: 1em; + box-shadow: 10px 10px 16px -5px rgba(0,0,0,0.5); + } + + .main_menu a { + display: block; + padding: 2em 0; + } + + .main_menu ul { + flex-direction: column; + padding-left: 2em; + } +}
--- a/default/static/ticket.css Wed Nov 15 08:52:14 2017 +0100 +++ b/default/static/ticket.css Fri Dec 01 00:46:42 2017 +0100 @@ -11,6 +11,7 @@ .tickets table { margin: 0 auto; + border-spacing: 0 0.5em; } .tickets tr:nth-child(even) { @@ -90,12 +91,12 @@ } .view #wid_labels span { - font-size: 0.8em; - background: #eae3e3; - font-variant: small-caps; - border: 1px solid black; - border-radius: 0.5em; - padding: 0 2px; + font-size: 0.8em; + background: #eae3e3; + font-variant: small-caps; + border: 1px solid black; + border-radius: 0.5em; + padding: 0 2px; white-space: nowrap; }
--- a/default/ticket/create.html Wed Nov 15 08:52:14 2017 +0100 +++ b/default/ticket/create.html Fri Dec 01 00:46:42 2017 +0100 @@ -1,6 +1,6 @@ {# creata a new ticket #} -{% set menus = [(url_tickets_list, _('Tickets list'), 'tickets_list')] %} +{% set category_menu = [('tickets_list', url_tickets_list)] %} {% extends 'base/base.html' %} {% import 'input/form.html' as form with context %} {% import 'input/field.html' as field with context %}
--- a/default/ticket/item.html Wed Nov 15 08:52:14 2017 +0100 +++ b/default/ticket/item.html Fri Dec 01 00:46:42 2017 +0100 @@ -6,8 +6,8 @@ @variable comments_node(unicode): node for adding comments #} -{% set menus = [(url_tickets_list, _('Tickets list'), 'tickets_list'), - (url_tickets_new, _('Create new ticket'), 'ticket_new')] %} +{% set category_menus = [('tickets_list', url_tickets_list), + ('ticket_new', url_tickets_new)] %} {% if not embedded %}{% extends 'base/base.html' %}{% endif %} {% import 'input/xmlui.html' as xmlui with context %} {% import 'blog/macros.html' as blog with context %} @@ -21,7 +21,7 @@ {% block body %} <div id="{{ item.widget_value['id'] }}" class="view single ticket box"> - {{ xmlui.generate(item, + {{ xmlui.generate(item, form=false, filters={'created': {'filters': ['date_fmt'], 'filters_args':[{'fmt': 'short'}]}, 'updated': {'filters': ['date_fmt'], 'filters_args':[{'fmt': 'short'}]},
--- a/default/ticket/overview.html Wed Nov 15 08:52:14 2017 +0100 +++ b/default/ticket/overview.html Fri Dec 01 00:46:42 2017 +0100 @@ -1,6 +1,6 @@ {# display the list of tickets #} -{% set menus = [(url_tickets_new, _('Create new ticket'), 'ticket_new')] %} +{% set category_menu = [('ticket_new', url_tickets_new)] %} {% extends 'base/base.html' %} {% import 'input/xmlui.html' as xmlui with context %}