Search in sources :

Example 1 with H1

use of com.vaadin.flow.component.html.H1 in project flow by vaadin.

the class AttachExistingElementView method onShow.

@Override
protected void onShow() {
    setId("root-div");
    add(createButton("Attach label", "attach-label", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "label", null, this::handleLabel)));
    add(createButton("Attach Header", "attach-header", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "h1", null, this::handleHeader)));
    Div div = new Div();
    div.setId("element-with-shadow");
    ShadowRoot shadowRoot = div.getElement().attachShadow();
    add(createButton("Attach label in shadow", "attach-label-inshadow", event -> shadowRoot.getStateProvider().attachExistingElement(shadowRoot.getNode(), "label", null, this::handleLabelInShadow)));
    add(createButton("Attach non-existing element", "non-existing-element", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "image", null, new NonExistingElementCallback())));
    add(div);
    getPage().executeJs("$0.appendChild(document.createElement('label'));", shadowRoot);
    getPage().executeJs("$0.appendChild(document.createElement('span')); $0.appendChild(document.createElement('label'));" + "$0.appendChild(document.createElement('h1'));", getElement());
}
Also used : Component(com.vaadin.flow.component.Component) Element(com.vaadin.flow.dom.Element) H1(com.vaadin.flow.component.html.H1) Div(com.vaadin.flow.component.html.Div) Label(com.vaadin.flow.component.html.Label) ViewTestLayout(com.vaadin.flow.uitest.servlet.ViewTestLayout) Node(com.vaadin.flow.dom.Node) ShadowRoot(com.vaadin.flow.dom.ShadowRoot) ChildElementConsumer(com.vaadin.flow.dom.ChildElementConsumer) Route(com.vaadin.flow.router.Route) Div(com.vaadin.flow.component.html.Div) ShadowRoot(com.vaadin.flow.dom.ShadowRoot)

Example 2 with H1

use of com.vaadin.flow.component.html.H1 in project flow by vaadin.

the class MainView method createHeaderContent.

private Component createHeaderContent() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.addClassName("header");
    layout.getThemeList().set("dark", true);
    layout.setWidthFull();
    layout.setSpacing(false);
    layout.setAlignItems(FlexComponent.Alignment.CENTER);
    layout.add(new DrawerToggle());
    viewTitle = new H1();
    layout.add(viewTitle);
    Avatar avatar = new Avatar();
    if (userInfo != null) {
        avatar.setName(userInfo.getFullName());
        avatar.setImage(userInfo.getImageUrl());
    }
    layout.add(avatar);
    return layout;
}
Also used : H1(com.vaadin.flow.component.html.H1) DrawerToggle(com.vaadin.flow.component.applayout.DrawerToggle) Avatar(com.vaadin.flow.component.avatar.Avatar) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 3 with H1

use of com.vaadin.flow.component.html.H1 in project flow by vaadin.

the class AttachExistingElementView method handleHeader.

private void handleHeader(Element header) {
    H1 lbl = Component.from(header, H1.class);
    lbl.setText("Client side header");
    lbl.setId("header");
}
Also used : H1(com.vaadin.flow.component.html.H1)

Example 4 with H1

use of com.vaadin.flow.component.html.H1 in project flow by vaadin.

the class MainView method createDrawerContent.

private Component createDrawerContent(Tabs menu) {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setPadding(false);
    layout.setSpacing(false);
    layout.getThemeList().set("spacing-s", true);
    layout.setAlignItems(FlexComponent.Alignment.STRETCH);
    HorizontalLayout logoLayout = new HorizontalLayout();
    logoLayout.addClassName("logo");
    logoLayout.setAlignItems(FlexComponent.Alignment.CENTER);
    logoLayout.add(new Image("public/images/logo.jpg", "Bank of Flow logo"));
    logoLayout.add(new H1("Bank of Flow"));
    Div info = new Div();
    info.setText("The menu intentionally shows items you cannot access so that access control can be tested by clicking on them");
    layout.add(logoLayout, info, menu);
    if (userInfo == null) {
        Button login = new Button("Log in");
        login.setId("login");
        login.addClickListener(e -> {
            e.getSource().getUI().get().navigate(LoginView.class);
        });
        layout.add(login);
    } else {
        Button logout = new Button("Logout");
        logout.setId("logout");
        logout.addClickListener(e -> {
            securityUtils.logout();
        });
        layout.add(logout);
    }
    return layout;
}
Also used : Div(com.vaadin.flow.component.html.Div) Button(com.vaadin.flow.component.button.Button) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H1(com.vaadin.flow.component.html.H1) Image(com.vaadin.flow.component.html.Image) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

H1 (com.vaadin.flow.component.html.H1)4 Div (com.vaadin.flow.component.html.Div)2 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 Component (com.vaadin.flow.component.Component)1 DrawerToggle (com.vaadin.flow.component.applayout.DrawerToggle)1 Avatar (com.vaadin.flow.component.avatar.Avatar)1 Button (com.vaadin.flow.component.button.Button)1 Image (com.vaadin.flow.component.html.Image)1 Label (com.vaadin.flow.component.html.Label)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)1 Element (com.vaadin.flow.dom.Element)1 Node (com.vaadin.flow.dom.Node)1 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)1 Route (com.vaadin.flow.router.Route)1 ViewTestLayout (com.vaadin.flow.uitest.servlet.ViewTestLayout)1