-
Notifications
You must be signed in to change notification settings - Fork 194
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
✨ RSP-631 InputGroup: add Datepicker range variant #53
Conversation
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.
This is almost good to go, a few changes and we can merge. I'd like to get design guidance on some of the widths/presentation, otherwise it's just implementation details.
src/inputgroup/index.css
Outdated
|
||
:root { | ||
/* Todo: move to DNA */ | ||
--spectrum-combobox-quiet-fieldbutton-border-radius: 0; | ||
--spectrum-combobox-field-border-width-right: 0; | ||
--spectrum-combobox-quiet-fieldbutton-padding-right: 0; | ||
--spectrum-datepicker-input-width: calc(var(--spectrum-global-dimension-size-1600) - 2 * var(--spectrum-padding)); | ||
--spectrum-datepicker-datetime-input-width: calc(var(--spectrum-datepicker-input-width) + var(--spectrum-global-dimension-size-700) - 0.5em); |
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.
Perhaps @NateBaldwinDesign can provide guidance on the right width to use here? Also, I assume this will work fine with dates using a period or -
separator instead of /
(the date won't overlap the em dash)?
src/inputgroup/index.css
Outdated
padding-right: var(--spectrum-padding); | ||
} | ||
} | ||
&:nth-of-type(2) { |
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.
@GarthDB how does this make you feel? Do you think we should have selectors for these two bad boys instead of doing nth-of-type
?
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.
It has full browser support, so I don't really have any issue with it. https://caniuse.com/#feat=css-sel3
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.
The only other reason we might be concerned is performance and/or code readability/maintainability, but I think it's fine on both of those.
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.
I think the specificity is pretty high here. I'm not 100% against it, but it feels like we could throw a class on the inputs and simplify the CSS... The real question is: do we want markup simplicity (the PR, as-is), or CSS simplicity (throw an extra class on the fields)?
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.
@majornista We talked a bit with @devongovett and think these selectors should be classes added to the markup.
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.
@lazd Would spectrum-Datepicker-field--start
and spectrum-Datepicker-field--end
work?
@majornista almost good to go! Just those icons remaining, and pending some feedback from @GarthDB on the |
@majornista is this a duplicate of #13 ? |
Yes, this supersedes #13. |
@majornista perfect, I'll close that one in favor of this. |
@GarthDB, @lazd and @NateBaldwinDesign Where are we with this one? |
Update initial margin on hr and em dash.
Use div with class name rather than hr for styling dash.
Improve calculation of dash offset on input.
Fix vertical alignment of em-dash for Medium and Large size variants.
</svg> | ||
</button> | ||
<!-- To render focus ring around entire input group when one of the inputs has keyboard focus, we need this: --> | ||
<div class="spectrum-Datepicker-focusRing" role="presentation"></div> |
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.
Mmmm, this can't be done with :before
/:after
? I don't see anything using those pseudo-elements right now.
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.
@majornista oh, I see -- it's being selected with the sibling selector, so we can't use pseudo-elements. Perhaps, instead, we should be programmatically applying .is-focused
to the outer .spectrum-Datepicker
and using :focus-within
(for futureproofing)
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.
Only with additional javascript to check for .focus-ring
className on a descendant element. And, we'd probably need an extra .focus-ring
state, to distinguish between mouse a keyboard focus. With the added element, the style can be applied with pure CSS.
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.
Got it, so we would need to know "is a child element keyboard focused?" in JavaScript, and a separate class for keyboard vs mouse focus. @GarthDB thoughts on this? This is the first component that has anything like this.
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.
I prefer pure CSS for accessibility things like keyboard focus. It would be preferable to implement it with the same strategy as all the others, but I'm not seeing an obvious way to do that.
We could add something to the focus-ring polyfill, but that would kind of defeat the point of a standards-based polyfill.
The focus-withing strategy would be nice, it just means we're adding another polyfill requirement to focus. What would you prefer @lazd?
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.
Though I would prefer the polyfill, I don't want to hold up this PR. I agree with your sentiments and suppose I'm fine with the current approach.
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.
Got it, so we would need to know "is a child element keyboard focused?" in JavaScript, and a separate class for keyboard vs mouse focus. @GarthDB thoughts on this? This is the first component that has anything like this.
The Rating component has a similar issue with how the focus outline is applied to the wrapper element. Devon was somewhat resistant to the approach of evaluating for descendant input with .focus-ring
. The difference for the Datepicker is that text inputs show blue border for mouse focus and border with box-shadow for keyboard focus.
Thanks for working through all of the changes, merging! |
Add Datepicker range variants to InputGroup to support date and datetime range.
Description
Add
.spectrum-Datepicker--range
and.spectrum-Datepicker--datetimeRange
to.spectrum-InputGroup
style definitions.Update docs to support adding
.is-focused
style to InputGroup on focus, similar to how we do it for.spectrum-Slider
.Related Issues
#54
✨ RSP-631: Datepicker range styles added
Spectrum/spectrum-css/issues/663
JIRA issue RSP-631
Motivation and Context
Calendar supports range selection but Datepicker component does not display the date range.
How Has This Been Tested?
Tested in Spectrum docs and as part of a related React-Spectrum PR.
Screenshots (if appropriate):
Types of changes
Checklist: