-
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.
NavigationLink: improve colors handling (#20022)
* block-editor: add getColorObjectByColorSlug() * navigation-link: get color from slug or value * navigation-link: rename prop to improve reading * navigation: remove stuff about rgb block attrs * navigation-link: replace getting rgb color values * navigation: fixing linting errors * minor doc improvements * navigation-link: fix default colors value * block-editor: add getColors() selector * block-editor: add getColorObjectByColorSlug() * block-editor: remove colors helper function * navigation-edit: refact using selectors * navigation-link: set nav colors as single props * docs: add getColorObjectByColorSlug() selector doc * navigation: handling deprecated attrs * navigation: adding support to deprecated * navigation: handling deprecated in server side * navigation: fixing linting errors * navigation-link: remove wrong comment * navigation: fix typo in file name * navigation: getting rbg color with local fn * block-editor: remove color selectors * navigation: simplify deprecated in server-side * navigation: swtich commenting block using * * navigation-link: avoid abbreviations in var name
- Loading branch information
Showing
5 changed files
with
149 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { omit } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
export default [ | ||
{ | ||
attributes: { | ||
className: { | ||
type: 'string', | ||
}, | ||
textColor: { | ||
type: 'string', | ||
}, | ||
rgbTextColor: { | ||
type: 'string', | ||
}, | ||
backgroundColor: { | ||
type: 'string', | ||
}, | ||
rgbBackgroundColor: { | ||
type: 'string', | ||
}, | ||
fontSize: { | ||
type: 'string', | ||
}, | ||
customFontSize: { | ||
type: 'number', | ||
}, | ||
itemsJustification: { | ||
type: 'string', | ||
}, | ||
showSubmenuIcon: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
isEligible( attribute ) { | ||
return attribute.rgbTextColor || attribute.rgbBackgroundColor; | ||
}, | ||
supports: { | ||
align: [ 'wide', 'full' ], | ||
anchor: true, | ||
html: false, | ||
inserter: true, | ||
}, | ||
migrate( attributes ) { | ||
return { | ||
...omit( attributes, [ 'rgbTextColor', 'rgbBackgroundColor' ] ), | ||
customTextColor: attributes.textColor | ||
? undefined | ||
: attributes.rgbTextColor, | ||
customBackgroundColor: attributes.backgroundColor | ||
? undefined | ||
: attributes.rgbBackgroundColor, | ||
}; | ||
}, | ||
save() { | ||
return <InnerBlocks.Content />; | ||
}, | ||
}, | ||
]; |
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