Search in sources :

Example 31 with H2

use of com.vaadin.flow.component.html.H2 in project komunumo-server by komunumo.

the class ContentBlock method loadPage.

/**
 * Load a page from the database.
 * @param databaseService the service to access the database
 * @param url the URL of the page to load
 * @return the loaded page
 */
public Page loadPage(@NotNull final DatabaseService databaseService, @NotNull final String url) {
    final var urlParts = url.split("/", 2);
    if (urlParts.length < 2 || urlParts[1].isBlank()) {
        throw new NotFoundException();
    }
    final var parent = PageParent.valueOf(FormatterUtil.camelCase(urlParts[0]));
    final var page = databaseService.getPage(parent, urlParts[1]).orElseThrow(NotFoundException::new);
    setContent(new H2(page.getTitle()), new Html("<div>%s</div>".formatted(page.getContent())));
    return page;
}
Also used : NotFoundException(com.vaadin.flow.router.NotFoundException) Html(com.vaadin.flow.component.Html) H2(com.vaadin.flow.component.html.H2)

Example 32 with H2

use of com.vaadin.flow.component.html.H2 in project komunumo-server by komunumo.

the class WebsiteFooter method createContact.

private Component createContact() {
    final var layout = new HorizontalLayout();
    layout.setId("website-footer-contact");
    final var title = new H2("Contact");
    final var name = new Div(new Text(configuration.getWebsiteName()));
    final var address = new Div(new Text(configuration.getWebsiteContactAddress()));
    final var email = createEmail(configuration.getWebsiteContactEmail());
    final var copyright = new Div(new Text(configuration.getWebsiteCopyright()));
    layout.add(new HorizontalLayout(title, new Div(name, address, email, copyright)));
    return layout;
}
Also used : Div(com.vaadin.flow.component.html.Div) H2(com.vaadin.flow.component.html.H2) Text(com.vaadin.flow.component.Text) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 33 with H2

use of com.vaadin.flow.component.html.H2 in project docs by vaadin.

the class DialogClosing method createDialogLayout.

private static VerticalLayout createDialogLayout(Dialog dialog) {
    H2 headline = new H2("System maintenance");
    headline.getStyle().set("margin", "var(--lumo-space-m) 0").set("font-size", "1.5em").set("font-weight", "bold");
    Paragraph paragraph = new Paragraph("System maintenance will begin at 3 PM. It is schedule to conclude at 5PM. We apologize for any inconvenience.");
    // tag::snippet[]
    Button closeButton = new Button("Close");
    closeButton.addClickListener(e -> dialog.close());
    // end::snippet[]
    VerticalLayout dialogLayout = new VerticalLayout(headline, paragraph, closeButton);
    dialogLayout.setPadding(false);
    dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
    dialogLayout.getStyle().set("width", "300px").set("max-width", "100%");
    dialogLayout.setAlignSelf(FlexComponent.Alignment.END, closeButton);
    return dialogLayout;
}
Also used : Button(com.vaadin.flow.component.button.Button) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H2(com.vaadin.flow.component.html.H2) Paragraph(com.vaadin.flow.component.html.Paragraph)

Example 34 with H2

use of com.vaadin.flow.component.html.H2 in project docs by vaadin.

the class DialogDraggable method createDialogLayout.

private static VerticalLayout createDialogLayout(Dialog dialog) {
    H2 headline = new H2("Add note");
    headline.getStyle().set("margin", "0").set("font-size", "1.5em").set("font-weight", "bold");
    // tag::snippet2[]
    HorizontalLayout header = new HorizontalLayout(headline);
    header.getElement().getClassList().add("draggable");
    // end::snippet2[]
    header.setSpacing(false);
    header.getStyle().set("border-bottom", "1px solid var(--lumo-contrast-20pct)").set("cursor", "move");
    // Use negative margins to make draggable header stretch over full width,
    // covering the padding of the dialog
    header.getStyle().set("padding", "var(--lumo-space-m) var(--lumo-space-l)").set("margin", "calc(var(--lumo-space-s) * -1) calc(var(--lumo-space-l) * -1) 0");
    TextField titleField = new TextField("Title");
    TextArea descriptionArea = new TextArea("Description");
    VerticalLayout fieldLayout = new VerticalLayout(titleField, descriptionArea);
    fieldLayout.setSpacing(false);
    fieldLayout.setPadding(false);
    fieldLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
    Button cancelButton = new Button("Cancel", e -> dialog.close());
    Button saveButton = new Button("Add note", e -> dialog.close());
    saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, saveButton);
    buttonLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
    VerticalLayout dialogLayout = new VerticalLayout(header, fieldLayout, buttonLayout);
    dialogLayout.setPadding(false);
    dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
    dialogLayout.getStyle().set("width", "300px").set("max-width", "100%");
    return dialogLayout;
}
Also used : TextArea(com.vaadin.flow.component.textfield.TextArea) Button(com.vaadin.flow.component.button.Button) TextField(com.vaadin.flow.component.textfield.TextField) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H2(com.vaadin.flow.component.html.H2) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 35 with H2

use of com.vaadin.flow.component.html.H2 in project karnak by OsiriX-Foundation.

the class ExportSettingsDialog method buildComponents.

/**
 * Build components
 */
private void buildComponents() {
    // Default
    exportSettings = new ExportSettings();
    // Title
    HorizontalLayout titleLayout = new HorizontalLayout();
    H2 dialogTitle = new H2("Export Settings");
    dialogTitle.setWidthFull();
    titleLayout.add(dialogTitle);
    // Textfields
    delimiterTextField = new TextField("Delimiter");
    quoteCharacterTextField = new TextField("Quote character");
    delimiterTextField.setWidth(60, Unit.PERCENTAGE);
    quoteCharacterTextField.setWidth(60, Unit.PERCENTAGE);
    VerticalLayout fieldsLayout = new VerticalLayout();
    fieldsLayout.add(delimiterTextField, quoteCharacterTextField);
    // Buttons
    cancelButton = new Button("Cancel");
    saveButton = new Button("Save settings");
    saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, saveButton);
    buttonLayout.setJustifyContentMode(JustifyContentMode.CENTER);
    buttonLayout.setWidthFull();
    // Final layout
    VerticalLayout dialogLayout = new VerticalLayout(titleLayout, fieldsLayout, buttonLayout);
    add(dialogLayout);
}
Also used : Button(com.vaadin.flow.component.button.Button) TextField(com.vaadin.flow.component.textfield.TextField) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) H2(com.vaadin.flow.component.html.H2) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

H2 (com.vaadin.flow.component.html.H2)68 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)29 Div (com.vaadin.flow.component.html.Div)25 Grid (com.vaadin.flow.component.grid.Grid)11 ComboBox (com.vaadin.flow.component.combobox.ComboBox)10 Button (com.vaadin.flow.component.button.Button)8 Paragraph (com.vaadin.flow.component.html.Paragraph)7 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)7 Route (com.vaadin.flow.router.Route)6 List (java.util.List)6 IntStream (java.util.stream.IntStream)6 NativeButton (com.vaadin.flow.component.html.NativeButton)5 ArrayList (java.util.ArrayList)5 Html (com.vaadin.flow.component.Html)4 TextField (com.vaadin.flow.component.textfield.TextField)4 Faker (com.github.javafaker.Faker)3 ItemFilter (com.vaadin.flow.component.combobox.ComboBox.ItemFilter)3 Label (com.vaadin.flow.component.html.Label)3 CallbackDataProvider (com.vaadin.flow.data.provider.CallbackDataProvider)3 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)3