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

Polish date-picker component #20824

Merged
merged 5 commits into from
Mar 12, 2020
Merged

Polish date-picker component #20824

merged 5 commits into from
Mar 12, 2020

Conversation

jasmussen
Copy link
Contributor

This PR does a few things:

  1. It refines the buttongroup component slightly. There was a small issue with the button group used for gradient type picking, that this addresses.
  2. It refactors the am/pm selector in the date component to use a ButtonGroup.
  3. It polishes the padding of the datetime picker, closing Date picker has some unexpected styling on borders #20774.

Screens:

Screenshot 2020-03-12 at 11 27 54

Screenshot 2020-03-12 at 11 27 59

Screenshot 2020-03-12 at 11 28 03

Screenshot 2020-03-12 at 11 28 13

@@ -7,6 +7,10 @@
.components-datetime {
padding: $grid-unit-20;

.components-popover__content & {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I recall having a conversation about keeping the padding behavior isolated to the context. But this feels a decent way to tune the behavior. Correct me if I'm wrong, Riad.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well ideally the component works the same in a popover or outside a popover. This is to say it shouldn't have padding IMO but I do remember the same discussion previously and you said that the calendar styles (third-party) kind of forces us to do have that padding somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that was the case due to how the month pagination works. However right at this moment I can't reproduce. Let me try a thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue we had back then does not appear to be an issue anymore, so I've pushed a different fix in c7302b7

And things look right:

Screenshot 2020-03-12 at 12 02 13

Screenshot 2020-03-12 at 12 02 04

@jasmussen
Copy link
Contributor Author

This is the "before":

Screenshot 2020-03-12 at 11 39 04

@github-actions
Copy link

github-actions bot commented Mar 12, 2020

Size Change: -119 B (0%)

Total Size: 864 kB

Filename Size Change
build/components/index.js 191 kB +13 B (0%)
build/components/style-rtl.css 15.5 kB -52 B (0%)
build/components/style.css 15.5 kB -56 B (0%)
build/editor/style-rtl.css 3.97 kB -12 B (0%)
build/editor/style.css 3.96 kB -12 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.01 kB 0 B
build/annotations/index.js 3.43 kB 0 B
build/api-fetch/index.js 3.39 kB 0 B
build/autop/index.js 2.58 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 6.02 kB 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 760 B 0 B
build/block-editor/index.js 104 kB 0 B
build/block-editor/style-rtl.css 10.7 kB 0 B
build/block-editor/style.css 10.7 kB 0 B
build/block-library/editor-rtl.css 7.23 kB 0 B
build/block-library/editor.css 7.24 kB 0 B
build/block-library/index.js 116 kB 0 B
build/block-library/style-rtl.css 7.38 kB 0 B
build/block-library/style.css 7.39 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-default-parser/index.js 1.65 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 57.7 kB 0 B
build/compose/index.js 5.75 kB 0 B
build/core-data/index.js 10.6 kB 0 B
build/data-controls/index.js 1.03 kB 0 B
build/data/index.js 8.22 kB 0 B
build/date/index.js 5.36 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 3.06 kB 0 B
build/edit-post/index.js 91.3 kB 0 B
build/edit-post/style-rtl.css 8.64 kB 0 B
build/edit-post/style.css 8.64 kB 0 B
build/edit-site/index.js 4.64 kB 0 B
build/edit-site/style-rtl.css 2.48 kB 0 B
build/edit-site/style.css 2.48 kB 0 B
build/edit-widgets/index.js 4.44 kB 0 B
build/edit-widgets/style-rtl.css 2.58 kB 0 B
build/edit-widgets/style.css 2.58 kB 0 B
build/editor/editor-styles-rtl.css 381 B 0 B
build/editor/editor-styles.css 382 B 0 B
build/editor/index.js 43.8 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 734 B 0 B
build/format-library/index.js 7.09 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 1.92 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.49 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.3 kB 0 B
build/keycodes/index.js 1.68 kB 0 B
build/list-reusable-blocks/index.js 2.99 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 4.85 kB 0 B
build/notices/index.js 1.57 kB 0 B
build/nux/index.js 3.01 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/primitives/index.js 1.49 kB 0 B
build/priority-queue/index.js 780 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/rich-text/index.js 14.3 kB 0 B
build/server-side-render/index.js 2.55 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4 kB 0 B
build/viewport/index.js 1.61 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

0 0 0 3px $blue-medium-focus;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What's all this red about :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All that red duplicated the rules from the ButtonGroup component. In all my testing they are unnecessary with the refactor to use the actual ButtonGroup (and to toggle the selected button to primary in the ternery). You can recognize the margin-left: -1px from the button group, where it's used to ensure their borders stack. The z-index to ensure focus is uncropped is also there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The border radii for the am/pm buttons are even replaced by first-child/last-child rules in the buttongroup.

@@ -318,24 +319,22 @@ class TimePicker extends Component {
/>
</div>
{ is12Hour && (
<div className="components-datetime__time-field components-datetime__time-field-am-pm">
<ButtonGroup className="components-datetime__time-field components-datetime__time-field-am-pm">
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that's the red thing. Cool to reuse components. 👍

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Nice PR

@jasmussen
Copy link
Contributor Author

Thanks for the review. I see some test failures I have to update.

@jasmussen jasmussen merged commit 3848806 into master Mar 12, 2020
@jasmussen jasmussen deleted the fix/button-group-date-picker branch March 12, 2020 11:42
@github-actions github-actions bot added this to the Gutenberg 7.8 milestone Mar 12, 2020
@paaljoachim
Copy link
Contributor

paaljoachim commented Mar 24, 2020

I just tested...
Clicking the Calendar help link to view the information then clicking outside the box (into empty space) it does not close.

Clicking the close text brings one back to the calendar.
Clicking outside (into empty space) does not close the calendar box.
I had to click the image to exit the calendar.

Date-Picker-screen

@jasmussen

@jasmussen
Copy link
Contributor Author

Indeed, excellent catch. Mind opening a new ticket for that? I don't think it's a result of this PR specifically, but feel free to point to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants