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 binding for amp-date-picker min attribute #19035

Merged
merged 2 commits into from Oct 30, 2018

Conversation

cvializ
Copy link
Contributor

@cvializ cvializ commented Oct 29, 2018

Fixes #16410

Implements, documents and tests validation of amp-bind bindings for the attributes min and max on amp-date-picker.

/to @nainar
/cc @choumx

@@ -53,7 +53,7 @@ export function withDatePickerCommon(WrappedComponent) {
*/
function isOutsideRange(min, max, date) {
const maxInclusive = max && moment(max);
const minInclusive = min && moment(min);
const minInclusive = min ? moment(min) : getDefaultMinDate(max);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be getDefaultMinDate(min)?

Copy link
Contributor Author

@cvializ cvializ Oct 30, 2018

Choose a reason for hiding this comment

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

No, but the method name is somewhat confusing. The default minimum date depends on what the maximum date is. The parameter is named max in the function definition to help clarify

function getDefaultMinDate(max) {

Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Bind-related changes LGTM.

@@ -173,6 +173,9 @@ attr_lists: {
blacklisted_value_regex: "__amp_source_origin"
}
attrs: { name: "week-day-format" }
# amp-bind
attrs: { name: "[max]" }
attrs: { name: "[min]" }

Choose a reason for hiding this comment

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

@honeybadgerdontcare FYI validator change.

@@ -33,7 +33,7 @@ export function withDatePickerCommon(WrappedComponent) {
const moment = requireExternal('moment');

/**
* @param {!moment} max
* @param {string} max
Copy link
Contributor

Choose a reason for hiding this comment

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

can this stay {!moment} if you pass moment(max) from isOutsideRange ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that could eliminate the extra call to moment

Copy link
Contributor

@honeybadgerdontcare honeybadgerdontcare left a comment

Choose a reason for hiding this comment

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

validation changes lgtm

@cvializ cvializ force-pushed the feature/adp-bind-min branch 2 times, most recently from 62d5485 to 942e247 Compare October 30, 2018 18:31
@cvializ cvializ merged commit 36fd394 into ampproject:master Oct 30, 2018
twifkak pushed a commit to twifkak/amphtml that referenced this pull request Oct 31, 2018
@twifkak twifkak mentioned this pull request Oct 31, 2018
twifkak added a commit that referenced this pull request Oct 31, 2018
 - cl/219385362 Revision bump for #19035
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Add binding for amp-date-picker min attribute

* Clarify getDefaultMinDate behavior and remove extra moment call
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants