-
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
Use UnitControl
instead of RangeControl
for column width
#24711
Merged
aristath
merged 25 commits into
WordPress:master
from
aristath:aristath/try-column-width
Sep 29, 2020
Merged
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
770886d
allow using custom units in columns
aristath 0e5c3b0
tweak the variations
aristath 8d61839
Fix deprecation
aristath dc3b8b7
Add rudimentary units validation
aristath 79d9d25
add extra check for css-var
aristath 770f0c6
shorter is better here
aristath 47552bb
Merge branch 'master' into aristath/try-column-width
aristath 4f89115
Merge branch 'master' into aristath/try-column-width
aristath d89af25
Switch to using the new UnitControl
aristath cdafd79
Merge branch 'master' into aristath/try-column-width
aristath 7968226
Merge branch 'master' into aristath/try-column-width
aristath f40bdbd
Update packages/block-library/src/column/deprecated.js
aristath c387ce7
Merge remote-tracking branch 'aristath/aristath/try-column-width' int…
aristath e7050cb
add whitespace
aristath c33b23c
tweak migration according to the review
aristath 0c852a2
simplify width check
aristath 3e4a3a8
Merge branch 'master' into aristath/try-column-width
aristath 6f00325
Don't allow negative numbers
aristath 7b3c938
Merge branch 'master' into aristath/try-column-width
aristath 48adbb0
Update implementation to fix merge conflict
aristath 9c22eab
Change labelPosition to "side"
aristath e977fda
change labelPosition to edge
aristath 1f6a2af
Merge branch 'master' into aristath/try-column-width
aristath 8ad0e20
Adjust label x control width for UnitControl in Column (edit)
8310377
Update snapshot test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
const deprecated = [ | ||
{ | ||
attributes: { | ||
verticalAlignment: { | ||
type: 'string', | ||
}, | ||
width: { | ||
type: 'number', | ||
min: 0, | ||
max: 100, | ||
}, | ||
}, | ||
isEligible( attributes ) { | ||
aristath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return attributes.width && 'string' !== typeof attributes.width; | ||
}, | ||
save( { attributes } ) { | ||
attributes.width = attributes.width.toString() + '%'; | ||
aristath marked this conversation as resolved.
Show resolved
Hide resolved
aristath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { verticalAlignment, width } = attributes; | ||
|
||
const wrapperClasses = classnames( { | ||
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment, | ||
} ); | ||
|
||
let style; | ||
if ( width ) { | ||
style = { flexBasis: width }; | ||
} | ||
|
||
return ( | ||
<div className={ wrapperClasses } style={ style }> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
attributes: { | ||
aristath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
verticalAlignment: { | ||
type: 'string', | ||
}, | ||
width: { | ||
type: 'string', | ||
}, | ||
}, | ||
isEligible( attributes ) { | ||
return attributes.width && ! isNaN( attributes.width ); | ||
}, | ||
migrate( attributes ) { | ||
return { | ||
...attributes, | ||
width: `${ attributes.width }%`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tellthemachines, @ntsekouras - this one might need |
||
}; | ||
}, | ||
save( { attributes } ) { | ||
const { verticalAlignment, width } = attributes; | ||
|
||
const wrapperClasses = classnames( { | ||
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment, | ||
} ); | ||
|
||
let style; | ||
if ( width ) { | ||
style = { flexBasis: width }; | ||
} | ||
|
||
return ( | ||
<div className={ wrapperClasses } style={ style }> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
export default deprecated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It also creates some issues when adding a new column because it still uses number values. See #27756.