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

Block Library: Add features to the Post Date block. #19857

Merged
merged 3 commits into from
Feb 24, 2020

Conversation

epiqueras
Copy link
Contributor

Closes #19697

Description

This PR implements the design from #19697.

How to test this?

Verify all the features from #19697 work as expected with a Post Date block inserted in a regular post.

Screenshots

Screen Shot 2020-01-23 at 8 57 45 PM

Types of Changes

New Feature: The Post Date block now has a more rich editing experience and allows you to customize the block-specific date format directly.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@shaunandrews
Copy link
Contributor

The pencil icon leaves a lot to be desired. Its not at all obvious, and actually seems to imply "change" or "edit" — not "format". Maybe we can replace it with a label:

image

I wish there was more control over the date and time formatting. Combining them both into a single selection reduces the control — or, if we add more, requires more options to provide more control. If we were to separate the formatting we could offer more control without having to list a dozen different combinations:

image

I found it jarring at first that selecting the block instantly shows the calendar to change the date. I wasn't expecting it, and I didn't really understand why that control was showing. Part of me thinks it should be something more intentional, like a "change" button in the toolbar:

image

@epiqueras
Copy link
Contributor Author

epiqueras commented Feb 14, 2020 via email

@shaunandrews
Copy link
Contributor

Sure, I can see how translations could cause troubles here. But I also don't think a pencil icon is a good way to indicate "change the date and time formatting". I'm not sure such an icon exists.

We had a similar problem for the Image block, and ended up going with a "Replace" label after trying a handful of different icons.

@epiqueras
Copy link
Contributor Author

epiqueras commented Feb 14, 2020 via email

@shaunandrews
Copy link
Contributor

calendar icon with some sort of pencil/tool

The block icon itself is already a calendar, and I worry about the repetition. Also, would this icon be for changing the date/time formatting, or editing the date of the post?

Here's a few quick variations of the calendar, pencil, and clock icons:

image

I don't think any of them are better or more obvious that using a label for the formatting. Generally, combining multiple icons at such a small size is not recommended — both icons tend to lose their "shape" and become unrecognizable.

I could, however, see the pencil icon working for changing the date of the post.

image

@epiqueras
Copy link
Contributor Author

epiqueras commented Feb 14, 2020 via email

</Popover>
) }
<BlockControls>
<ToolbarGroup
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the format is changed often enough to warrant a placement in the toolbar. It could be just an inspector control.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@epiqueras
Copy link
Contributor Author

I've refactored the opening of the calendar popover so that it now opens through a pencil icon on the toolbar.

I also moved the format dropdown to the inspector. This solves the icon problem for now.

@shaunandrews I think this is ready to go.

@github-actions
Copy link

Size Change: +5.86 kB (0%)

Total Size: 864 kB

