Search in sources :

Example 1 with FlexibleGridLayout

use of com.github.appreciated.layout.FlexibleGridLayout in project vaadin-spinkit by mcollovati.

the class DemoUI method spinnerSizesContainer.

private Component spinnerSizesContainer() {
    List<Spinner> spinners = EnumSet.complementOf(EnumSet.of(SpinnerSize.DEFAULT)).stream().map(size -> {
        Spinner s = createSpinner(SpinnerType.PLANE);
        s.setSize(size);
        s.setTitle(size.name());
        return s;
    }).collect(Collectors.toList());
    List<SpinnerType> spinnerTypes = Stream.of(SpinnerType.values()).filter(t -> !t.isAlias()).collect(Collectors.toList());
    ComboBox<SpinnerType> selector = new ComboBox<>("Select spinner type", spinnerTypes);
    selector.setPreventInvalidInput(true);
    selector.setValue(SpinnerType.ROTATING_PLANE);
    selector.addValueChangeListener(e -> spinners.forEach(s -> s.setType(selector.getValue())));
    TextField baseSize = new TextField("Base size (--sk-size)", "40px");
    baseSize.addValueChangeListener(e -> spinners.forEach(s -> s.setBaseSize(e.getValue())));
    FlexibleGridLayout spinnersContainer = new FlexibleGridLayout().withColumns(Repeat.RepeatMode.AUTO_FILL, new Length("25%")).withPadding(true).withSpacing(true).withItems(spinners.stream().map(s -> spinnerWithName(s, Spinner::getSize)).toArray(Component[]::new));
    for (SpinnerSize size : EnumSet.complementOf(EnumSet.of(SpinnerSize.DEFAULT))) {
        Spinner spinner = new Spinner(SpinnerType.PLANE);
        spinner.setSize(size);
        spinner.setTitle(size.name());
        spinners.add(spinner);
    }
    VerticalLayout commands = new VerticalLayout();
    commands.setSizeUndefined();
    commands.setAlignItems(FlexComponent.Alignment.START);
    commands.setMargin(false);
    commands.setSpacing(true);
    commands.add(selector, baseSize);
    VHorizontalLayout layout = new VHorizontalLayout(commands, spinnersContainer);
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setFlexGrow(1, spinnersContainer);
    return layout;
}
Also used : Component(com.vaadin.flow.component.Component) CssImport(com.vaadin.flow.component.dependency.CssImport) Div(com.vaadin.flow.component.html.Div) VTabSheet(org.vaadin.firitin.layouts.VTabSheet) PageTitle(com.vaadin.flow.router.PageTitle) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Function(java.util.function.Function) Spinner(org.vaadin.spinkit.Spinner) VVerticalLayout(org.vaadin.firitin.components.orderedlayout.VVerticalLayout) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Repeat(com.github.appreciated.css.grid.sizes.Repeat) Length(com.github.appreciated.css.grid.sizes.Length) TextField(com.vaadin.flow.component.textfield.TextField) EnumSet(java.util.EnumSet) RichText(org.vaadin.firitin.components.RichText) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Collectors(java.util.stream.Collectors) FlexibleGridLayout(com.github.appreciated.layout.FlexibleGridLayout) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Stream(java.util.stream.Stream) Optional(java.util.Optional) VHorizontalLayout(org.vaadin.firitin.components.orderedlayout.VHorizontalLayout) SpinnerType(org.vaadin.spinkit.SpinnerType) Dialog(com.vaadin.flow.component.dialog.Dialog) SpinnerSize(org.vaadin.spinkit.SpinnerSize) Span(com.vaadin.flow.component.html.Span) Spinner(org.vaadin.spinkit.Spinner) ComboBox(com.vaadin.flow.component.combobox.ComboBox) SpinnerSize(org.vaadin.spinkit.SpinnerSize) Length(com.github.appreciated.css.grid.sizes.Length) VHorizontalLayout(org.vaadin.firitin.components.orderedlayout.VHorizontalLayout) TextField(com.vaadin.flow.component.textfield.TextField) FlexibleGridLayout(com.github.appreciated.layout.FlexibleGridLayout) VVerticalLayout(org.vaadin.firitin.components.orderedlayout.VVerticalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) SpinnerType(org.vaadin.spinkit.SpinnerType) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Example 2 with FlexibleGridLayout

use of com.github.appreciated.layout.FlexibleGridLayout in project vaadin-spinkit by mcollovati.

the class DemoUI method spinnersContainer.

