Skip to content
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

Merged
merged 9 commits into from
Mar 18, 2019

Conversation

majornista
Copy link
Contributor

@majornista majornista commented Dec 12, 2018

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):

Datepicker Range Input Group
Datepicker Range Input Group (Quiet variant)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@majornista majornista changed the title ✨ RSP-631 InputGroup: add Datepicker range variant ✨ RSP-631 InputGroup: add Datepicker range variant Dec 12, 2018
Copy link
Member

@lazd lazd left a 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 Show resolved Hide resolved

: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);
Copy link
Member

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)?

docs/inputgroup/datepicker-range-quiet.yml Outdated Show resolved Hide resolved
src/inputgroup/skin.css Show resolved Hide resolved
src/inputgroup/skin.css Show resolved Hide resolved
docs/inputgroup/datepicker-range.yml Show resolved Hide resolved
topdoc/resources/js/docs.js Show resolved Hide resolved
padding-right: var(--spectrum-padding);
}
}
&:nth-of-type(2) {
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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)?

Copy link
Member

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.

Copy link
Contributor Author

@majornista majornista Mar 15, 2019

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?

@lazd
Copy link
Member

lazd commented Dec 19, 2018

@majornista almost good to go! Just those icons remaining, and pending some feedback from @GarthDB on the nth-of-type situation.

@GarthDB
Copy link
Member

GarthDB commented Jan 7, 2019

@majornista is this a duplicate of #13 ?

@majornista
Copy link
Contributor Author

@majornista is this a duplicate of #13 ?

Yes, this supersedes #13.

@GarthDB
Copy link
Member

GarthDB commented Jan 7, 2019

@majornista perfect, I'll close that one in favor of this.

@majornista
Copy link
Contributor Author

majornista commented Feb 20, 2019

@GarthDB, @lazd and @NateBaldwinDesign Where are we with this one?

src/inputgroup/index.css Outdated Show resolved Hide resolved
src/inputgroup/skin.css Outdated Show resolved Hide resolved
</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>
Copy link
Member

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.

Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

@lazd
Copy link
Member

lazd commented Mar 18, 2019

Thanks for working through all of the changes, merging!

@lazd lazd merged commit 5660100 into adobe:master Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants