def add_as_addon(self, addon, position): if isinstance(addon, six.string_types): addon = Span(self.view, text=addon) span = Span(self.view) span.add_child(addon) span.append_class('input-group-%s' % position) addon.append_class('input-group-text') return self.div.add_child(span)
def add(self, widget): """Adds the given Form or Nav `widget` to the Navbar. :param widget: A :class:`~reahl.web.bootstrap.navs.Nav`, :class:`~reahl.web.bootstrap.ui.Form` or :class:`~reahl.web.bootstrap.ui.TextNode` to add. """ if isinstance(widget, reahl.web.bootstrap.navs.Nav): widget.append_class('navbar-nav') if isinstance(widget, Form): widget.append_class('form-inline') if isinstance(widget, TextNode): span = Span(self.view) span.add_child(widget) span.append_class('navbar-text') widget = span return self.contents_container.add_child(widget)
def __init__(self, view, target_widget, text=None): super().__init__(view, 'button', children_allowed=True) self.set_attribute('type', 'button') self.target_widget = target_widget self.append_class('navbar-toggler') self.set_attribute('data-toggle', 'collapse') self.set_attribute('data-target', '#%s' % target_widget.css_id) self.set_attribute('aria-controls', '%s' % target_widget.css_id) self.set_attribute('aria-label', _('Toggle navigation')) if text is None: collapse_toggle_widget = Span(self.view) collapse_toggle_widget.append_class('navbar-toggler-icon') else: collapse_toggle_widget = TextNode(view, text) self.add_child(collapse_toggle_widget)