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

Adding border to table header & footer #18767 #19136

Closed
wants to merge 5 commits into from
Closed

Adding border to table header & footer #18767 #19136

wants to merge 5 commits into from

Conversation

dmahendrakar
Copy link
Contributor

@dmahendrakar dmahendrakar commented Dec 13, 2019

Description

Added 2px border-bottom to header and border-top to footer. Design suggested by @shaunandrews in #18767
image
Closes #18767.

How has this been tested?

Screenshots

Screen Shot 2019-12-13 at 12 31 52 PM

Screen Shot 2019-12-13 at 12 31 39 PM

Screen Shot 2019-12-13 at 12 31 11 PM

Screen Shot 2019-12-13 at 12 30 54 PM

Types of changes

CSS changes limited to editor view.

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. .

@dmahendrakar
Copy link
Contributor Author

@ajitbohra I see there are no failing tests after after my change. Do you need me to add a snapshot test for table component? I see it's only added in block-library/embed. Is there any reason why snapshot tests are not added pervasively?

@dmahendrakar
Copy link
Contributor Author

@talldan do you have any feedback on this pr?

@shaunandrews
Copy link
Contributor

I like it. I wonder if it would stand out just a little more at 3px?

@dmahendrakar
Copy link
Contributor Author

@shaunandrews this is how it looks 2px vs 3px -
Screen Shot 2019-12-16 at 9 48 33 PM
Screen Shot 2019-12-16 at 9 48 33 PM copy

@talldan
Copy link
Contributor

talldan commented Dec 18, 2019

I tried it out with the Gutenberg Starter Theme (https://github.com/WordPress/gutenberg-starter-theme):
Screen Shot 2019-12-18 at 4 09 31 pm

At the moment the style is only applied in the editor, and I think the styles should be consistent when also viewing the post. @dpkm95 To do that, these styles could be added to the table block's theme.scss file, which should apply to both the editor and the post. That file is generally for slightly more opinionated styles that are optional for themes to use.

@talldan talldan added [Block] Table Affects the Table Block [Type] Enhancement A suggestion for improvement. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Dec 18, 2019
@dmahendrakar
Copy link
Contributor Author

dmahendrakar commented Dec 18, 2019

@talldan thanks for the feedback. Do you like 2px or 3px border? +@shaunandrews.
@talldan I'm facing an issue when I move it to style.scss[0]. In preview & render view the themes/twentytwenty/style.scss loads after block-library/table.style.scss[1], it should be other way around as it is in editor view[2]. Is this done for a reason? If not how to fix it?

[0]Screen Shot 2019-12-18 at 9 22 45 AM

[1] Screen Shot 2019-12-18 at 9 26 27 AM

[2] Screen Shot 2019-12-18 at 9 26 27 AM

@shaunandrews
Copy link
Contributor

Do you like 2px or 3px border?

I have a slight preference for the 3px visually. Maybe others have differing opinions, I'll get more eyes.

@shaunandrews
Copy link
Contributor

A few more people chimed in on Slack — lets go with 3px.

@talldan
Copy link
Contributor

talldan commented Dec 19, 2019

@dpkm95 As mentioned above, this should go in the theme.scss stylesheet, not the style.scss stylesheet.

In terms of Twenty Twenty, it was a surprise to me, but it looks like that theme doesn't support default block styles:
https://developer.wordpress.org/block-editor/developers/themes/theme-support/#default-block-styles

Any changes added to the theme.scss won't be visible when viewing a post in Twenty Twenty. It's up to the theme to add styling as it sees fit.

My recommendation would be to use a different theme to test this feature. Generally a good one to use is the Gutenberg Starter Theme (https://github.com/WordPress/gutenberg-starter-theme), as it's more of a base theme than other themes. You can download it from the repo using the Clone or Download button, and then upload that directly into your dev environment.

Twenty Nineteen also seems to work fine. I also tried a few older themes, but they seem to have border-collapse: separate; specified which stops them showing borders correctly.

@dmahendrakar
Copy link
Contributor Author

@talldan thanks for the clarification, It works for me with gutenberg-starter-theme! I've moved the styles to theme.scss, can you please review the pr.

@talldan
Copy link
Contributor

talldan commented Dec 20, 2019

@dpkm95 Looking good! What do you think about also adding the placeholder text for the header and footer cells as described in this comment - #18767 (comment)?

@dmahendrakar
Copy link
Contributor Author

dmahendrakar commented Dec 21, 2019

I've updated pr with placeholder. Thanks for the review!

This is how it looks @shaunandrews @talldan -
Screen Shot 2019-12-21 at 12 48 10 AM

Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for all your hard work @dpkm95!

Copy link
Member

@Soean Soean left a comment

Choose a reason for hiding this comment

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

The placeholders should be translatable. You can add the translation function like this: __( 'placeholder label' )

@@ -450,6 +450,13 @@ export class TableEdit extends Component {
[ `has-text-align-${ align }` ]: align,
}, 'wp-block-table__cell-content' );

let placeholder = '';
if ( name === 'head' ) {
placeholder = 'Header label';
Copy link
Member

Choose a reason for hiding this comment

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

This string should be translatable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Soean thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

if ( name === 'head' ) {
placeholder = 'Header label';
} else if ( name === 'foot' ) {
placeholder = 'Footer label';
Copy link
Member

Choose a reason for hiding this comment

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

This string should also be translatable.

@dmahendrakar dmahendrakar requested a review from Soean January 6, 2020 22:47
@dmahendrakar
Copy link
Contributor Author

dmahendrakar commented Jan 6, 2020

This looks good to me, thanks for all your hard work @dpkm95!

Thanks @talldan looking forward to add more contributions!

@dmahendrakar
Copy link
Contributor Author

latest pr: #19450 with correct github user & email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Table Affects the Table Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table Block: Further distinguish headers/footers from regular cells
4 participants