Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions packages/block-library/src/navigation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
"rgbBackgroundColor": {
"type": "string"
},
"fontSize": {
"type": "string"
},
"customFontSize": {
"type": "number"
},
"itemsJustification": {
"type": "string"
},
Expand All @@ -50,13 +44,11 @@
"showSubmenuIcon": "showSubmenuIcon"
},
"supports": {

Copy link
Copy Markdown
Member

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?

"align": [
"wide",
"full"
],
"align": [ "wide", "full" ],
"anchor": true,
"html": false,
"inserter": true,
"lightBlockWrapper": true
"lightBlockWrapper": true,
"__experimentalFontSize": true
}
}
28 changes: 2 additions & 26 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
InnerBlocks,
InspectorControls,
BlockControls,
FontSizePicker,
withFontSizes,
__experimentalUseColors,
__experimentalBlock as Block,
} from '@wordpress/block-editor';
Expand All @@ -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(
[
Expand All @@ -64,15 +59,13 @@ function Navigation( {
{
backgroundColor: true,
textColor: true,
fontSize: fontSize.size,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 ColorEdit and ColorPanel components don't explicitly deal with font size, and it's not being passed to the contrast checker in e.g. the Paragraph and the Heading block color panels.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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(
Expand Down Expand Up @@ -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',
} );

Expand Down Expand Up @@ -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
Expand All @@ -187,10 +167,7 @@ function Navigation( {
</InspectorControls>
<TextColor>
<BackgroundColor>
<Block.nav
className={ blockClassNames }
style={ blockInlineStyles }
>
<Block.nav className={ blockClassNames }>
<InnerBlocks
ref={ ref }
allowedBlocks={ [
Expand Down Expand Up @@ -227,7 +204,6 @@ function Navigation( {
}

export default compose( [
withFontSizes( 'fontSize' ),
withSelect( ( select, { clientId } ) => {
const innerBlocks = select( 'core/block-editor' ).getBlocks( clientId );
const {
Expand Down