Ejemplo n.º 1
0
def test_brand_may_be_collapsed_with_expandable_content(
        web_fixture, navbar_fixture, brand_collapse_fixture):
    """Brands may be collapse along with the other content."""

    responsive_navbar = navbar_fixture.navbar
    responsive_navbar.set_id('my_navbar_id')
    responsive_navbar.use_layout(
        ResponsiveLayout(
            'md',
            collapse_brand_with_content=brand_collapse_fixture.brand_collapse))
    responsive_navbar.layout.add(navbar_fixture.nav)

    brand_widget = Div(web_fixture.view)
    responsive_navbar.layout.set_brand(brand_widget)

    if brand_collapse_fixture.brand_collapse:
        [toggle, collapse_div] = responsive_navbar.children[0].children
        [brand, navbar_nav] = collapse_div.children
    else:
        [brand, toggle, collapse_div] = responsive_navbar.children[0].children
        [navbar_nav] = collapse_div.children

    assert brand is brand_widget
    assert 'navbar-collapse' in collapse_div.get_attribute('class')
    assert 'navbar-nav' in navbar_nav.html_representation.get_attribute(
        'class')
    assert 'navbar-toggler' in toggle.get_attribute('class')
Ejemplo n.º 2
0
    def __init__(self, view):
        super().__init__(view)
        self.body.use_layout(Container())

        layout = ResponsiveLayout('md', colour_theme='dark', bg_scheme='primary')
        navbar = Navbar(view, css_id='my_nav').use_layout(layout)
        navbar.layout.set_brand_text('Address book')
        navbar.layout.add(TextNode(view, 'All your addresses in one place'))

        self.body.add_child(navbar)
        self.body.add_child(AddressBookPanel(view))
Ejemplo n.º 3
0
    def __init__(self, view, bookmarks):
        super().__init__(view)
        self.use_layout(PageLayout(document_layout=Container()))
        contents_layout = ColumnLayout(ColumnOptions('main', size=ResponsiveSize())).with_slots()
        self.layout.contents.use_layout(contents_layout)

        layout = ResponsiveLayout('md', colour_theme='dark', bg_scheme='primary')
        navbar = Navbar(view, css_id='my_nav').use_layout(layout)
        navbar.layout.set_brand_text('Address book')
        navbar.layout.add(Nav(view).with_bookmarks(bookmarks))

        self.layout.header.add_child(navbar)
    def __init__(self, view):
        super(__class__, self).__init__(view)

        self.body.use_layout(Container())

        layout = ResponsiveLayout('md', colour_theme='dark', bg_scheme='primary')
        navbar = Navbar(view, css_id='my_nav').use_layout(layout)
        navbar.layout.set_brand_text('Simple TR')
        navbar.layout.add(TextNode(view, 'Translate from this to that.'))

        self.body.add_child(navbar)
        self.body.add_child(MyPanel(view))
Ejemplo n.º 5
0
    def __init__(self, view, bookmarks):
        super(AddressBookPage, self).__init__(view)
        self.body.use_layout(Container())

        layout = ResponsiveLayout('md',
                                  colour_theme='dark',
                                  bg_scheme='primary')
        navbar = Navbar(view, css_id='my_nav').use_layout(layout)
        navbar.layout.set_brand_text('Address book')
        navbar.layout.add(Nav(view).with_bookmarks(bookmarks))

        self.body.add_child(navbar)
Ejemplo n.º 6
0
def responsive_navbar(fixture):
    """A ResponsiveLayout hides its Navbar when the viewport becomes smaller than a given device size"""
    navbar_widget = fixture.navbar
    navbar_widget.set_id('my_navbar_id')
    navbar_widget.use_layout(ResponsiveLayout('sm'))

    [navbar] = navbar_widget.children
    [toggle, collapse_div] = navbar.children

    vassert('navbar-toggler' in toggle.get_attribute('class'))
    vassert('hidden-sm-up' in toggle.get_attribute('class'))
    vassert('button' in toggle.get_attribute('type'))
    vassert('collapse' in toggle.get_attribute('data-toggle'))
    vassert('my_navbar_id' in toggle.get_attribute('data-target'))

    vassert('my_navbar_id' in collapse_div.get_attribute('id'))
    vassert('collapse' in collapse_div.get_attribute('class'))
    vassert('navbar-toggleable-xs' in collapse_div.get_attribute('class'))
Ejemplo n.º 7
0
def test_responsive_navbar_basics(web_fixture, navbar_fixture):
    """A ResponsiveLayout hides its Navbar when the viewport becomes smaller than a given device size"""

    navbar_widget = navbar_fixture.navbar
    navbar_widget.set_id('my_navbar_id')
    navbar_widget.use_layout(ResponsiveLayout('sm'))

    [navbar] = navbar_widget.children
    [toggle, collapse_div] = navbar.children

    assert 'navbar-toggler' in toggle.get_attribute('class')
    assert 'button' in toggle.get_attribute('type')
    assert 'collapse' in toggle.get_attribute('data-toggle')
    assert 'my_navbar_id' in toggle.get_attribute('data-target')

    assert 'my_navbar_id' in collapse_div.get_attribute('id')
    assert 'collapse' in collapse_div.get_attribute('class').split()
    assert 'navbar-collapse' in collapse_div.get_attribute('class').split()

    assert 'navbar-expand-xs' in navbar.get_attribute('class')
Ejemplo n.º 8
0
    def __init__(self, view, bookmarks):
        super(FundingRequestPage, self).__init__(view)

        self.head.add_css(Url('/css/pyconza2019.css'))

        self.use_layout(PageLayout(document_layout=Container()))
        contents_layout = ColumnLayout(
            ColumnOptions('main', size=ResponsiveSize())).with_slots()
        self.layout.contents.use_layout(contents_layout)

        layout = ResponsiveLayout('md',
                                  colour_theme='dark',
                                  bg_scheme='primary')
        navbar = Navbar(view, css_id='my_nav').use_layout(layout)
        navbar.layout.set_brand_text('PyConZA 2019 Financial Aid')
        navbar.layout.add(Nav(view).with_bookmarks(bookmarks))

        if LoginSession.for_current_session().is_logged_in():
            navbar.layout.add(LogoutForm(view))

        self.layout.header.add_child(navbar)
Ejemplo n.º 9
0
 def aligned_left(self):
     self.layout = ResponsiveLayout('sm', align_toggle_left=True)
     self.expected_order = [CollapseToggle, A, Div]
Ejemplo n.º 10
0
 def aligned_right(self):
     self.layout = ResponsiveLayout('sm', align_toggle_left=False)
     self.expected_order = [A, CollapseToggle, Div]