Files
atst/atst/ui_modules.py
richard-dds d6b099c684 Formatting
2018-08-02 13:20:03 -04:00

71 lines
1.9 KiB
Python

from tornado.web import UIModule
# from tornado.template import raw
import re
class Alert(UIModule):
def render(self, title, message=None, actions=None, level="info"):
return self.render_string(
"components/alert.html.to",
title=title,
message=message,
actions=actions,
level=level,
)
class TextInput(UIModule):
def render(self, field, placeholder=""):
return self.render_string(
"components/text_input.html.to",
field=field,
label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors,
placeholder=placeholder,
description=field.description,
)
class OptionsInput(UIModule):
def render(self, field, inline=False):
return self.render_string(
"components/options_input.html.to",
field=field,
label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors,
description=field.description,
inline=inline,
)
class Icon(UIModule):
def render(self, name, classes=""):
with open("static/icons/%s.svg" % name) as svg:
return self.render_string(
"components/icon.html.to", svg=svg.read(), name=name, classes=classes
)
class SidenavItem(UIModule):
def render(self, label, href, active=False, icon=None, subnav=None):
return self.render_string(
"navigation/_sidenav_item.html.to",
label=label,
href=href,
active=active,
icon=icon,
subnav=subnav,
)
class EmptyState(UIModule):
def render(self, message, actionLabel, actionHref, icon=None):
return self.render_string(
"components/empty_state.html.to",
message=message,
actionLabel=actionLabel,
actionHref=actionHref,
icon=icon,
)