Skip to content

Commit eaa2ac7

Browse files
committed
Styling improvements
1 parent 3be894a commit eaa2ac7

File tree

9 files changed

+49
-23
lines changed

9 files changed

+49
-23
lines changed

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 4.2.0
2+
* Improved styling
3+
* Overlay now has the same minimum width as the underlying DateRangePicker
4+
* The default is ``20em``, this can be changed using ``--date-range-picker-min-width``
5+
* Layouts inside the overlay now use the full available width
6+
* Removed excess top padding from input components
7+
* Refactored CSS class names (should cause less conflicts now)
8+
* Updated to Vaadin 24.5
9+
110
## 4.1.1
211
* Only use client-side locale for formatting when no ``formatLocale`` has been set #353
312

@@ -13,7 +22,6 @@
1322
* Various dependency updates including Vaadin 24.1
1423

1524
## 4.0.0
16-
1725
⚠️<i>This release contains breaking changes</i>
1826

1927
* Adds support for Vaadin 24+, drops support for Vaadin 23<br/>
@@ -32,12 +40,10 @@
3240
* Vaadin 23.3
3341

3442
## 3.0.1
35-
3643
* Updated dependencies
3744
* Vaadin 23.2
3845

3946
## 3.0.0
40-
4147
⚠️<i>This release contains breaking changes</i>
4248

4349
* Adds support for Vaadin 23+, drops support for Vaadin 14 #155<br/>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>vaadin-date-range-picker-root</artifactId>
9-
<version>4.1.2-SNAPSHOT</version>
9+
<version>4.2.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>

vaadin-date-range-picker-demo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>vaadin-date-range-picker-root</artifactId>
10-
<version>4.1.2-SNAPSHOT</version>
10+
<version>4.2.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>vaadin-date-range-picker-demo</artifactId>
14-
<version>4.1.2-SNAPSHOT</version>
14+
<version>4.2.0-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>

