-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Experiment: Add dynamic time to comment date with interactivity api #49955
Conversation
Size Change: +8 B (0%) Total Size: 1.36 MB
ℹ️ View Unchanged
|
Flaky tests detected in 67afc66. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4754180568
|
@dmsnell suggested a different (and simpler) approach; don't include the whole
Up to this point, decide whether to make it dynamic also for times > 1 hour. If so, also include something like:
The rest doesn’t need to be dynamic as it’d never be updated in the client. |
My only note here is that for the functionality that requires many highly dynamic translations, the usage of |
Closing this PR as it was just meant to be an experiment. It can always be reopened/reused in the future. |
Co-authored with @gziolo
What?
Experiment using the Interactivity API to update the time that has passed since a comment was submitted.
The Interactivity API is an experimental API to add frontend interactivity to blocks. More info in this post and in GitHub
Why?
To see what is needed to integrate this use case.
How?
This branch is on top of the Experiment: use the Interactivity API to do client-side form submissions for practical reasons.
Before explaining how this was implemented, some considerations we had in mind:
How we implemented this:
get_comment_time() function
indata-wp-context
.data-wp-init
directive and triggereffects.core.checkDiff
, which runs a function namedmakeTheUpdate
with asetTimeOut
depending if it is seconds, minutes, or hours.makeTheUpdate
function to change the time diff and the text depending on if it is seconds, mins, or hours. That information is stored in thecontext
.data-wp-text
to show the time difference updated bymakeTheUpdate
.@wordpress/i18n
package to handle the translations. We are aware this package is not intended for the frontend, but it was enough for this experiment.And here you have a video with the demo and some explanations:
https://www.loom.com/share/e42ba81012454640ad239c63c5c25523