zoom.components module

zoom.components

class zoom.components.HeaderBar(model=None, **k)

Bases: zoom.mvc.DynamicView

Header Bar

A horizontal header bar with a left and right content sections. Useful for section headers that may contain actions or other features.

>>> content = HeaderBar(left='Left Part', right='Right Part')
>>> print(content)
<div class="header-container">
    <div class="header-bar clearfix">
        <div class="header-bar-left">
            Left Part
        </div>
        <div class="header-bar-right">
            Right Part
        </div>
    </div>
</div>
left = ''
right = ''

Bases: object

zoom.components.as_actions(items)

returns actions

>>> from zoom.context import context as ctx
>>> ctx.site = lambda: None
>>> ctx.site.url = ''
>>> as_actions(['New'])
'<div class="actions"><ul><li><a class="action" href="<dz:request_path>/new" id="new-action">New</a></li></ul></div>'
>>> as_actions(['New','Delete'])
'<div class="actions"><ul><li><a class="action" href="<dz:request_path>/delete" id="delete-action">Delete</a></li><li><a class="action" href="<dz:request_path>/new" id="new-action">New</a></li></ul></div>'

generate an unordered list of links

>>> as_links(['one', 'two'])
'<ul><li><a href="<dz:app_url>">one</a></li><li><a href="<dz:app_url>/two">two</a></li></ul>'
>>> as_links([('one', '/1'), 'two'])
'<ul><li><a href="/1">one</a></li><li><a href="<dz:app_url>/two">two</a></li></ul>'
>>> as_links([('uno', 'one', '/1'), 'two'], select=lambda a: a.name=='uno')
'<ul><li class="active"><a class="active" href="/1">one</a></li><li><a href="<dz:app_url>/two">two</a></li></ul>'
>>> as_links(['one', 'two'], select=lambda a: a.name=='two')
'<ul><li><a href="<dz:app_url>">one</a></li><li class="active"><a class="active" href="<dz:app_url>/two">two</a></li></ul>'
zoom.components.dropzone(url, **kwargs)

Dropzone component

A basic dropzone component that supports drag and drop uploading of files which are posted to the URL provided.

>>> zoom.system.site = zoom.sites.Site()
>>> zoom.system.site.packages = {}
>>> zoom.system.request = zoom.utils.Bunch(app=zoom.utils.Bunch(name='hello', packages={}))
>>> c = dropzone('/app/files')
>>> isinstance(c, zoom.Component)
True
zoom.components.error(message)
zoom.components.spinner()

A progress spinner

>>> isinstance(spinner(), str)
True
zoom.components.success(message)
zoom.components.warning(message)