From 2ff1c21b4bd9261e090950b87afd3cfc6212187a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 1 Dec 2021 19:06:26 +0000 Subject: [PATCH] UI: Add boxes Signed-off-by: Michael Tremer --- Makefile.am | 4 ++- src/templates/demo/index.html | 12 +++++++++ src/templates/modules/box.html | 9 +++++++ src/westferry/ui/__init__.py | 1 + src/westferry/ui/boxes.py | 49 ++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/templates/modules/box.html create mode 100644 src/westferry/ui/boxes.py diff --git a/Makefile.am b/Makefile.am index 322b44c..d2a522f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/src/templates/demo/index.html b/src/templates/demo/index.html index 22e9c5b..bdb4fa4 100644 --- a/src/templates/demo/index.html +++ b/src/templates/demo/index.html @@ -11,6 +11,18 @@ {{ _("Heading %s") % i }} {% end %} +

{{ _("Boxes") }}

+ + {% 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!")) %} +

{{ _("Controls") }}

{{ _("Buttons") }}

diff --git a/src/templates/modules/box.html b/src/templates/modules/box.html new file mode 100644 index 0000000..a6ef5db --- /dev/null +++ b/src/templates/modules/box.html @@ -0,0 +1,9 @@ +
+ {% if title %} +
{{ title }}
+ {% end %} + + {% if text %} +

{{ text }}

+ {% end %} +
diff --git a/src/westferry/ui/__init__.py b/src/westferry/ui/__init__.py index 7bcce3f..025987c 100644 --- a/src/westferry/ui/__init__.py +++ b/src/westferry/ui/__init__.py @@ -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 index 0000000..373db80 --- /dev/null +++ b/src/westferry/ui/boxes.py @@ -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 . # +# # +############################################################################### + +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" -- 2.47.3