vaadin-date-range-picker-demo/src/main/java/software/xdev/vaadin/daterange_picker/example/DateRangePickerStyledDemo.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.vaadin.flow.component.HasSize;
44
import com.vaadin.flow.component.UI;
55
import com.vaadin.flow.component.button.Button;
6+
import com.vaadin.flow.component.html.Div;
67
import com.vaadin.flow.component.icon.VaadinIcon;
78
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
9+
import com.vaadin.flow.component.splitlayout.SplitLayout;
810
import com.vaadin.flow.dom.ThemeList;
911
import com.vaadin.flow.router.Route;
1012
import com.vaadin.flow.theme.lumo.Lumo;
@@ -15,15 +17,20 @@ public class DateRangePickerStyledDemo extends AbstractSimpleChangeDemo
1517
{
1618
public static final String NAV = "styled";
1719

18-
private final Button btnDarkMode = new Button("Toogle theme");
20+
private final Button btnDarkMode = new Button("Toggle theme");
1921

2022
public DateRangePickerStyledDemo()
2123
{
2224
this.initUI();
2325
}
2426

27+
@SuppressWarnings("checkstyle:MagicNumber")
2528
protected void initUI()
2629
{
30+
this.dateRangePicker.setWidthFull();
31+
32+
this.taResult.setSizeFull();
33+
2734
this.btnDarkMode.addClickListener(ev ->
2835
{
2936
final ThemeList themeList = UI.getCurrent().getElement().getThemeList();
@@ -40,11 +47,13 @@ protected void initUI()
4047
this.updateBtnDarkMode();
4148
});
4249

43-
this.taResult.setSizeFull();
50+
final SplitLayout splitLayout = new SplitLayout(this.dateRangePicker, new Div());
51+
splitLayout.setSplitterPosition(25);
52+
splitLayout.setWidthFull();
4453

4554
this.getContent().setPadding(false);
4655
this.getContent().add(
47-
new VerticalLayout(this.dateRangePicker),
56+
splitLayout,
4857
new VerticalLayout(this.taResult, this.btnDarkMode));
4958
this.getContent().getChildren().forEach(comp -> ((HasSize)comp).setHeight("50%"));
5059
this.getContent().setHeightFull();

vaadin-date-range-picker/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>vaadin-date-range-picker</artifactId>
9-
<version>4.1.2-SNAPSHOT</version>
9+
<version>4.2.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>vaadin-date-range-picker</name>

vaadin-date-range-picker/src/main/java/software/xdev/vaadin/daterange_picker/ui/DateRangePicker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ protected void initUI()
219219
this.setId("DateRangePickerID" + nextID.incrementAndGet());
220220

221221
this.btnOverview.addClassNames(DateRangePickerStyles.BUTTON, DateRangePickerStyles.CLICKABLE);
222-
this.btnOverview.setMinWidth("20em");
223222
this.btnOverview.setWidthFull();
224223

225224
this.btnOverview.setDisableOnClick(true);

vaadin-date-range-picker/src/main/java/software/xdev/vaadin/daterange_picker/ui/DateRangePickerOverlay.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class DateRangePickerOverlay<D extends DateRange> extends Composite<Verti
5555
/*
5656
* Fields
5757
*/
58-
protected boolean readOnly = false;
58+
protected boolean readOnly;
5959

6060
protected DateRangePicker<D> dateRangePicker;
6161
protected DateRangeModel<D> currentModel;
@@ -84,14 +84,16 @@ protected void initUI()
8484
this.btnBackwardRange
8585
.addClassNames(DateRangePickerStyles.FLEX_CHILD_CONTENTSIZE, DateRangePickerStyles.CLICKABLE);
8686

87-
this.cbDateRange.addClassName(DateRangePickerStyles.FLEX_CHILD_AUTOGROW);
87+
this.cbDateRange.addClassNames(
88+
DateRangePickerStyles.FLEX_CHILD_AUTOGROW,
89+
DateRangePickerStyles.PADDING_TOP_XS);
8890
this.setTextFieldDefaultWidthFlexConform(this.cbDateRange);
8991

9092
this.btnForwardRange
9193
.addClassNames(DateRangePickerStyles.FLEX_CHILD_CONTENTSIZE, DateRangePickerStyles.CLICKABLE);
9294

9395
final HorizontalLayout hlRange = new HorizontalLayout();
94-
hlRange.addClassNames(DateRangePickerStyles.FLEX_CHILD_AUTOGROW, DateRangePickerStyles.FLEX_CONTAINER);
96+
hlRange.addClassNames(DateRangePickerStyles.OVERLAY_LAYOUT_ROW);
9597
hlRange.setAlignItems(Alignment.BASELINE);
9698
hlRange.setJustifyContentMode(JustifyContentMode.BETWEEN);
9799
hlRange.setMargin(false);
@@ -103,21 +105,20 @@ protected void initUI()
103105
this.initDatePicker(this.dpEnd);
104106

105107
final HorizontalLayout hlDatepickers = new HorizontalLayout();
106-
hlDatepickers.addClassNames(DateRangePickerStyles.FLEX_CHILD_AUTOGROW, DateRangePickerStyles.FLEX_CONTAINER);
108+
hlDatepickers.addClassNames(DateRangePickerStyles.OVERLAY_LAYOUT_ROW);
107109
hlDatepickers.setMargin(false);
108110
hlDatepickers.setSpacing(true);
109111
hlDatepickers.setPadding(false);
110112
hlDatepickers.add(this.dpStart, this.dpEnd);
111113

112-
this.addClassName(DateRangePickerStyles.FLEX_CONTAINER);
113114
this.add(hlRange, hlDatepickers);
114115
this.getContent().setPadding(true);
115116
}
116117

117118
protected void initDatePicker(final DatePicker dp)
118119
{
119120
this.setTextFieldDefaultWidthFlexConform(dp);
120-
dp.addClassName(DateRangePickerStyles.FLEX_CHILD_AUTOGROW);
121+
dp.addClassNames(DateRangePickerStyles.FLEX_CHILD_AUTOGROW, DateRangePickerStyles.PADDING_TOP_XS);
121122
dp.setWeekNumbersVisible(true);
122123
}
123124

vaadin-date-range-picker/src/main/java/software/xdev/vaadin/daterange_picker/ui/DateRangePickerStyles.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ private DateRangePickerStyles()
3131
public static final String BUTTON = "date-range-picker-button";
3232
public static final String OVERLAY_BASE = "date-range-picker-overlay-base";
3333
public static final String OVERLAY_LAYOUT = "date-range-picker-overlay-layout";
34+
public static final String OVERLAY_LAYOUT_ROW = "date-range-picker-overlay-layout-row";
3435

3536
/*
3637
* FLEX
3738
*/
38-
public static final String FLEX_CONTAINER = "flex-container";
39+
public static final String FLEX_CHILD_AUTOGROW = "date-range-picker-flex-child-autogrow";
40+
public static final String FLEX_CHILD_CONTENTSIZE = "date-range-picker-flex-child-contentsize";
3941

40-
public static final String FLEX_CHILD_AUTOGROW = "flex-child-autogrow";
41-
public static final String FLEX_CHILD_CONTENTSIZE = "flex-child-contentsize";
42+
// Used to remove Vaadin's default padding which adds a lot of blank space to the overlay
43+
public static final String PADDING_TOP_XS = "date-range-picker-padding-top-xs";
4244
}

vaadin-date-range-picker/src/main/resources/META-INF/resources/frontend/styles/dateRangePicker.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,39 @@
66
margin-bottom: 0;
77
border-radius: 0;
88
color: var(--lumo-body-text-color);
9+
min-width: var(--date-range-picker-min-width, 20em);
910
}
1011

1112
.date-range-picker-overlay-base {
1213
position: relative;
1314
}
1415

1516
.date-range-picker-overlay-layout {
17+
display: flex;
1618
position: absolute;
1719
left: 0;
1820
right: 0;
1921
z-index: 1;
2022
background-color: var(--lumo-base-color);
2123
border: 1px solid var(--lumo-contrast-5pct);
2224
border-top: none;
25+
min-width: var(--date-range-picker-min-width, 20em);
2326
}
2427

25-
.flex-container {
28+
.date-range-picker-overlay-layout-row {
29+
width: 100%;
30+
flex: 1 1 auto;
2631
display: flex;
2732
}
2833

29-
.flex-child-autogrow {
34+
.date-range-picker-flex-child-autogrow {
3035
flex: 1 1 auto;
3136
}
3237

33-
.flex-child-contentsize {
38+
.date-range-picker-flex-child-contentsize {
3439
flex: 0 1 auto;
3540
}
41+
42+
.date-range-picker-padding-top-xs {
43+
padding-top: var(--lumo-space-xs);
44+
}

0 commit comments

Comments
 (0)