-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge branch 'master' into rnmobile/fix-title-no-focus
- Loading branch information
Showing
117 changed files
with
3,125 additions
and
2,150 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { omit } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { RichText } from '@wordpress/block-editor'; | ||
|
||
const colorsMigration = ( attributes ) => { | ||
return omit( { | ||
...attributes, | ||
customTextColor: attributes.textColor && '#' === attributes.textColor[ 0 ] ? attributes.textColor : undefined, | ||
customBackgroundColor: attributes.color && '#' === attributes.color[ 0 ] ? attributes.color : undefined, | ||
}, [ 'color', 'textColor' ] ); | ||
}; | ||
|
||
const blockAttributes = { | ||
url: { | ||
type: 'string', | ||
source: 'attribute', | ||
selector: 'a', | ||
attribute: 'href', | ||
}, | ||
title: { | ||
type: 'string', | ||
source: 'attribute', | ||
selector: 'a', | ||
attribute: 'title', | ||
}, | ||
text: { | ||
type: 'string', | ||
source: 'html', | ||
selector: 'a', | ||
}, | ||
}; | ||
|
||
const deprecated = [ | ||
{ | ||
attributes: { | ||
...blockAttributes, | ||
color: { | ||
type: 'string', | ||
}, | ||
textColor: { | ||
type: 'string', | ||
}, | ||
align: { | ||
type: 'string', | ||
default: 'none', | ||
}, | ||
}, | ||
save( { attributes } ) { | ||
const { url, text, title, align, color, textColor } = attributes; | ||
|
||
const buttonStyle = { | ||
backgroundColor: color, | ||
color: textColor, | ||
}; | ||
|
||
const linkClass = 'wp-block-button__link'; | ||
|
||
return ( | ||
<div className={ `align${ align }` }> | ||
<RichText.Content | ||
tagName="a" | ||
className={ linkClass } | ||
href={ url } | ||
title={ title } | ||
style={ buttonStyle } | ||
value={ text } | ||
/> | ||
</div> | ||
); | ||
}, | ||
migrate: colorsMigration, | ||
}, | ||
{ | ||
attributes: { | ||
...blockAttributes, | ||
color: { | ||
type: 'string', | ||
}, | ||
textColor: { | ||
type: 'string', | ||
}, | ||
align: { | ||
type: 'string', | ||
default: 'none', | ||
}, | ||
}, | ||
save( { attributes } ) { | ||
const { url, text, title, align, color, textColor } = attributes; | ||
|
||
return ( | ||
<div className={ `align${ align }` } style={ { backgroundColor: color } }> | ||
<RichText.Content | ||
tagName="a" | ||
href={ url } | ||
title={ title } | ||
style={ { color: textColor } } | ||
value={ text } | ||
/> | ||
</div> | ||
); | ||
}, | ||
migrate: colorsMigration, | ||
}, | ||
]; | ||
|
||
export default deprecated; |
Oops, something went wrong.