use of com.github.appreciated.css.grid.sizes.Length 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;
}
use of com.github.appreciated.css.grid.sizes.Length 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;
}
Aggregations