-
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
Add table dimension controls #9801
Conversation
A couple of things I'm undecided on with this PR:
|
Hey @jasmussen - This min-width style causes some issues when if I try to set the table width to a value less than it:
Do you have any ideas on the right way to resolve that? Thanks! |
This is very cool! Really nice work.
Sigh, creating responsive tables is a dang headache. We need some kind of min-width. We could make it optional, like a switch in the inspector. We could even combine the "fixed-width cells" so it's sometning like "Responsive table with fixed-width table cells". Something in that vein. The other option is to simply accept it as is — what are the use cases for a table that is smaller than 240px? |
As a general rule, this way to build translatable strings: On a side note, I've seen there are other places in the codebase where similar concatenation is used and they all should be reviewed. Best practices for variables in translation strings: https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#variables |
<TextControl | ||
type="number" | ||
className="block-library-table__dimensions__width" | ||
label={ widthUnit ? `${ __( 'Width' ) } (${ widthUnit })` : __( 'Width' ) } |
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 would move this ternary out of the component itself and put it in a variable above, to improve readability. Because this line is quite intended, it'll be easier to read above.
As @afercia mentioned, this won't work for l10n because it assumes English order/characters for this string. Instead, you'll want:
import { __, sprintf } from '@wordpress/i18n';
// […]
const widthLabel = widthUnit ? sprintf( __( 'Width (%s)' ), widthUnit ) : __( 'Width' );
<TextControl
label={ widthLabel }
/>
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.
Thanks both of you for catching that - not sure why my brain blipped on using sprintf
. Pushed a commit to fix it.
de9e257
to
88f0cfa
Compare
88f0cfa
to
10b6ad5
Compare
Thanks for working on this. Let me know if you need a hand. |
@jasmussen Cheers for the offer - I've decided to move the fix for #9779 to a separate PR (#10011), as this is getting quite big. Would be great if you could take a look at it. 😄 Once that's merged I can squish this down a bit. |
I think with the comment by @jasmussen we can remove the design feedback label on this as it's in progress. Let's add back in though if we need to. |
dac5dbb
to
545b935
Compare
545b935
to
b842054
Compare
This reverts commit f5338ed.
…t outside of the contenteditable
b842054
to
1bc9a23
Compare
This PR became stale, @talldan do you plan to refresh this PR? |
@gziolo I'll close this and follow up with a different approach. Some background—I realised some way through that what I was trying here with the Potential solutions:
|
Description
Fixes #9327
Fixes #9114
Fixes #8325
Related #6923
This PR adds width and height controls to the table block. Summarised:
How has this been tested?
master
, saving and loading post on this branch.Screenshots
Using width/height controls
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: