-
Notifications
You must be signed in to change notification settings - Fork 2k
Add DateCalendar and DateRangeCalendar components #102989
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
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
026ee11
to
2233c42
Compare
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~1150 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~491 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
@jameskoster @verofasulo @mirka @retrofox Could you take a look and share some early feedback? This is a prototype but, if we agree on the approach, I'm going to iterate on it and refine it. |
Update:
Next up, I'm going to take a look at controlled vs uncontrolled. In any case, I've added some TODO items in the PR description. |
I'm following the linear project and just saw this PR. I thought I'd share the following, though I suppose you're already aware of this. The "date filter" is one of the features we'd like to have in DataViews (see original conversation). One of the key features would be providing presets ("one day", "past week", etc.). Is this something the new Calendar component will support? or would it be up to consumers to implement? For reference, in the Site Logs screen, we've reused the existing
|
Hey @oandregal ! Yes, we're aware of this need, and we already discussed it on Gutenberg (link). These components are focused on displaying only the Calendar UI and handling the user interaction. We deliberately decided to exclude:
In short — we expect the consumers of the component to handle the presets. I added a "With Presets" Storybook examples to both Sidenote: happy to help with building that filter dialog, especially when it comes to choosing the componentry and adopting the correct semantics! |
Update:
Kapture.2025-05-05.at.11.57.30.mp4The PR is now ready for a preliminary review, with the goal of flagging any missing requirements, any visual tweaks, and discuss the API approach. I'd like to highlight a few aspects to receive feedback on. Code, API design and general functionality (cc @Automattic/team-calypso @retrofox @kangzj @miguelpeixe @dkoo @oandregal )
Design & visual styles (@jameskoster @verofasulo ):
|
I've started to look into adding a datetime filter to DataViews at #103136 It should serve to test the new calendar component developed in this PR as well. |
Generally the design is in a decent spot. I think we might need a different treatment for marking |
Thank you so much for working on this, @ciampo ! Not sure if it's still in progress, but I can't see this logic implemented in the video above: "Clicking outside the range updates the start/end date accordingly. Clicking within a range deselects as well." Or maybe it is, and I couldn't get it from the video.
@jameskoster, can't we just keep the outline persistent? Like in the MUI calendar: |
@veronica.fasulo I should have been more specific, it disappears when it's the first or last date in a range. |
By using
Agree, I don't see any large changes needed — more like small tweaks. I'll wait for technical feedback before moving forward. |
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 looks awesome and works like charm! Thanks for working on this.
Could we please make timeZone
a explicit param, which would be useful for Jetpack Stats because all the stats is in the timezone of the site right now?
Plus what's the size implication of adapting the component?
Thanks again!
Thank you for taking a look, @kangzj !
I don't think handling time zones is relevant since the component only handles dates (and no time) — although I may be missing something.
Beyond that, though, building a well-functioning, feature-full and accessible Calendar component first-hand would require a big effort, and I'm not sure about what the potential savings in terms of bundle size would be. |
AFAIK, we need to highlight today in the timezone of the site, which otherwise would be incorrect for some pps especially those ones who have a site set to a different timezone as their browser. For example, I'm in +12 zone, and when I look at stats for FG, it always lags 12 hours. This gets trickier when the Calendar accepts Date objects 🤔
Not bad at all. Thanks! |
I assume that the "today" date would always works as expected, given that it's calculated on the client —
Absolutely, I'll ensure that the Storybook examples' path is right before merging. |
Like I shared in this comment, Jetpack Stats is always in the timezone of the site, regardless of the browser timezone. It means, today would be in site timezone as well. We only allow selection of past dates + today, so if site timezone and browser timezone don't match, then users could have problems selecting dates. For example, if my browser is +12, and site is UTC, when it's 8am, 12 May, my today would be 12 May, and the today for the site is still 11 May. (I passed 'UTC' as I understand this might not be super intuitive to users and this is definitely a point to improve; however, it would cover a case where multiple users access the same data set, their data would match. |
@kangzj Thank you for sharing a more detailed example. I tried exposing the experimental Could you take a look and let me know if it fulfils your needs? Things to keep in mind for more context:
(@mirka , FYI |
LGTM! Thanks for doing that 👍 |
@garymurray I understand this component is still a necessity for the Woo Analytics project (as per pfKYZu-2M1-p2) - could we get some feedback from the team to ensure it covers all needs? Thanks! |
Yup, thanks for the reminder @tyxla :) |
…ocalization props
e812b27
to
8b2838b
Compare
Now that the general implementation feels stable enough both in terms of design, functionality and APIs, I'm going to merge this PR, and continue to iterate in follow-ups. Planned follow-ups:
|
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/17503189 Some locales (Hebrew) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Hi @ciampo, could you please edit the description of this PR and add a screenshot for our translators? Ideally it'd include all of the following strings:
Thank you in advance! |
Great work with this one @ciampo, happy to see it land 🚀 |
Hey @donaghokeeffe , thank you for sharing more details! The components from this PR focus on proving a calendar UI for date picking in a While components take timezone into account to "localize" date picking (for example, right now it's Friday in Italy, but soon in New Zealand will be Saturday), they don't provide UI for time picking. At the same time, the components accept full date objects, meaning that you should be able to build extra UI for time picking and integrate it with the Calendar UI, as in the screenshot above. I plan on working on a comprehensive Storybook example for a very similar use case. |
timeZone: BaseProps[ 'timeZone' ]; | ||
mode: 'single' | 'range'; | ||
} ) => { | ||
const { __ } = useI18n(); |
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.
Why do we need to use the hook here instead of directly using __()
from the i18n
package?
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.
TL;DR: @wordpress/i18n
is not reactive. So, if you have lazy-loaded components with translations, their translation chunks will be lazy-loaded too. when that happens, @wordpress/i18n
won't trigger rerenders.
@wordpress/react-i18n
is the reactive version that solves that reactivity issue.
Related to DS-201
Proposed Changes
Create new
DateCalendar
andDateRangeCalendar
components based on thereact-day-picker
libraryKapture.2025-05-16.at.17.13.29.mp4
Why are these changes being made?
We need a complete and accessible set of calendar components across A8C
Testing Instructions
yarn workspace @automattic/components run storybook:start
and visit theDateCalendar
andDateRangeCalendar
storiesPre-merge Checklist