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

Add d2l-input-time Component #18

Merged
merged 7 commits into from
Aug 31, 2018
Merged

Add d2l-input-time Component #18

merged 7 commits into from
Aug 31, 2018

Conversation

svanherk
Copy link
Contributor

Taken from: https://github.com/BrightspaceUI/time-picker

Previous issues: https://github.com/BrightspaceUI/time-picker/issues

  • Will add all three to this repo

@svanherk
Copy link
Contributor Author

Will look more into the failing galen tests tomorrow


_updateFormater: function(locale, overrides) {
this._setFormatter(new d2lIntl.DateTimeFormat(locale, { locale: overrides }));
this._setParser(new d2lIntl.DateTimeParse(locale, { locale: overrides }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in this issue, but we should really switch this over to use the localize behavior's time/date formatting methods at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #19

--d2l-input-padding: 0.7rem 1rem;
--d2l-input-padding-focus: calc(0.7rem - 1px) calc(1rem - 1px);

display: inline-flex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all pre-existing code.

Having display: inline-flex; on the host worries me a little. If the consumer happens to put display: inline-block; on d2l-input-time, what affect would that have on the internal layout for the component? For specifying internal layout, I think it's better to isolate internals from the public API to avoid risk of stomping on consumer, and vice versa.

host
   shadow-DOM
      div (where flex or whatever is defined)
         things that flex

Thoughts?

Copy link
Contributor Author

@svanherk svanherk Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, all pre-existing code. I'm not sure the reason for inline-flex, inline-block seems to do the same thing other than 10px of padding at the bottom disappears. Feels weird making an issue for this when I could just do it now, but I'm not sure if this breaks a usage in a form somewhere

}

d2l-dropdown-content {
--d2l-dropdown-verticaloffset: 10px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is an option for this in the d2l-dropdown-content-behavior. Are we able to use that? I'm also wondering if we will see a pattern emerge for a smaller offset - this seems like something that we'll begin to see inconsistency on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above the property has it marked as private, so I think the intention is to set this using the css variable as above. The 20px default does seem very large and looks odd, but it probably makes more sense when there's some kind of connector or error like a menu has

Copy link
Contributor

@dbatiste dbatiste Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the vertical-offset option was added to support Navbars, since the dropdown would appear too low given the specific aesthetic of those openers. The default was intended to work with buttons and the openers in the dropdown collection, and for the most part, we wanted to keep things consistent unless the case was "special"... and so the property was commented as "private" to discourage that.

In doing some poking around, there appears to be some inconsistency that's cropped up already. I suspect some of that could be the same - perhaps not 20px, but not all different either. It would be good if we could reel that in... figure out the common thread there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #25 to address if we don't move to select.

@apply --d2l-body-compact-text;
color: var(--d2l-color-tungsten);
font-style: italic;
padding-top: 10px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like maybe we should follow rule of "6"s. Not sure how much of that is up for grabs though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to center the timezone text beside the dropdown, so I think that would require changes to dropdown as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. It's a minor thing. If one day dropdown is updated for the design spacing changes, this would then need to be updated too. Something seemingly small that has ripple effects. :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood where the timezone was supposed to go, so this doesn't actually rely on the height of the dropdown. So we can change the value, but then it will cause a visual difference for anyone that pulls in the component. Are we good with that, or do we need to talk to design?

@dlockhart
Copy link
Member

Since @svanherk's just transplanting these input components into d2l-inputs, for the sake of simplicity and her sanity I think we should move them in as-is and then if there are follow-up things we want to tackle or look into, let's create issues to track that.

</style>

<d2l-dropdown no-auto-open>
<div class="d2l-dropdown-opener" id="opener">
Copy link
Contributor

@dbatiste dbatiste Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I think the actual opener (the element the user will click or focus on) should have d2l-dropdown-opener class. This class is how the dropdown logic locates the focusable opener. The d2l-dropdown-opener-behavior has some logic that I think expects this, for instance to apply focus to the opener when the use hits [Escape] inside the dropdown content. There's likely a couple more little things like that. So in this case, I think it should be on the input, but perhaps there is a reason it's not in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's an issue with the scrollbar when you do this, and there's special functionality to handle scrolling what has been selected into view. I think it's related to this issue: https://github.com/BrightspaceUI/time-picker/issues/9

I've added #21 with this comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw the scrolling bit earlier too. That's one of the behaviors that made me wonder if this should really be using your select implementation. (?) I'm surprised the opener would affect scrolling though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the select component could be a really good fit. I've been investigating a bit more but I think I'll just throw them in issues and hopefully we can just replace it later and remove those issues altogether.

},

attached: function() {
document.body.addEventListener('focus', this.__onAutoCloseFocus, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know what's different about the focus/close logic here vs what dropdown provides? It would be really great if this component did not need to provide custom logic for this, since it's typically the source of many bugs, especially when considering shadow-DOM vs shady.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this causes the menu not to disappear when someone tabs off the input without selecting anything, or clicks elsewhere on the page. It may be related to the opener not being on the right level?

Added #23

Copy link
Contributor

@dbatiste dbatiste Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it could be because the focusable opener element is not the one marked as the opener. Not sure. Sounds like these scenarios should be handled by dropdown though.

ready: function() {
this.__onAutoCloseFocus = this.__onAutoCloseFocus.bind(this);
this.__onAutoCloseClick = this.__onAutoCloseClick.bind(this);
this.id = this.id || ('d2l-input-time-' + instances++);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we have a little helper for getting unique Id. D2L.Id.getUniqueId().

@dbatiste
Copy link
Contributor

Sounds good Dave. I wasn't sure how much clean-up was "on the table". ;)

I also wonder if this should really be using the select component that she's started on. There seems to be some behavior here that might not be exclusive to this component.

@svanherk
Copy link
Contributor Author

Yeah, I also wasn't sure if we wanted to do cleanup. I was thinking we should keep breaking changes (like size and look and feel) to a minimum so its easy for others to update just doing a find/replace, and then we could do a sweep through the elements to fix issues and make another major release update. I haven't looked yet, but I expect we'll see similar issues with date and datetime.

I'll respond to the comments above and make issues accordingly. @awikkerink are you able to weigh in on any of the questions Dave has about past decisions?

@svanherk
Copy link
Contributor Author

Ok merging now, I think I added all needed issues but keep discussing if I missed anything!

@svanherk svanherk merged commit b043c40 into master Aug 31, 2018
@svanherk svanherk deleted the Add_time_Component branch August 31, 2018 15:57
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