]> git.ipfire.org Git - people/ms/westferry.git/commitdiff
UI: Add boxes
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Dec 2021 19:06:26 +0000 (19:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Dec 2021 19:06:26 +0000 (19:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/demo/index.html
src/templates/modules/box.html [new file with mode: 0644]
src/westferry/ui/__init__.py
src/westferry/ui/boxes.py [new file with mode: 0644]

index 322b44c445ee601221eaa50be3e665b36aedcbfc..d2a522f4ec273cf48ba240922ac19320e45c39be 100644 (file)
@@ -128,6 +128,7 @@ westferry_handlersdir = $(pythondir)/westferry/handlers
 westferry_ui_PYTHON = \
        src/westferry/ui/__init__.py \
        src/westferry/ui/base.py \
+       src/westferry/ui/boxes.py \
        src/westferry/ui/forms.py \
        src/westferry/ui/graphs.py \
        src/westferry/ui/menu.py \
@@ -151,7 +152,8 @@ dist_templates_demo_DATA = \
 
 templates_modulesdir = $(templatesdir)/modules
 
-dist_templates_modules_DATA =
+dist_templates_modules_DATA = \
+       src/templates/modules/box.html
 
 templates_modules_formsdir = $(templates_modulesdir)/forms
 
index 22e9c5ba39aee9c00c585bb963d904ab59fb8985..bdb4fa4c295c8312456c037ad6db47e482cb5941 100644 (file)
                <h{{ i }}>{{ _("Heading %s") % i }}</h{{ i }}>
        {% end %}
 
+       <h3>{{ _("Boxes") }}</h3>
+
+       {% module PrimaryBox(_("Primary"), _("This is a box in our primary color.")) %}
+
+       {% module SecondaryBox(_("Secondary"), _("This is a box in our secondary color.")) %}
+
+       {% module SuccessBox(_("Success"), _("This is a box to show a successful operation.")) %}
+
+       {% module WarningBox(_("Warning"), _("This box shows a warning.")) %}
+
+       {% module AlertBox(_("Alert"), _("This is an alert!")) %}
+
        <h3>{{ _("Controls") }}</h3>
 
        <h4>{{ _("Buttons") }}</h4>
diff --git a/src/templates/modules/box.html b/src/templates/modules/box.html
new file mode 100644 (file)
index 0000000..a6ef5db
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="callout {{ level }}">
+       {% if title %}
+               <h5>{{ title }}</h5>
+       {% end %}
+
+       {% if text %}
+               <p>{{ text }}</p>
+       {% end %}
+</div>
index 7bcce3f2f1662f1b61f8426032edf35f8e42619e..025987c3d00410a8f90ccc204c8e2360a0a04804 100644 (file)
@@ -20,6 +20,7 @@
 ###############################################################################
 
 from . import base
+from . import boxes
 from . import forms
 from . import graphs
 from . import menu
diff --git a/src/westferry/ui/boxes.py b/src/westferry/ui/boxes.py
new file mode 100644 (file)
index 0000000..373db80
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+###############################################################################
+#                                                                             #
+# Westferry - The IPFire web user interface                                   #
+# Copyright (C) 2021 IPFire development team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+from . import base
+
+class _BoxModule(base.BaseUIModule):
+       level = None
+
+       def render(self, title, text):
+               return self.render_string(
+                       "modules/box.html", level=self.level, title=title, text=text)
+
+
+class PrimaryBoxModule(_BoxModule):
+       level = "primary"
+
+
+class SecondaryBoxModule(_BoxModule):
+       level = "secondary"
+
+
+class SuccessBoxModule(_BoxModule):
+       level = "success"
+
+
+class WarningBoxModule(_BoxModule):
+       level = "warning"
+
+
+class AlertBoxModule(_BoxModule):
+       level = "alert"