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

amp-date-countdown component #15453

Merged
merged 57 commits into from Jun 19, 2018
Merged

amp-date-countdown component #15453

merged 57 commits into from Jun 19, 2018

Conversation

leonahliang90
Copy link
Contributor

@leonahliang90 leonahliang90 commented May 21, 2018

(previously mostly reviewed via PR #13657)

MVP:

  • Ability to set an enddate (probably ISO format with optional timezone section similar to amp-timeago) and get some default out of the box rendering. (e.g. 2 days 10 hours 2 minutes 30 seconds ) - Done
  • Ability to customize and internationalize the format: (e.g. 3 hours 10:02:30) - Done
    • Since numbers are dynamic, pluralization of the words matter here - Ability to introduce multiple language, I am not language expert so i presume we would consistently use plural instead as different language for different rules and will make the component complicated and heavy.
  • Ability to provide formats where groupings are different. For instance instead of 1 month 20 days publisher may prefer 50 days - Done, please refer to biggest-unit attribute
  • Ability to use CSS to style each part (number and text) so publisher could do renderings - Done
  • Ability to write CSS that would allow animation when numbers change (this probably means we either need to reset the class or remove/reinsert instead of just changing innerText) - Suggest to move to non-MVP list, as there are many css animation effects, it might take quite some time and effort to be implemented
  • Ability to specify what happens when it reaches the end. Maybe publisher wants it to stay at 0 or they may it to keep going in the opposite direction. Done
  • One of end-date, timestamp-ms, timestamp-seconds is required, else error message. -
    Done
  • Support offset-seconds - Done
  • Support i18n locale - Done

To be confirmed:

  • currently only support up to Day, not sure need to support for Weeks / Months / Years ?
  • css animation

leonahliang90 and others added 30 commits February 26, 2018 14:36
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Docs LGTM

}
attrs: {
name: "offset-seconds"
value_regex: "-?\\d{1,}"
Copy link
Member

Choose a reason for hiding this comment

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

Optionally, you could shorten {1,} to +.

@twifkak
Copy link
Member

twifkak commented May 29, 2018

Validator changes look good, thanks! (Small regex suggestion in the protoascii.)

@aghassemi aghassemi self-assigned this May 30, 2018
@aghassemi
Copy link
Contributor

@leonalicious This is getting very close, I see couple of unit tests failures (related to this component). We can merge as soon as they are fixed and build is green. Thanks for all the work on this component!

@leonahliang90
Copy link
Contributor Author

it was working previously, and i have tried to fix this for last couple of days, seems like the connection between element.setAttribute , build(), impl are not connected and I am lost ...

For instance, based on my understanding

  1. element.setAttribute('biggest-unit', 'HOURS')
  2. then element.build()
  3. then my element.implementation_ should be able to get the object that have attribute('biggest-unit') and execute the method that i want

it was working previously, now is not working, if there are any simple example would be much appreciate

@leonahliang90
Copy link
Contributor Author

@aghassemi please help, i have uploaded my test-amp-date-countdown.js, the last 3 use cases that i have commented out are not working, i am writing it based on test-amp-date.js but not too sure why they are not working as expected

// element.build();
// let timeObj;
// let itemElement;
// Services.viewerForDoc(win.document).whenFirstVisible().then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

because this test is async you need to add a return here and return the promise so that the test runner knows to wait.

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 did add a return here, but then it will stuck there and return error

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

the thing is it will never go inside the function, not sure why , and then i did try another approach in the last 2 test cases

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 you are stubbing the whenFirstVisible above in test setup and keeping a reference under viewer variable so

return viewer.whenFirstVisible().then() {
});
whenFirstVisiblePromiseResolve(); 

should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, still not working as expected

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to skip for now to get the PR in, we can fix later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, already commented them out , and the rest of the test scripts are passed !

Copy link
Contributor

Choose a reason for hiding this comment

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

@leonalicious there seems to be a conflict in gulp.js after that's resolved and build is green, we can merge. Thanks for all the work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here you go, should be resolved by now~

Copy link
Contributor

Choose a reason for hiding this comment

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

a new unit test failure (32:7 error 'whenFirstVisiblePromiseResolve' is assigned a value but never used. Allowed unused vars must match /AmpElement|Def|Interface$/ no-unused-vars
)

(we are constantly improving our lint/jsdoc rules so that is why these issues keep coming up, so as you rebase and try to merge PR, there might be new rules to adhere to that did not exist before. Apologies for the inconvenience this causes but needed for code quality improvements)

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 do run sudo gulp pr-check and notice there are too many errors which flood my entire command screen and i couldn't not pin-point and check on amp-date-countdown properly. but i guess all linter check should be achieved by now~

@aghassemi aghassemi changed the title fix #10385 [amp-date-countdown] contribute amp-date-countdown component - ref PR 13657 🌟 amp-date-countdown component Jun 19, 2018
@aghassemi aghassemi changed the title 🌟 amp-date-countdown component amp-date-countdown component Jun 19, 2018
@aghassemi aghassemi merged commit 304e09a into ampproject:master Jun 19, 2018
@aghassemi
Copy link
Contributor

@leonalicious Merged! Thanks so much for contributing this new component to AMP and for you patience through the review and approval process.
/cc @ericlindley-g

@leonahliang90
Copy link
Contributor Author

It is our pleasure to contribute the component and giving it back to the community ~

alin04 pushed a commit to alin04/amphtml that referenced this pull request Jun 22, 2018
@alin04 alin04 mentioned this pull request Jun 22, 2018
honeybadgerdontcare pushed a commit that referenced this pull request Jun 22, 2018
* cl/201378460 Revision bump for #15453

* cl/201393002 Revision bump for #14521

* cl/201426296 Revision bump for #16159

* cl/201570498 n/a

* cl/201578514 n/a

* cl/201602467 Revision bump for #16167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants