Beispiel #1
0
def brand(*content):
    ''' A "brand" element in a navbar, essentially the title or logo. To make
    it a link, pass it a {"href": "http://my.link.here"} attribute dict.

    '''

    return classed_a(NAVBAR_CLASS, *content)
Beispiel #2
0
def nav_dropdown(title, *content):
    ''' A button to open a dropdown menu in a navbar. Give it a menu in the
    content for it to actually work.
    WARNING: Unlike other functions, this one can't take extra classes right
    now :(

    '''

    return classed_li(DROPDOWN_CLASS,
        classed_a(
            combine(DROPDOWN_CLASS, "toggle"),
            toggle(DROPDOWN_CLASS),
            title,
            classed_b("caret"),
            *content
        )
    )
Beispiel #3
0
def media(img_url, title, link_url, *content):
    ''' Returns the HTML for a basic formatter for a "media object" like a video
    or something. It kind of looks like a Facebook post. '''

    return classed_div(MEDIA_CLASS,
        *media_content(img_url, title, link_url, *content
    )


def media_list(*content):
    ''' A list that handles media items (even nested!) gracefully. Use
    media_list_item to generate them. '''

    return classed_ul(MEDIA_LIST_CLASS, *content)


def media_list_item(img_url, title, link_url, *content):
    ''' A single list item in a media list (see media_list() for something that
    is designed to gracefully hold them). '''

    return classed_li(MEDIA_CLASS,
        *media_content(img_url, title, link_url, *content)
    )


def media_content(img_url, title, link_url, *content):
    ''' Returns the content to a media block. Should only be used internally,
    use media() or media_list() + media_list_item(). '''

    return [
        classed_a(PULL_LEFT, href(link_url),
            img({"src": img_url, "class": MEDIA_OBJECT_CLASS})
        ),
        classed_div(MEDIA_BODY_CLASS,
            h4(classes(MEDIA_HEADING_CLASS), title),
            *content
        )
    ]
Beispiel #4
0
def navbar_button(*content):
    ''' A button for use in the navigation bar. '''

    return classed_a([BUTTON_CLASS, NAVBAR_BUTTON_CLASS], *content)
Beispiel #5
0
def close():
    ''' Returns the HTML code for an X that indicates an element can be closed
    (like a window.) '''

    return classed_a(CLOSE_CLASS, href("#"), "×")
Beispiel #6
0
def close():
    ''' Returns the HTML code for an X that indicates an element can be closed
    (like a window.) '''

    return classed_a(CLOSE_CLASS, href("#"), "×")