Filename Size Change
build/annotations/index.js 3.43 kB -3 B (0%)
build/api-fetch/index.js 3.39 kB +1 B
build/autop/index.js 2.58 kB -1 B
build/block-directory/index.js 6.02 kB -1 B
build/block-editor/index.js 104 kB +132 B (0%)
build/block-library/editor-rtl.css 7.67 kB +27 B (0%)
build/block-library/editor.css 7.67 kB +29 B (0%)
build/block-library/index.js 114 kB +2.78 kB (2%)
build/block-serialization-default-parser/index.js 1.65 kB -1 B
build/blocks/index.js 57.6 kB +4 B (0%)
build/components/index.js 190 kB +154 B (0%)
build/components/style-rtl.css 16.1 kB +1 B
build/components/style.css 16 kB +6 B (0%)
build/core-data/index.js 10.5 kB +30 B (0%)
build/data-controls/index.js 1.04 kB -3 B (0%)
build/data/index.js 8.22 kB -4 B (0%)
build/date/index.js 5.36 kB +1 B
build/dom-ready/index.js 569 B +1 B
build/edit-post/index.js 90.7 kB +139 B (0%)
build/edit-post/style-rtl.css 8.7 kB +14 B (0%)
build/edit-post/style.css 8.69 kB +13 B (0%)
build/edit-site/index.js 4.58 kB +1.87 kB (40%) 🚨
build/edit-site/style-rtl.css 2.77 kB +149 B (5%) 🔍
build/edit-site/style.css 2.76 kB +147 B (5%) 🔍
build/edit-widgets/index.js 4.36 kB +3 B (0%)
build/editor/index.js 45.1 kB -23 B (0%)
build/element/index.js 4.45 kB -1 B
build/format-library/index.js 7.6 kB +89 B (1%)
build/hooks/index.js 1.92 kB -1 B
build/html-entities/index.js 621 B -1 B
build/i18n/index.js 3.45 kB -1 B
build/keyboard-shortcuts/index.js 2.3 kB -6 B (0%)
build/keycodes/index.js 1.68 kB -1 B
build/media-utils/index.js 4.85 kB +12 B (0%)
build/notices/index.js 1.57 kB -1 B
build/nux/index.js 3.02 kB +3 B (0%)
build/plugins/index.js 2.54 kB +302 B (11%) ⚠️
build/primitives/index.js 1.49 kB -2 B (0%)
build/redux-routine/index.js 2.84 kB -3 B (0%)
build/rich-text/index.js 14.3 kB -1 B
build/token-list/index.js 1.27 kB +1 B
build/url/index.js 4 kB +1 B
build/viewport/index.js 1.61 kB +2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.01 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 760 B 0 B
build/block-editor/style-rtl.css 9.78 kB 0 B
build/block-editor/style.css 9.77 kB 0 B
build/block-library/style-rtl.css 7.47 kB 0 B
build/block-library/style.css 7.48 kB 0 B
build/block-library/theme-rtl.css 669 B 0 B
build/block-library/theme.css 671 B 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/compose/index.js 5.76 kB 0 B
build/deprecated/index.js 771 B 0 B
build/dom/index.js 3.06 kB 0 B
build/edit-widgets/style-rtl.css 2.8 kB 0 B
build/edit-widgets/style.css 2.79 kB 0 B
build/editor/editor-styles-rtl.css 327 B 0 B
build/editor/editor-styles.css 328 B 0 B
build/editor/style-rtl.css 4.13 kB 0 B
build/editor/style.css 4.11 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 500 B 0 B
build/format-library/style.css 501 B 0 B
build/is-shallow-equal/index.js 711 B 0 B
build/list-reusable-blocks/index.js 2.99 kB 0 B
build/list-reusable-blocks/style-rtl.css 215 B 0 B
build/list-reusable-blocks/style.css 216 B 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/priority-queue/index.js 878 B 0 B
build/server-side-render/index.js 2.54 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Date/time selection seems to work, but I'm not sure how to change the format:

post-date

Edit: Ohhh, it's mentioned here: #19857 (comment)

I also moved the format dropdown to the inspector.

Will test the format now.

@ockham
Copy link
Contributor

ockham commented Feb 24, 2020

This works, but I find the split (data/time selection via block toolbar, format selection via block inspector) rather unintuitive, esp for a block that basically has only those two customization options 🤔

post-date2

I think from a user's POV, it begs the question, why aren't both options in the same place?

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Code-wise, this is looking good.

I have some UI concerns, but it's probably okay to address those in a future iteration.

@mtias
Copy link
Member

mtias commented Feb 24, 2020

We should avoid the pencil as the "edit" icon.

@epiqueras epiqueras merged commit e0c9aa5 into master Feb 24, 2020
@epiqueras epiqueras deleted the add/post-date-block-features branch February 24, 2020 15:31
@youknowriad youknowriad modified the milestones: Future, Gutenberg 7.6 Feb 26, 2020
@ellatrix ellatrix mentioned this pull request Jun 16, 2020
12 tasks
Comment on lines +25 to +31
const is12Hour = /a(?!\\)/i.test(
settings.formats.time
.toLowerCase() // Test only for the lower case "a".
.replace( /\\\\/g, '' ) // Replace "//" with empty strings.
.split( '' )
.reverse()
.join( '' ) // Reverse the string and test for "a" not followed by a slash.
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Why reverse the string and not use a non-capturing group like /(?:[^\\])a/?
  • If the RegExp already has the i flag, why pipe through .toLowerCase?

Copy link
Contributor

Choose a reason for hiding this comment

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

I now see that the original occurrence came with 256badd, three years ago, so ignore this message.

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 Block: Post Date
6 participants