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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations