Search in sources :

Example 1 with Alignment

use of com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment in project flow-components by vaadin.

the class OrderedLayoutView method createHorizontalLayoutWithDefaultAlignment.

private void createHorizontalLayoutWithDefaultAlignment() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setHeight("150px");
    layout.getStyle().set("border", "1px solid #9E9E9E");
    layout.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN);
    // the default is Alignment.BASELINE
    layout.setDefaultVerticalComponentAlignment(Alignment.CENTER);
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.add(component1, component2, component3);
    add(layout);
    component2.getElement().getStyle().set("fontSize", "24px");
    component3.getElement().getStyle().set("fontSize", "9px");
    RadioButtonGroup<Alignment> alignments = new RadioButtonGroup<>();
    alignments.setItems(Alignment.values());
    alignments.setRenderer(new TextRenderer<>(alignment -> alignment.name().toLowerCase()));
    alignments.setValue(Alignment.CENTER);
    alignments.setId("horizontal-layout-alignment-radio-button");
    alignments.addValueChangeListener(event -> layout.setDefaultVerticalComponentAlignment(event.getValue()));
    layout.setId("layout-with-alignment");
    addCard("HorizontalLayout", "HorizontalLayout with general alignment", layout, alignments);
}
Also used : Component(com.vaadin.flow.component.Component) Scroller(com.vaadin.flow.component.orderedlayout.Scroller) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) H2(com.vaadin.flow.component.html.H2) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Consumer(java.util.function.Consumer) BoxSizing(com.vaadin.flow.component.orderedlayout.BoxSizing) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TextRenderer(com.vaadin.flow.data.renderer.TextRenderer) Span(com.vaadin.flow.component.html.Span) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 2 with Alignment

use of com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment in project flow-components by vaadin.

the class OrderedLayoutView method createFlexLayoutWithAlignmentContent.

/* FlexLayout demos */
private void createFlexLayoutWithAlignmentContent() {
    FlexLayout layout = new FlexLayout();
    layout.setWidth("130px");
    layout.setHeight("150px");
    layout.getStyle().set("border", "1px solid #9E9E9E");
    layout.setFlexWrap(FlexLayout.FlexWrap.WRAP);
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.add(component1, component2, component3);
    layout.setId("flex-layout-with-alignment-content");
    Consumer<FlexLayout.ContentAlignment> changeLayout = alignment -> layout.setAlignContent(alignment);
    addCard("FlexLayout", "FlexLayout with alignment content", layout, createRadioButtonGroup(FlexLayout.ContentAlignment.values(), changeLayout, layout.getAlignContent()));
}
Also used : Component(com.vaadin.flow.component.Component) Scroller(com.vaadin.flow.component.orderedlayout.Scroller) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) H2(com.vaadin.flow.component.html.H2) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Consumer(java.util.function.Consumer) BoxSizing(com.vaadin.flow.component.orderedlayout.BoxSizing) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TextRenderer(com.vaadin.flow.data.renderer.TextRenderer) Span(com.vaadin.flow.component.html.Span) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Example 3 with Alignment

use of com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment in project flow-components by vaadin.

the class OrderedLayoutView method createVerticalLayoutWithDefaultAlignment.

private void createVerticalLayoutWithDefaultAlignment() {
    VerticalLayout layout = new VerticalLayout();
    layout.getStyle().set("border", "1px solid #9E9E9E");
    layout.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN);
    // the default is Alignment.START
    layout.setDefaultHorizontalComponentAlignment(Alignment.STRETCH);
    Component component1 = createComponent(1, "#78909C");
    Component component2 = createComponent(2, "#546E7A");
    Component component3 = createComponent(3, "#37474F");
    layout.add(component1, component2, component3);
    add(layout);
    component2.getElement().setText("Component 2 with long text");
    component3.getElement().setText("C 3");
    RadioButtonGroup<Alignment> alignments = new RadioButtonGroup<>();
    alignments.setItems(Alignment.values());
    alignments.setRenderer(new TextRenderer<>(alignment -> alignment.name().toLowerCase()));
    alignments.setValue(Alignment.STRETCH);
    alignments.setId("vertical-layout-alignment-radio-button");
    alignments.addValueChangeListener(event -> layout.setDefaultHorizontalComponentAlignment(event.getValue()));
    layout.setId("vertical-layout-with-alignment");
    addCard("VerticalLayout", "VerticalLayout with general alignment", layout, alignments);
}
Also used : Component(com.vaadin.flow.component.Component) Scroller(com.vaadin.flow.component.orderedlayout.Scroller) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Div(com.vaadin.flow.component.html.Div) H2(com.vaadin.flow.component.html.H2) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Consumer(java.util.function.Consumer) BoxSizing(com.vaadin.flow.component.orderedlayout.BoxSizing) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TextRenderer(com.vaadin.flow.data.renderer.TextRenderer) Span(com.vaadin.flow.component.html.Span) Alignment(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Aggregations

Component (com.vaadin.flow.component.Component)3 Div (com.vaadin.flow.component.html.Div)3 H2 (com.vaadin.flow.component.html.H2)3 Span (com.vaadin.flow.component.html.Span)3 BoxSizing (com.vaadin.flow.component.orderedlayout.BoxSizing)3 FlexComponent (com.vaadin.flow.component.orderedlayout.FlexComponent)3 Alignment (com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment)3 FlexLayout (com.vaadin.flow.component.orderedlayout.FlexLayout)3 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)3 Scroller (com.vaadin.flow.component.orderedlayout.Scroller)3 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)3 RadioButtonGroup (com.vaadin.flow.component.radiobutton.RadioButtonGroup)3 TextRenderer (com.vaadin.flow.data.renderer.TextRenderer)3 Route (com.vaadin.flow.router.Route)3 Consumer (java.util.function.Consumer)3