def __init__(self, view): super(MainWidget, self).__init__(view) navbar = Navbar(view) navbar.use_layout(NavbarLayout()) fixture.element_to_collapse = P(view, text='Peek-A-Boo', css_id='my_id') navbar.layout.add_toggle(fixture.element_to_collapse) self.add_child(fixture.element_to_collapse) self.add_child(navbar)
def __init__(self, view): super().__init__(view) navbar = Navbar(view) navbar.use_layout( NavbarLayout(colour_theme='dark', bg_scheme='dark')) fixture.element_to_collapse = P(view, text='Peek-A-Boo', css_id='my_id') navbar.layout.add_toggle(fixture.element_to_collapse) self.add_child(fixture.element_to_collapse) self.add_child(navbar)
def test_navbar_basics(web_fixture, navbar_fixture): """A typical Navbar is created by using its layout to add some brand text, a nav and form in it.""" fixture = navbar_fixture navbar = Navbar(web_fixture.view).use_layout(NavbarLayout()) navbar.layout.set_brand_text('Brandy') navbar.layout.add(fixture.nav) navbar.layout.add(fixture.form) [brand, nav, form] = navbar.children[0].children [ul] = nav.children # The Navbar itself assert navbar.children[0].tag_name == 'nav' assert 'navbar' in navbar.children[0].get_attribute('class').split(' ') # The added contents assert isinstance(brand, A) assert brand.href.path == '/' assert 'navbar-brand' in brand.get_attribute('class') assert 'navbar-nav' in ul.get_attribute('class') assert isinstance(form, Form) assert 'form-inline' in form.get_attribute('class')
def test_customised_colour_scheme(web_fixture): """A ColourScheme is used to determine link colours and/or optionally a standard bootstrap background color.""" layout = NavbarLayout(colour_theme='light', bg_scheme='dark') widget = Navbar(web_fixture.view).use_layout(layout) [navbar] = widget.children assert 'navbar-light' in navbar.get_attribute('class') assert 'bg-dark' in navbar.get_attribute('class')
def __init__(self, view): super().__init__(view) self.use_layout( PageLayout( document_layout=Container(), contents_layout=ColumnLayout( ColumnOptions('main', size=ResponsiveSize(lg=6))).with_slots())) navbar = Navbar(view).use_layout(NavbarLayout()) navbar.layout.set_brand_text('My Site') self.layout.header.add_child(navbar)
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))
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))
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)
def navbar_can_have_layout(fixture): """NavbarLayout is used to define the placement of a Navbar.""" widget = Navbar(fixture.view).use_layout(fixture.layout) [navbar] = widget.children all_classes = ['navbar-fixed-bottom', 'navbar-fixed-top', 'navbar-full'] if fixture.expected_css_class: vassert(fixture.expected_css_class in navbar.get_attribute( 'class').split(' ')) for not_expected_class in [ i for i in all_classes if i != fixture.expected_css_class ]: vassert( not_expected_class not in navbar.get_attribute('class').split(' '))
def test_navbar_can_have_layout(web_fixture, layout_scenarios): """NavbarLayout is used to define the placement of a Navbar.""" fixture = layout_scenarios widget = Navbar(web_fixture.view).use_layout(fixture.layout) [navbar] = widget.children all_classes = ['fixed-bottom', 'fixed-top', 'sticky-top'] if fixture.expected_css_class: assert fixture.expected_css_class in navbar.get_attribute( 'class').split(' ') for not_expected_class in [ i for i in all_classes if i != fixture.expected_css_class ]: assert not_expected_class not in navbar.get_attribute('class').split( ' ')
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)
def navbar_basics(fixture): """A typical Navbar is created by using its layout to add some brand text, a nav and form in it.""" navbar = Navbar(fixture.view).use_layout(NavbarLayout()) navbar.layout.set_brand_text('Brandy') navbar.layout.add(fixture.nav) navbar.layout.add(fixture.form) [brand, nav, form] = navbar.children[0].children [ul] = nav.children # The Navbar itself vassert(navbar.children[0].tag_name == 'nav') vassert('navbar' in navbar.children[0].get_attribute('class').split(' ')) # The added contents vassert(isinstance(brand, A)) vassert('navbar-brand' in brand.get_attribute('class')) vassert('navbar-nav' in ul.get_attribute('class')) vassert(isinstance(form, Form))
def new_navbar(self): return Navbar(self.web_fixture.view)
def new_navbar(self): return Navbar(self.view)