-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DatePicker] reuse existing components in caption #2792
Changes from 15 commits
f2a934b
ed2255d
3162e53
752ef71
6fc7d0a
5dbf33e
9201d55
585e44c
20cc99b
ee1aefe
1446108
c007d02
8596355
ab916b5
2be34c7
358de54
8688d92
205183d
c49c583
e368464
915e290
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,24 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
line-height: 1; | ||
} | ||
|
||
.#{$ns}-divider { | ||
margin: $datepicker-padding; | ||
background: $pt-divider-black; | ||
width: 1px; | ||
|
||
&.#{$ns}-vertical { | ||
width: auto; | ||
height: 1px; | ||
} | ||
} | ||
|
||
// react-day-picker does not conform to our naming scheme | ||
// stylelint-disable selector-class-pattern | ||
.#{$ns}-datepicker { | ||
position: relative; | ||
border-radius: $pt-border-radius; | ||
background: $datepicker-background-color; | ||
padding: $pt-grid-size; | ||
padding: $datepicker-padding; | ||
user-select: none; | ||
|
||
.DayPicker { | ||
|
@@ -39,8 +50,7 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
|
||
.DayPicker-Month { | ||
display: inline-table; | ||
margin: 0 auto; | ||
padding: 0 $pt-grid-size / 2; | ||
margin: 0 $datepicker-padding $datepicker-padding; | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
user-select: none; | ||
|
@@ -51,34 +61,8 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
} | ||
} | ||
|
||
.DayPicker-NavBar { | ||
position: relative; | ||
} | ||
|
||
.DayPicker-NavButton { | ||
@include pt-icon-colors(); | ||
position: absolute; | ||
top: -$datepicker-header-margin; | ||
cursor: pointer; | ||
padding: $datepicker-header-margin + 1; | ||
|
||
&--prev { | ||
left: -$datepicker-header-margin; | ||
|
||
&::before { | ||
@include pt-icon(); | ||
content: $pt-icon-chevron-left; | ||
} | ||
} | ||
|
||
&--next { | ||
right: -$datepicker-header-margin; | ||
|
||
&::before { | ||
@include pt-icon(); | ||
content: $pt-icon-chevron-right; | ||
} | ||
} | ||
.DayPicker-Caption { | ||
display: table-caption; | ||
} | ||
|
||
.DayPicker-Weekdays { | ||
|
@@ -91,7 +75,7 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
|
||
.DayPicker-Weekday { | ||
@include calendar-day(); | ||
padding-top: $pt-grid-size / 2; | ||
padding-top: $datepicker-padding; | ||
font-weight: 600; | ||
|
||
// normalize.css adds an underline to abbr[title] elements, remove it here | ||
|
@@ -151,78 +135,55 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
color: $pt-text-color-disabled; | ||
} | ||
} | ||
} | ||
|
||
.#{$ns}-datepicker-caption { | ||
display: table-caption; | ||
border-bottom: 1px solid $pt-divider-black; | ||
padding: 0 $pt-grid-size; | ||
text-align: center; | ||
|
||
select { | ||
margin: -$datepicker-header-margin 0 $datepicker-header-margin; | ||
border: 0; | ||
background: none; | ||
cursor: pointer; | ||
height: $pt-input-height; | ||
// increase the size of the click target, clearing the caret on the right. | ||
padding-right: $pt-icon-size-standard; | ||
padding-left: $pt-grid-size / 2; | ||
line-height: $pt-input-height; | ||
color: $pt-text-color; | ||
font-weight: 600; | ||
|
||
// stylelint-disable property-no-vendor-prefix | ||
-moz-appearance: none; | ||
-webkit-appearance: none; | ||
// stylelint-enable property-no-vendor-prefix | ||
|
||
&:focus + .#{$ns}-datepicker-caption-caret { | ||
display: inline; | ||
} | ||
.#{$ns}-datepicker-navbar { | ||
display: flex; | ||
align-items: center; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
left: 0; | ||
height: $pt-button-height; | ||
|
||
&::-ms-expand { | ||
// IE11 styling to hide the arrow | ||
display: none; | ||
} | ||
} | ||
> :first-child { | ||
margin-right: auto; | ||
} | ||
} | ||
|
||
.#{$ns}-datepicker-caption-select { | ||
display: inline-block; | ||
position: relative; | ||
|
||
&:first-child { | ||
margin-right: $pt-grid-size; | ||
} | ||
.#{$ns}-datepicker-caption { | ||
@include pt-flex-container(row, $fill: ":first-child"); | ||
justify-content: space-between; | ||
margin-bottom: $datepicker-padding; | ||
padding: 0 ($pt-button-height - $datepicker-padding); | ||
|
||
// HTMLSelect overrides for a narrower appearance | ||
select { | ||
flex-shrink: 1; | ||
padding-right: $pt-icon-size-standard; | ||
padding-left: $datepicker-padding; | ||
font-weight: 600; | ||
|
||
&:hover .#{$ns}-datepicker-caption-caret { | ||
fill: $pt-icon-color-hover; | ||
+ .#{$ns}-icon { | ||
right: 2px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should this be a multiple of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this case i think not. i really dislike using non-2 multiples of grid size because they're not reliable integers. |
||
} | ||
} | ||
|
||
.#{$ns}-datepicker-caption-caret { | ||
position: absolute; | ||
top: 2px; | ||
right: 0; | ||
fill: $pt-icon-color; | ||
pointer-events: none; | ||
} | ||
|
||
.#{$ns}-datepicker-footer { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-top: $pt-grid-size; | ||
margin-bottom: -$pt-grid-size / 2; | ||
border-top: 1px solid $pt-divider-black; | ||
padding-top: $pt-grid-size / 2; | ||
+ .#{$ns}-divider { | ||
margin: 0; | ||
} | ||
} | ||
|
||
.#{$ns}-datepicker-caption-measure { | ||
padding-left: $pt-grid-size / 2; | ||
padding-left: $datepicker-padding; | ||
font-weight: 600; | ||
} | ||
|
||
.#{$ns}-datepicker-footer { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.#{$ns}-dark .#{$ns}-datepicker { | ||
background: $dark-datepicker-background-color; | ||
|
||
|
@@ -259,29 +220,6 @@ $header-margin: ($header-height - $pt-input-height) / 2 !default; | |
} | ||
} | ||
|
||
.#{$ns}-datepicker-caption { | ||
border-bottom-color: $pt-dark-divider-black; | ||
|
||
select { | ||
color: $pt-dark-text-color; | ||
} | ||
|
||
option { | ||
background-color: $dark-popover-background-color; | ||
} | ||
|
||
// we really need more than 4 compound selector | ||
// to target the particular structure of this markup | ||
// stylelint-disable-next-line | ||
.#{$ns}-datepicker-caption-select:hover .#{$ns}-datepicker-caption-caret { | ||
fill: $pt-dark-icon-color-hover; | ||
} | ||
|
||
.#{$ns}-datepicker-caption-caret { | ||
fill: $pt-dark-icon-color; | ||
} | ||
} | ||
|
||
.#{$ns}-datepicker-footer { | ||
border-top-color: $pt-dark-divider-black; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: gonna pull this out to its own component in a separate PR, in progress now.