|
| 1 | +package software.xdev.vaadin.daterange_picker; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | + |
| 5 | +import com.vaadin.flow.component.AttachEvent; |
| 6 | +import com.vaadin.flow.component.Composite; |
| 7 | +import com.vaadin.flow.component.grid.Grid; |
| 8 | +import com.vaadin.flow.component.grid.GridVariant; |
| 9 | +import com.vaadin.flow.component.html.Anchor; |
| 10 | +import com.vaadin.flow.component.html.Span; |
| 11 | +import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
| 12 | +import com.vaadin.flow.data.renderer.ComponentRenderer; |
| 13 | +import com.vaadin.flow.router.PageTitle; |
| 14 | +import com.vaadin.flow.router.Route; |
| 15 | + |
| 16 | +import software.xdev.vaadin.daterange_picker.example.DateRangePickerCustomizedDemo; |
| 17 | +import software.xdev.vaadin.daterange_picker.example.DateRangePickerLocalizedDemo; |
| 18 | +import software.xdev.vaadin.daterange_picker.example.DateRangePickerParameterDemo; |
| 19 | +import software.xdev.vaadin.daterange_picker.example.DateRangePickerRangeExceedingDemo; |
| 20 | +import software.xdev.vaadin.daterange_picker.example.DateRangePickerStyledDemo; |
| 21 | + |
| 22 | + |
| 23 | +@PageTitle("DateRangePicker Examples") |
| 24 | +@Route("") |
| 25 | +public class HomeView extends Composite<VerticalLayout> |
| 26 | +{ |
| 27 | + private final Grid<Example> grExamples = new Grid<>(); |
| 28 | + |
| 29 | + public HomeView() |
| 30 | + { |
| 31 | + this.grExamples |
| 32 | + .addColumn(new ComponentRenderer<>(example -> { |
| 33 | + final Anchor anchor = new Anchor(example.route(), example.name()); |
| 34 | + |
| 35 | + final Span spDesc = new Span(example.desc()); |
| 36 | + spDesc.getStyle().set("font-size", "90%"); |
| 37 | + |
| 38 | + final VerticalLayout vl = new VerticalLayout(anchor, spDesc); |
| 39 | + vl.setSpacing(false); |
| 40 | + return vl; |
| 41 | + })) |
| 42 | + .setHeader("Available demos"); |
| 43 | + |
| 44 | + this.grExamples.setSizeFull(); |
| 45 | + this.grExamples.addThemeVariants(GridVariant.LUMO_COMPACT, GridVariant.LUMO_NO_BORDER); |
| 46 | + |
| 47 | + this.getContent().add(this.grExamples); |
| 48 | + this.getContent().setHeightFull(); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + protected void onAttach(final AttachEvent attachEvent) |
| 53 | + { |
| 54 | + this.grExamples.setItems(Arrays.asList( |
| 55 | + new Example( |
| 56 | + DateRangePickerStyledDemo.NAV, |
| 57 | + "Styled-Demo", |
| 58 | + "dark mode 🌑 and more"), |
| 59 | + new Example( |
| 60 | + DateRangePickerParameterDemo.NAV, |
| 61 | + "Parameter-Demo", |
| 62 | + "configuration is stored in QueryParameters"), |
| 63 | + new Example( |
| 64 | + DateRangePickerLocalizedDemo.NAV, |
| 65 | + "Localized-Demo", |
| 66 | + "🌐 simple localization"), |
| 67 | + new Example( |
| 68 | + DateRangePickerRangeExceedingDemo.NAV, |
| 69 | + "RangeExceeding-Demo", |
| 70 | + "usage of a range exceeding DateRange"), |
| 71 | + new Example( |
| 72 | + DateRangePickerCustomizedDemo.NAV, |
| 73 | + "Customized-Demo", |
| 74 | + "usage of a customized DateRange") |
| 75 | + )); |
| 76 | + } |
| 77 | + |
| 78 | + record Example(String route, String name, String desc) |
| 79 | + { |
| 80 | + } |
| 81 | +} |
0 commit comments