private Component spinnersContainer() {
    List<Spinner> spinners = Stream.of(SpinnerType.values()).filter(t -> !t.isAlias()).map(DemoUI::createSpinner).collect(Collectors.toList());
    FlexibleGridLayout spinnersContainer = new FlexibleGridLayout().withColumns(Repeat.RepeatMode.AUTO_FILL, new Length("25%")).withPadding(true).withSpacing(true).withItems(spinners.stream().map(s -> spinnerWithName(s, Spinner::getType)).toArray(Component[]::new));
    TextField color = new TextField("Color (--sk-color)", "#333");
    color.addValueChangeListener(e -> spinners.forEach(s -> s.setColor(e.getValue())));
    ComboBox<String> theme = new ComboBox<>("Css class", "", "green", "red");
    theme.setPreventInvalidInput(true);
    theme.addValueChangeListener(e -> spinners.forEach(s -> {
        Optional.ofNullable(e.getOldValue()).ifPresent(css -> s.removeClassName("sk-demo-" + css));
        s.addClassName("sk-demo-" + e.getValue());
    }));
    VerticalLayout commands = new VerticalLayout();
    commands.setAlignItems(FlexComponent.Alignment.START);
    commands.setMargin(false);
    commands.setSpacing(true);
    commands.add(color, theme);
    commands.setSizeUndefined();
    VHorizontalLayout layout = new VHorizontalLayout(commands, spinnersContainer);
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setFlexGrow(1, spinnersContainer);
    return layout;
}
Also used : Component(com.vaadin.flow.component.Component) CssImport(com.vaadin.flow.component.dependency.CssImport) Div(com.vaadin.flow.component.html.Div) VTabSheet(org.vaadin.firitin.layouts.VTabSheet) PageTitle(com.vaadin.flow.router.PageTitle) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Function(java.util.function.Function) Spinner(org.vaadin.spinkit.Spinner) VVerticalLayout(org.vaadin.firitin.components.orderedlayout.VVerticalLayout) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) Repeat(com.github.appreciated.css.grid.sizes.Repeat) Length(com.github.appreciated.css.grid.sizes.Length) TextField(com.vaadin.flow.component.textfield.TextField) EnumSet(java.util.EnumSet) RichText(org.vaadin.firitin.components.RichText) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Collectors(java.util.stream.Collectors) FlexibleGridLayout(com.github.appreciated.layout.FlexibleGridLayout) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Stream(java.util.stream.Stream) Optional(java.util.Optional) VHorizontalLayout(org.vaadin.firitin.components.orderedlayout.VHorizontalLayout) SpinnerType(org.vaadin.spinkit.SpinnerType) Dialog(com.vaadin.flow.component.dialog.Dialog) SpinnerSize(org.vaadin.spinkit.SpinnerSize) Span(com.vaadin.flow.component.html.Span) Length(com.github.appreciated.css.grid.sizes.Length) VHorizontalLayout(org.vaadin.firitin.components.orderedlayout.VHorizontalLayout) Spinner(org.vaadin.spinkit.Spinner) ComboBox(com.vaadin.flow.component.combobox.ComboBox) FlexibleGridLayout(com.github.appreciated.layout.FlexibleGridLayout) TextField(com.vaadin.flow.component.textfield.TextField) VVerticalLayout(org.vaadin.firitin.components.orderedlayout.VVerticalLayout) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent)

Aggregations

Length (com.github.appreciated.css.grid.sizes.Length)2 Repeat (com.github.appreciated.css.grid.sizes.Repeat)2 FlexibleGridLayout (com.github.appreciated.layout.FlexibleGridLayout)2 Component (com.vaadin.flow.component.Component)2 Button (com.vaadin.flow.component.button.Button)2 ComboBox (com.vaadin.flow.component.combobox.ComboBox)2 CssImport (com.vaadin.flow.component.dependency.CssImport)2 Dialog (com.vaadin.flow.component.dialog.Dialog)2 Div (com.vaadin.flow.component.html.Div)2 Span (com.vaadin.flow.component.html.Span)2 FlexComponent (com.vaadin.flow.component.orderedlayout.FlexComponent)2 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)2 TextField (com.vaadin.flow.component.textfield.TextField)2 PageTitle (com.vaadin.flow.router.PageTitle)2 Route (com.vaadin.flow.router.Route)2 EnumSet (java.util.EnumSet)2 List (java.util.List)2 Optional (java.util.Optional)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2