Skip to content

#684 | Add display options to "Event Date" block#1155

Merged
mauteri merged 37 commits intoGatherPress:developfrom
JordanPak:feature/684-event-date-block
Nov 7, 2025
Merged

#684 | Add display options to "Event Date" block#1155
mauteri merged 37 commits intoGatherPress:developfrom
JordanPak:feature/684-event-date-block

Conversation

@JordanPak
Copy link
Copy Markdown
Contributor

Description of the Change

Adds new display options to the gatherpress/event-date block:

  1. "Display" radio control for showing start, end, or both date/time(s)
  2. "Separator" text control for customizing the separator "word" between the start and end dates/times (if both are being displayed)
  3. Conditional text controls for start & end date PHP formatting
  4. Dynamic date removal from end date (leaving only the time) if both the start and end date are the same
  5. Timezone display option, including a default that inherits the plugin setting
image

Closes #684

How to test the Change

Go to an event post and add the "event date" block if it isn't already there. Select the block and change the new attribute inspector controls.

Changelog Entry

Added - Display options for showing start vs end date/time, timezone, date formatting, and "separator"

Credits

@JordanPak

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Aug 9, 2025

PR Summary

  • Enhancements to Block Configuration
    The event date block configuration has been updated, with new settings including the type of display (start and/or end date), the format of the start and the end date, a separator, and the option to show the timezone.

  • Improved Display Logic
    The date and time display has been refined to allow for format customizations, display type selection, and the addition of timezones. Also, unnecessary code was removed to improve efficiency.

  • Integrated New Controls
    New settings for start and end date formats, separator, and timezone display option have been integrated into the block settings user interface.

  • Date Rendering enhancements
    Dates are now rendered in a more user-friendly manner that respects the specified formats and separators.

  • Utility Functions in datetime.js
    Utility functions were added to handle non-time PHP date format characters and remove them from date formats effectively.

@carstingaxion
Copy link
Copy Markdown
Collaborator

carstingaxion commented Aug 12, 2025

This is a cool thing and fun to play around with, thanks for your work @JordanPak !

I wouldn't have believed how much changes where needed, but I like your approach. A first look through your code was ok and seemed well done to me.

The 3 unit tests are easily fixed, I think.
The UI seems a little full now, but I guess you already had plans and I'm open to help if you want.

I tried moving the displaytype selection into the block Toolbar, which also looked ok to me. Have a look.

Bildschirmaufzeichnung.vom.12.08.2025.11.01.21.webm

Or even a little narrower with only two options

Bildschirmaufzeichnung.vom.12.08.2025.16.14.47.webm

One thing I'm quite unsure with, is the wrong date formatting as you can see in the video. I don't know yet if this is a thing comming from your PR or if I messed something up elsewhere.

Comment on lines +303 to +332
<SelectControl
label={__('Show time zone', 'gatherpress')}
value={showTimezone}
options={[
{
label: sprintf(
/* translators: %s: Plugin "show timezone" setting */
__(
'%s (plugin setting)',
'gatherpress'
),
globalShowTimezone
? __('Yes', 'gatherpress')
: __('No', 'gatherpress')
),
value: '',
},
{
label: __('Yes', 'gatherpress'),
value: 'yes',
},
{
label: __('No', 'gatherpress'),
value: 'no',
},
]}
onChange={(value) =>
setAttributes({ showTimezone: value })
}
/>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this could be reduced to two options, while the default from settings will be

  1. shown in one of the labels (like currently) and
  2. define the pre-selected default if nothing is set on the block yet

Having this as only two options would allow to use ToggleControl for that whole thing.

A new ToggleControl could also be moved to the top directly behind the DateTimeRange component, which would bring timezone related settings closer to each other, even coming from different components technically.

Bildschirmaufzeichnung.vom.12.08.2025.11.38.01.webm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @carstingaxion!

I initially wanted it to be a toggle UI, but also wanted to make it possible to inherit the default or override to on or off. Would we be able to do that with a toggle?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not? Or in other words, yes I think so.

Having a default as a separate option seems unnecessary to me. The two options yes and no will already include the default, so the default from settings will become the default for the block.

Like I showed in my demo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@carstingaxion a textbox/toggle is simpler to understand but would make it so the administrator can't choose to have all of the events inherit the setting and allow the existing events to respect it. For example, if the default option is empty/"" to just inherit the value (to display the timezone) from the plugin settings, then the administrator could enable or disable timezone display down the road without having to go back through every existing event post and enable/disable it.

It's a practical feature--the main issue is making it intuitive from a UI standpoint. @mauteri suggested adding some help text below to specify what "plugin settings" means and link to it. We could also think of better words to use instead of "plugin setting".

@carstingaxion
Copy link
Copy Markdown
Collaborator

One thing I'm quite unsure with, is the wrong date formatting as you can see in the video. I don't know yet if this is a thing comming from your PR or if I messed something up elsewhere.

I guess this is related to #920

@carstingaxion
Copy link
Copy Markdown
Collaborator

@JordanPak What do you think about the two variants of bringing the radio control for the display type into the Toolbar in the form of 2 or 3 buttons?

@JordanPak
Copy link
Copy Markdown
Contributor Author

@JordanPak What do you think about the two variants of bringing the radio control for the display type into the Toolbar in the form of 2 or 3 buttons?

I think the two-button setup in the block toolbar is pretty dope. I wonder if anyone won't realize that there's stuff in the block toolbar vs inspector controls, but that's a higher-level issue with the block editor itself. I wonder what everyone else's thoughts are, but I think the toolbar placement with buttons is better than the radios in the inspector controls.

@JordanPak
Copy link
Copy Markdown
Contributor Author

@JordanPak What do you think about the two variants of bringing the radio control for the display type into the Toolbar in the form of 2 or 3 buttons?

I think the two-button setup in the block toolbar is pretty dope. I wonder if anyone won't realize that there's stuff in the block toolbar vs inspector controls, but that's a higher-level issue with the block editor itself. I wonder what everyone else's thoughts are, but I think the toolbar placement with buttons is better than the radios in the inspector controls.

@carstingaxion I'm testing this implementation, but realized something that may or may not be concerning: The date format and separator controls in the inspector are conditional to the start/end/both setting, so if we move that to the toolbar, there's a bit more visual separation between the display setting and the separator + format settings when the display setting is changed, which might make it less intuitive? I'm going to try to present this to the group on Friday to gather a bit more feedback.

@JordanPak JordanPak marked this pull request as ready for review November 3, 2025 13:51
"default": ""
},
"separator": {
"//": "@todo Add this to plugin settings",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@JordanPak I feel like we need to do this now because we have a lot of translated versions of GatherPress and feel the hardcoded to will be problem, or am I misunderstanding something here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mauteri I think that todo was for having the default pull from the plugin settings so it'd be easy to change all of the existing blocks' separators at the same time while also respecting the language used in the setting.

This makes me realize, though, that unless we add extra depth to the setting (which probably wouldn't be ideal), how would would you be able to get one instance of a date block to have no separator unless the proposed setting were empty?


let endFormat = dateFormat + ' ' + timeFormat + ' ' + timezoneFormat;
const parts = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@JordanPak what about something like this for translating the separator?

if ( 'to' === separator ) {
    const translatedSeparator = __( 'to', 'gatherpress');
} else {
    const translatedSeparator = separator;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh rooiiight this'll prolly work @mauteri

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 7, 2025

Preview changes with Playground

You can preview the recent changes for PR#1155 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri merged commit df83e16 into GatherPress:develop Nov 7, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NEW Event Date block

3 participants