-
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
Polish the Table block #6314
Polish the Table block #6314
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I was working on thxis as you did some "is-selected" work, that I may have messed up in a rebase.
All good with isSelected
:)
I left a few other comments to consider.
blocks/library/table/index.js
Outdated
{ | ||
'has-fixed-layout': hasFixedLayout, | ||
}, | ||
align ? `align${ align }` : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align ?
align${ align } : null,
can be moved to the object as follows:
{
'has-fixed-layout': hasFixedLayout,
[ `align${ align }` ]: align,
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 👍
blocks/library/table/editor.scss
Outdated
} | ||
} | ||
|
||
// Style the resize handles | ||
.ephox-snooker-resizer-rows { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those names look alien, is there any way to make them look as WordPress internals? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid those are from deep within the core of the TinyMCE library, so we can't change them unless we change those core files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds okey, I had to double check :)
blocks/library/table/index.js
Outdated
PanelBody, | ||
ToggleControl, | ||
} from '@wordpress/components'; | ||
import classnames from 'classnames'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classnames
is an external dependency.
blocks/library/table/index.js
Outdated
@@ -32,14 +38,18 @@ export const settings = { | |||
selector: 'table', | |||
default: [ | |||
<tbody key="1"> | |||
<tr><td><br /></td><td><br /></td></tr> | |||
<tr><td><br /></td><td><br /></td></tr> | |||
<tr><td><br /></td><td><br /></td><td><br /></td></tr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it for testing or do we plan to change the default table layout to to 3x2?
blocks/library/table/index.js
Outdated
@@ -69,22 +90,40 @@ export const settings = { | |||
onChange={ updateAlignment } | |||
/> | |||
</BlockControls> | |||
<InspectorControls> | |||
<PanelBody title={ __( 'Table Settings' ) } className="blocks-table-settings"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the coding styles we follow this className
should be blocks-table__settings
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.
Rebased. |
fc05085
to
6aa1ad5
Compare
Rebased and squashed. I think this is ready for final review. |
I'd agree Gutenberg shouldn't try to make the table responsive, that's not its responsibility. More importantly, altering the CSS |
Yep, that was one of the reasons I threw in the towel on any responsiveness other than horizontal scrolling. I think there could be a place for a "Responsive Table" block, that's built from the start to let you insert tabular data in a transforming way. But alas, it's not this block. |
Nice. For that future block, take into consideration @aardrian has experimented a lot with responsive, accessible, tables ;) |
Definitely — though I think that's likely going to be plugin territory for the near future/v1. |
It's not always working properly with all those dimension styles applied: I pushed a commit which fixes the failing fixture test: 77bf6ce. It looks like it also needs to be rebased. Doing it now. |
Going to rebase when we decide on #6739 (comment) |
This branch is based off of `try/better-responsive-table`, but without my attempt at better responsiveness. - New toggle to decide whether table has fixed widths, off by default, as discussed in #2620 - Surface and style the resizing tool
Rebased. I think this is ready for final approval. What do you think, @gziolo ? |
|
||
.ephox-snooker-resizer-bar-dragging { | ||
background: $blue-medium-500; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an empty line here :)
core-blocks/table/index.js
Outdated
isSelected={ isSelected } | ||
/> | ||
</Fragment> | ||
); | ||
}, | ||
|
||
save( { attributes } ) { | ||
const { content, align } = attributes; | ||
save( { attributes, className } ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no className prop passed to the save
callback we should just remove it, it will be added automatically.
Looks good to me, left some small comments, Let's merge once resolved. |
Thanks, @youknowriad for the review. I addressed it. However, I'm seeing an issue with saving and publishing. I don't know if I messed somethign up in the rebase, but the table isn't being saved, looks like :( any idea what's up? Try to create a table in this branch, save, preview, or save and publish. It's not working |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Yaay thank you! |
} | ||
} | ||
|
||
// Style the resize handles | ||
.ephox-snooker-resizer-rows { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these styles be applied only within the context of the table block? As implemented, these will impact any table on the screen, regardless of within the block. Even if they're desirable globally, I don't think the styles should be implemented here (since a block's styles shouldn't be impacting the page as a whole).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I could scope these to be table block specific only. However these elements are inserted into the root of the DOM.
I can move them to the main stylesheet if you like?
This branch is based off of
try/better-responsive-table
, but without my attempt at better responsiveness.In that other branch I tried desperately to build in a responsive table feature, but it just doesn't seem possible to do in a good way that works for every WordPress theme out there. Stacking is fine, but if we can't stack as columns, you'll just end up with a mishmash of out of context rows. If we truly want a responsive table, we have to write a new one in Flexbox from the start :(
CC: @gziolo because I was working on thxis as you did some "is-selected" work, that I may have messed up in a rebase.
GIF: