-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[WIP] Updates to the CalendarDay field #2922
Conversation
💥 No ChangesetLatest commit: 2664c8c Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
FTR, I'm not sure in hindsight that the Material day picker was a great idea. It kinda clashed theme-wise with Arch, and it runs the risk of making everything look too much like generic Android. Regarding Definitely 👍 on date range replacing year range. |
Proposal 1 - DoneAdd two new config options,
This proposal would replace the |
Proposal 2 -
|
Proposal 3 - DoneUpdate the Note: Arch component not used and can be deprecated |
Ahhh, that |
Proposal 4 -
|
Proposal 5Rename the current Update: Alternate proposals:
|
Should this be moved to |
another improvementalso remove use of |
@timleslie I like all these proposals (except for 4). I don't think we need to provide different options for incoming or out going dates in graphQL. If we say graphQL queries accept and provide ISO860 format, I think this is much clearer and easier for users to work with. It's easy to implement a format options on the client to make sure this is in the format you want you want and it simplifies our work as well as potentially saving people from a mess of handling multiple different in one application. |
My brain dump... Re: Proposal 1 - From/To Validation Range
Yep, this all sound great. Some ideas:
I'm not invested in either of these ^^ ideas, just throwing them in the mix. Re: Proposal 4 - Server-Side Formatting
To me, applying formatting to a date is about getting it ready for human consumption. This doesn't seem like something that should be part of a data API like GraphQL. One of the issues is how consistent we want If you're formatting a a UTC datetime for someone and not accounting for time zones and localisation, you're doing it wrong. And to what benefit? There are a few use case I can think of where this would be helpful:
Am I'm missing others? My question is, would we ever want to build out server-side formatting for the Then, if the answer is "no" (and I suspect it is) then would be want add this functionality to just the Again, I suspect the answer is "no". It's not quite as complex as datetimes as we can ignore time zones but..
TL:DR; Supporting this well and constantly will be a lot of work for little gain. Besides, formatting data for human consumption is the browsers job. (Ps. If we did support this, don't miss the naming discussing in #2702.) Re: Proposal 5 - Admin FormatYep, this is useful as config for the Admin UI but, as as @gautamsi notes, it should probably be in Re: The RestProposals 2 and 3 sound good to me. |
I propose we use the standard |
I'm not such a fan of this. It makes our API more complex and it introduces an element of magic. If I stumble across someone else's config and it says |
988a8c8
to
6b22d57
Compare
I'm +1 for a ✅ The bundle size issue is quite bad. If I can remove libs like |
@jesstelford |
In support of a
This is generated after running an ISO8086 datestring through this function:
The warning arises because it is run on both server-side and client side. Even on the same computer, there are differences between how the browser formats the date, and how node formats it. If I could normalise that so it is only ever run in the server (ie; the GraphQL resolver), I would not get such warnings. Note that this isn't only a console warning, it also causes a flash of wrong content (ie; it shows the node.js version on page load, but after the first client render, it shows the browser version). That's bad. |
That was actually what gave me the idea for #2702. The date formatting functionality is already there, it's just a matter of exposing it. Otherwise, you end up with the end user having to add a date lib dependency just to format potentially just one date string 😬 |
Re: prop 4I think the bundle size argument is a particularly compelling argument for this prop. An important question to ask is: can the user get server-side-formatted dates using some other mechanism? I put together the following example using the
Caveat: The I think this pattern is a simple enough mechanism for devs to implement (I'd happily write up a guide on how to do this for the docs) and it allows them the flexibility to make their implementation as simple/complex as they need/want, allows them to pick their formatting library of choice, etc, etc. I think overall handing over these decisions to the dev is a better solution than us trying to make a one size fits all API. |
Re: server-side formatting, cont. Bundle size is important, but remember, for this to actually be a win all date times used in the app (or on a page?) need to be loaded through GraphQL. If you're doing anything else with dates other than loading them from Keystone, you're going to need in-browser formatting capacity. All that's going to happen is, people will start building an app using the server-side Plus, we're talking about 17.5 Kb for the whole of
So, given..
Is it really worth considering? The saving grace here is that, yes, it is "purely additional" at an API level and, yes, we can actually solve the entire problem well if we choose to. Formatting like this will be convenient for some small number of apps and, maybe more importantly, it demo's well. It's good for the "first sprint" (I guess). So yeah, I think it's a bad idea but at having it isn't going to create serious problems. |
RE removing moment and luxon, there's |
ff05c42
to
0dd0160
Compare
0dd0160
to
6ede92a
Compare
Did a little spike on adding functions to dayTo/From ... had to revert because of course you can't pass functions across the webpack barrier. This kinda sucks because the most common Proposal 6: Solve this |
6ede92a
to
54c615e
Compare
5219b4c
to
0d17ea5
Compare
0d17ea5
to
ab54ea9
Compare
Ok I've gone through all this work and I'm pretty sure this PR has run it's course... Proposals 1-4 have been implemented. No graphQL formatting yet but I like Tim's suggestions of using the virtual field. Re: 5. - Admin format is contentious in terms of how it should be implemented and definitely not essential, not to be solved here. Re: 6 - Also not to be solved here. |
This PR is a bit of a mixed bag to make general improvements to the
CalandarDay
field type.I'll probably break it into multiple smaller PRs as it comes together and we find answers to some open questions.
The docs for this field type need a bit of work and there are a few open questions around the API which need to be clarified.
Things to consider:
format
only applies to the adminUI. Do we want to have this somehow apply to the graphQL API as well? ( Added aformat
argument to CalendarDay GraphQL queries #2702,yearRangeFrom
andyearRangeTo
only apply to the adminUI. Do we want to apply validation at the graphQL layer as well? This would probably required date from/to rather than year from/to. Probably would want to be a half-open range I guess [from, to).Field
view component, based onTextDayPicker
doing what we want? Do we want to be able to configure it more? How easy is it for someone to use a different component here if they want?Filter
component uses ISO8601 formatting, rather than theformat
config value used in theField
component. Is this correct?Need to make sure we fix #2748, #2565, #2366
Should also consider #1136
Should look into #215 and see if there's anything useful left in that issue that we still need to address. Joss makes a good comment in here: #215 (comment) that we should probably wait for
react-day-picker
v8 before launching into any serious UI work.Loads of interesting related work in #1965.
2.x
. This will be a breaking change, as they changed their format string handling completely.{ from, to }
API for date range restriction.