Search in sources :

Example 66 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class MenuBarIcons method createIconItem.

private MenuItem createIconItem(HasMenuItems menu, VaadinIcon iconName, String label, String ariaLabel, boolean isChild) {
    Icon icon = new Icon(iconName);
    if (isChild) {
        icon.getStyle().set("width", "var(--lumo-icon-size-s)");
        icon.getStyle().set("height", "var(--lumo-icon-size-s)");
        icon.getStyle().set("marginRight", "var(--lumo-space-s)");
    }
    MenuItem item = menu.addItem(icon, e -> {
    });
    if (ariaLabel != null) {
        item.getElement().setAttribute("aria-label", ariaLabel);
    }
    if (label != null) {
        item.add(new Text(label));
    }
    return item;
}
Also used : MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Text(com.vaadin.flow.component.Text) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon)

Example 67 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class GridColumnHeaderFooter method createSubscriberHeader.

// tag::snippet2[]
private static Component createSubscriberHeader() {
    Span span = new Span("Subscriber");
    Icon icon = VaadinIcon.INFO_CIRCLE.create();
    icon.getElement().setAttribute("title", "Subscribers are paying customers");
    icon.getStyle().set("height", "var(--lumo-font-size-m)").set("color", "var(--lumo-contrast-70pct)");
    HorizontalLayout layout = new HorizontalLayout(span, icon);
    layout.setAlignItems(FlexComponent.Alignment.CENTER);
    layout.setSpacing(false);
    return layout;
}
Also used : VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Span(com.vaadin.flow.component.html.Span) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 68 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class NotificationRich method createSubmitSuccess.

// tag::snippet[]
public static Notification createSubmitSuccess() {
    Notification notification = new Notification();
    notification.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
    Icon icon = VaadinIcon.CHECK_CIRCLE.create();
    Div info = new Div(new Text("Application submitted!"));
    Button viewBtn = new Button("View", clickEvent -> notification.close());
    viewBtn.getStyle().set("margin", "0 0 0 var(--lumo-space-l)");
    HorizontalLayout layout = new HorizontalLayout(icon, info, viewBtn, createCloseBtn(notification));
    layout.setAlignItems(FlexComponent.Alignment.CENTER);
    notification.add(layout);
    return notification;
}
Also used : Div(com.vaadin.flow.component.html.Div) Button(com.vaadin.flow.component.button.Button) Text(com.vaadin.flow.component.Text) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) Notification(com.vaadin.flow.component.notification.Notification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 69 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class NotificationUndo method show.

public Notification show() {
    // tag::snippet[]
    Notification notification = new Notification();
    notification.setDuration(10000);
    notification.addThemeVariants(NotificationVariant.LUMO_CONTRAST);
    Div statusText = new Div(new Text("5 tasks deleted"));
    Button undoButton = new Button("Undo");
    undoButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
    undoButton.getElement().getStyle().set("margin-left", "var(--lumo-space-xl)");
    undoButton.addClickListener(event -> {
        notification.close();
    });
    Button closeButton = new Button(new Icon("lumo", "cross"));
    closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
    closeButton.getElement().setAttribute("aria-label", "Close");
    closeButton.addClickListener(event -> {
        notification.close();
    });
    HorizontalLayout layout = new HorizontalLayout(statusText, undoButton, closeButton);
    layout.setAlignItems(Alignment.CENTER);
    notification.add(layout);
    notification.open();
    // end::snippet[]
    notification.setPosition(Notification.Position.MIDDLE);
    return notification;
}
Also used : Div(com.vaadin.flow.component.html.Div) Button(com.vaadin.flow.component.button.Button) Text(com.vaadin.flow.component.Text) Icon(com.vaadin.flow.component.icon.Icon) Notification(com.vaadin.flow.component.notification.Notification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 70 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class AppLayoutBottomNavbar method createTab.

private Tab createTab(VaadinIcon viewIcon, String viewName) {
    Icon icon = viewIcon.create();
    icon.setSize("var(--lumo-icon-size-s)");
    icon.getStyle().set("margin", "auto");
    RouterLink link = new RouterLink();
    link.add(icon);
    // Demo has no routes
    // link.setRoute(viewClass.java);
    link.setTabIndex(-1);
    return new Tab(link);
}
Also used : RouterLink(com.vaadin.flow.router.RouterLink) Tab(com.vaadin.flow.component.tabs.Tab) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon)

Aggregations

Icon (com.vaadin.flow.component.icon.Icon)110 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)94 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)46 Button (com.vaadin.flow.component.button.Button)39 Span (com.vaadin.flow.component.html.Span)21 Div (com.vaadin.flow.component.html.Div)19 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)18 Tab (com.vaadin.flow.component.tabs.Tab)16 Text (com.vaadin.flow.component.Text)15 Test (org.junit.Test)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 Grid (com.vaadin.flow.component.grid.Grid)10 RouterLink (com.vaadin.flow.router.RouterLink)9 Notification (com.vaadin.flow.component.notification.Notification)8 Component (com.vaadin.flow.component.Component)7 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)7 Anchor (com.vaadin.flow.component.html.Anchor)7 TextField (com.vaadin.flow.component.textfield.TextField)7 UI (com.vaadin.flow.component.UI)6 StreamResource (com.vaadin.flow.server.StreamResource)6