Repository navigation
Add experimental font size attribute to Navigation block #24531
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,6 @@ import { | |
| InnerBlocks, | ||
| InspectorControls, | ||
| BlockControls, | ||
| FontSizePicker, | ||
| withFontSizes, | ||
| __experimentalUseColors, | ||
| __experimentalBlock as Block, | ||
| } from '@wordpress/block-editor'; | ||
|
|
@@ -39,20 +37,17 @@ function Navigation( { | |
| selectedBlockHasDescendants, | ||
| attributes, | ||
| clientId, | ||
| fontSize, | ||
| hasExistingNavItems, | ||
| isImmediateParentOfSelectedBlock, | ||
| isSelected, | ||
| setAttributes, | ||
| setFontSize, | ||
| updateInnerBlocks, | ||
| className, | ||
| } ) { | ||
| // | ||
| // HOOKS | ||
| // | ||
| const ref = useRef(); | ||
|
|
||
| const { selectBlock } = useDispatch( 'core/block-editor' ); | ||
| const { TextColor, BackgroundColor, ColorPanel } = __experimentalUseColors( | ||
| [ | ||
|
|
@@ -64,15 +59,13 @@ function Navigation( { | |
| { | ||
| backgroundColor: true, | ||
| textColor: true, | ||
| fontSize: fontSize.size, | ||
|
Contributor
Author
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. With this new setup, how can we pass the font size value to the color panel contrast checker? I noticed that
Member
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. Hi @tellthemachines, good point. It seems currently for paragraph and heading we are not passing fontSize related information so the checker always assumes the font size is small. I verified gutenberg/packages/block-editor/src/hooks/color-panel.js is retrieving the colors from the dom, I guess it can easily be enhanced to also retrieve the font size in a separate PR.
Contributor
Author
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. Cool, is this mentioned in any existing issue or shall I create a new one?
Member
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. I am not aware of an issue for it so I guess we should create a new one.
Contributor
Author
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. Done: #24607 |
||
| }, | ||
| ], | ||
| colorDetector: { targetRef: ref }, | ||
| colorPanelProps: { | ||
| initialOpen: true, | ||
| }, | ||
| }, | ||
| [ fontSize.size ] | ||
| } | ||
| ); | ||
|
|
||
| const { navigatorToolbarButton, navigatorModal } = useBlockNavigator( | ||
|
|
@@ -109,13 +102,8 @@ function Navigation( { | |
| ); | ||
| } | ||
|
|
||
| const blockInlineStyles = { | ||
| fontSize: fontSize.size ? fontSize.size + 'px' : undefined, | ||
| }; | ||
|
|
||
| const blockClassNames = classnames( className, { | ||
| [ `items-justified-${ attributes.itemsJustification }` ]: attributes.itemsJustification, | ||
| [ fontSize.class ]: fontSize.class, | ||
| 'is-vertical': attributes.orientation === 'vertical', | ||
| } ); | ||
|
|
||
|
|
@@ -166,14 +154,6 @@ function Navigation( { | |
| </BlockColorsStyleSelector> | ||
| </BlockControls> | ||
| { navigatorModal } | ||
| <InspectorControls> | ||
| <PanelBody title={ __( 'Text settings' ) }> | ||
| <FontSizePicker | ||
| value={ fontSize.size } | ||
| onChange={ setFontSize } | ||
| /> | ||
| </PanelBody> | ||
| </InspectorControls> | ||
| <InspectorControls> | ||
| <PanelBody title={ __( 'Display settings' ) }> | ||
| <ToggleControl | ||
|
|
@@ -187,10 +167,7 @@ function Navigation( { | |
| </InspectorControls> | ||
| <TextColor> | ||
| <BackgroundColor> | ||
| <Block.nav | ||
| className={ blockClassNames } | ||
| style={ blockInlineStyles } | ||
| > | ||
| <Block.nav className={ blockClassNames }> | ||
| <InnerBlocks | ||
| ref={ ref } | ||
| allowedBlocks={ [ | ||
|
|
@@ -227,7 +204,6 @@ function Navigation( { | |
| } | ||
|
|
||
| export default compose( [ | ||
| withFontSizes( 'fontSize' ), | ||
| withSelect( ( select, { clientId } ) => { | ||
| const innerBlocks = select( 'core/block-editor' ).getBlocks( clientId ); | ||
| const { | ||
|
|
||
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 we remove the fontSize attribute from block.json as we did for paragraph?