Skip to content

Commit 36a0ee7

Browse files
committed
Better code, embrace padding.
The DateTime component as it exists, references a 3rd party library that uses lots of inline styles and hard-coded widths and dimensions. Having explored various other approaches now, there are only two ways to fix this. 1. Actually add the padding to the component itself. This is the only way to make it work inside popovers when used outside of WordPress. 2. Do a major refactor to include a different datetime library. In order to move forward, I'm therefore embracing the padding.
1 parent 2ead619 commit 36a0ee7

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

packages/components/src/date-time/style.scss

+26-12
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
/*rtl:end:ignore*/
66

77
.components-datetime {
8-
padding: $grid-size;
8+
padding: $grid-size-large;
99

1010
.components-datetime__calendar-help {
11-
padding: $grid-size;
11+
padding: $grid-size-large;
1212

1313
h4 {
1414
margin: 0;
@@ -18,8 +18,6 @@
1818
.components-datetime__date-help-button {
1919
display: block;
2020
margin-left: auto;
21-
margin-right: $grid-size;
22-
margin-top: 0.5em;
2321
}
2422

2523
fieldset {
@@ -30,21 +28,33 @@
3028

3129
select,
3230
input {
33-
box-sizing: border-box;
34-
height: 28px;
35-
vertical-align: middle;
36-
padding: 0;
3731
@include input-style__neutral();
3832
}
33+
34+
// Override inherited conflicting styles to be consistent.
35+
select,
36+
input[type="number"],
37+
.components-button {
38+
height: 30px;
39+
margin-top: 0;
40+
margin-bottom: 0;
41+
}
3942
}
4043

4144
.components-datetime__date {
4245
min-height: 236px;
4346
border-top: 1px solid $light-gray-500;
44-
margin-left: -$grid-size;
45-
margin-right: -$grid-size;
4647

4748
// Override external DatePicker styles.
49+
.CalendarMonthGrid {
50+
// The included component contains an arbitrary 13px padding that misaligns things.
51+
margin-left: -13px;
52+
}
53+
54+
.DayPickerNavigation_leftButton__horizontalDefault {
55+
left: 0;
56+
}
57+
4858
.CalendarMonth_caption {
4959
font-size: $default-font-size;
5060
}
@@ -84,11 +94,15 @@
8494
}
8595

8696
.components-datetime__time {
87-
margin-bottom: 1em;
97+
padding-bottom: $grid-size-large;
8898

8999
fieldset {
90-
margin-top: 0.5em;
91100
position: relative;
101+
margin-bottom: 0.5em;
102+
}
103+
104+
fieldset + fieldset {
105+
margin-bottom: 0;
92106
}
93107

94108
.components-datetime__time-field-am-pm fieldset {

packages/editor/src/components/post-publish-panel/style.scss

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
display: none;
8181
}
8282

83+
// The DateTime component has an intrinsic padding in order for the horizontal scrolling to function inside a popover.
84+
// We unset that here when used inline.
8385
.components-datetime {
8486
padding: 0;
8587
}

0 commit comments

Comments
 (0)