All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dominokit.domino.ui.layout.NavigationBar Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package org.dominokit.domino.ui.layout;

import elemental2.dom.HTMLAnchorElement;
import elemental2.dom.HTMLDivElement;
import elemental2.dom.HTMLElement;
import elemental2.dom.HTMLUListElement;
import org.dominokit.domino.ui.grid.flex.FlexItem;
import org.dominokit.domino.ui.grid.flex.FlexLayout;
import org.dominokit.domino.ui.style.Styles;
import org.dominokit.domino.ui.utils.BaseDominoElement;
import org.dominokit.domino.ui.utils.DominoElement;

import javax.annotation.PostConstruct;

import static org.jboss.gwt.elemento.core.Elements.*;

public class NavigationBar extends BaseDominoElement {
    private final FlexItem menuToggleItem;
    private final FlexItem titleItem;
    private final FlexItem logoItem;
    private final FlexItem actionBarItem;

    private DominoElement navBar = DominoElement.of(nav().css("navbar")
            .css("ls-closed"));
    private FlexLayout container = FlexLayout.create().css("container-fluid");

    DominoElement title = DominoElement.of(a().css("navbar-brand"));
    DominoElement menu = DominoElement.of(a().css("bars"));
    DominoElement topBar = DominoElement.of(ul()
            .css("nav")
            .css("navbar-nav")
            .css("navbar-right")
    );
    DominoElement topBarContainer = DominoElement.div().appendChild(topBar);
    DominoElement navBarHeader = DominoElement.div().css("navbar-header");

    public NavigationBar() {
        menuToggleItem = FlexItem.create().css("menu-toggle");
        logoItem = FlexItem.create();
        titleItem = FlexItem.create();
        actionBarItem = FlexItem.create();
        container
                .appendChild(menuToggleItem.appendChild(menu))
                .appendChild(logoItem)
                .appendChild(titleItem.setFlexGrow(1)
                        .appendChild(title))
                .appendChild(actionBarItem.appendChild(topBarContainer));

        navBar.appendChild(navBarHeader
                .appendChild(container));
        init();
    }

    @PostConstruct
    void init() {
        init(this);
    }

    public static NavigationBar create() {
        return new NavigationBar();
    }

    @Override
    public HTMLElement element() {
        return navBar.element();
    }

    public DominoElement getNavBar() {
        return navBar;
    }

    public DominoElement getTitle() {
        return title;
    }

    public DominoElement getMenu() {
        return menu;
    }

    public DominoElement getTopBar() {
        return topBar;
    }

    public DominoElement getTopBarContainer() {
        return topBarContainer;
    }

    public DominoElement getNavBarHeader() {
        return navBarHeader;
    }

    public FlexItem getMenuToggleItem() {
        return menuToggleItem;
    }

    public FlexItem getLogoItem() {
        return logoItem;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy