Search in sources :

Example 36 with Icon

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

the class BadgeIcons method createIcon.

// tag::snippet3[]
private Icon createIcon(VaadinIcon vaadinIcon) {
    Icon icon = vaadinIcon.create();
    icon.getStyle().set("padding", "var(--lumo-space-xs");
    return icon;
}
Also used : VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon)

Example 37 with Icon

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

the class ContextMenuPresentation method createIcon.

private Component createIcon(VaadinIcon vaadinIcon) {
    Icon icon = vaadinIcon.create();
    icon.getStyle().set("color", "var(--lumo-secondary-text-color)").set("margin-inline-end", "var(--lumo-space-s").set("padding", "var(--lumo-space-xs");
    return icon;
}
Also used : VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon)

Example 38 with Icon

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

the class AppLayoutSecondaryNavigation method createTab.

private Tab createTab(VaadinIcon viewIcon, String viewName) {
    Icon icon = viewIcon.create();
    icon.getStyle().set("box-sizing", "border-box").set("margin-inline-end", "var(--lumo-space-m)").set("padding", "var(--lumo-space-xs)");
    RouterLink link = new RouterLink();
    link.add(icon, new Span(viewName));
    // 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) Span(com.vaadin.flow.component.html.Span)

Example 39 with Icon

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

the class NotificationRetry method show.

private Notification show() {
    // tag::snippet[]
    // When creating a notification using the constructor,
    // the duration is 0-sec by default which means that
    // the notification does not close automatically.
    Notification notification = new Notification();
    notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
    Div statusText = new Div(new Text("Failed to generate report"));
    Button retryButton = new Button("Retry");
    retryButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
    retryButton.getElement().getStyle().set("margin-left", "var(--lumo-space-xl)");
    retryButton.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, retryButton, 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 40 with Icon

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

the class NotificationRich method createReportError.

public static Notification createReportError() {
    Notification notification = new Notification();
    notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
    Icon icon = VaadinIcon.WARNING.create();
    Div info = new Div(new Text("Failed to generate report!"));
    Button retryBtn = new Button("Retry", clickEvent -> notification.close());
    retryBtn.getStyle().set("margin", "0 0 0 var(--lumo-space-l)");
    HorizontalLayout layout = new HorizontalLayout(icon, info, retryBtn, 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)

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