Skip to content
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

wip: Hide overflowing navigation menu items #28646

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
24b0275
Bump plugin version to 9.9.0-rc.1
oandregal Jan 29, 2021
bff5496
add `minHeightUnit` to latest core/cover deprecation (#28627)
flootr Feb 1, 2021
34d8338
Try: Cover position fix round 2 (#28653)
jasmussen Feb 3, 2021
f7abb22
Full Site Editing: Fix template parts not loading in frontend (#28752)
jeyip Feb 4, 2021
44ace23
Fix e2e failures on 'Front Page' template. (#28638)
Addison-Stavlo Feb 1, 2021
d8b50ae
Bump plugin version to 9.9.0
noisysocks Feb 5, 2021
9ac8c55
Fix global styles in iframed site editor (#28731)
nosolosw Feb 5, 2021
f993b0d
Bugfix: enqueue preset classes in the front-end (#28792)
nosolosw Feb 8, 2021
ac9e3cb
Bump plugin version to 9.9.1
oandregal Feb 8, 2021
95551d9
Try: useMergeRefs (#27768)
ellatrix Feb 8, 2021
bbb9934
Remove duplication of editor styles (#28837)
ellatrix Feb 10, 2021
619d9f9
Cover: Add missing align support to deprecation (#28796)
sirreal Feb 11, 2021
5ebb63b
Bump plugin version to 9.9.2
oandregal Feb 11, 2021
c199736
Add react-merge-refs to block-library
vcanales Feb 1, 2021
d1b963d
Add autohide hook to handle 'flex-wrapped' element
vcanales Feb 1, 2021
4200a9d
fix hook export
Feb 2, 2021
ea9c9c4
wip
vcanales Feb 11, 2021
310156f
add visibility status to innerBlocks
vcanales Feb 17, 2021
1be4591
use ownerDocument's defaultView instead of window
vcanales Feb 17, 2021
a349ff0
Call resize handler to set initial state
vcanales Feb 17, 2021
d8c92cb
Memoize navigationElement instead of relying on fn
vcanales Feb 17, 2021
ab99c07
Add comments
vcanales Feb 17, 2021
98c55db
correctly determine if nav has hidden elements
vcanales Feb 22, 2021
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
238 changes: 238 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the new block editor in core.
* Requires at least: 5.3
* Requires PHP: 5.6
* Version: 9.8.2
* Version: 9.9.2
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
2 changes: 1 addition & 1 deletion lib/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ private function get_block_styles() {

$metadata = $this->get_blocks_metadata();
foreach ( $metadata as $block_selector => $metadata ) {
if ( empty( $metadata['selector'] ) || empty( $metadata['supports'] ) ) {
if ( empty( $metadata['selector'] ) ) {
continue;
}

Expand Down
23 changes: 11 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "9.8.2",
"version": "9.9.2",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"lodash": "^4.17.19",
"memize": "^1.1.0",
"react-autosize-textarea": "^7.1.0",
"react-merge-refs": "^1.0.0",
"react-spring": "^8.0.19",
"redux-multi": "^0.1.12",
"rememo": "^3.0.0",
Expand Down
67 changes: 31 additions & 36 deletions packages/block-editor/src/components/editor-styles/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,57 @@
/**
* External dependencies
*/
import { compact, map } from 'lodash';
import tinycolor from 'tinycolor2';

/**
* WordPress dependencies
*/
import { useCallback, useRef } from '@wordpress/element';
import { useCallback } from '@wordpress/element';

/**
* Internal dependencies
*/
import transformStyles from '../../utils/transform-styles';

function syncDarkThemeBodyClassname( node ) {
const backgroundColor = window
.getComputedStyle( node, null )
.getPropertyValue( 'background-color' );

const { ownerDocument } = node;
const body = ownerDocument.getElementsByTagName( 'body' )[ 0 ];

if ( tinycolor( backgroundColor ).getLuminance() > 0.5 ) {
body.classList.remove( 'is-dark-theme' );
} else {
body.classList.add( 'is-dark-theme' );
}
}

export default function useEditorStyles( styles ) {
const nodes = useRef( [] );
const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';

function useDarkThemeBodyClassName( styles ) {
return useCallback(
( node ) => {
if ( ! node ) {
nodes.current.forEach( ( styleElement ) =>
styleElement.ownerDocument.body.removeChild( styleElement )
);
return;
}

const updatedStyles = transformStyles(
styles,
'.editor-styles-wrapper'
);

const { ownerDocument } = node;
nodes.current = map( compact( updatedStyles ), ( updatedCSS ) => {
const styleElement = ownerDocument.createElement( 'style' );
styleElement.innerHTML = updatedCSS;
ownerDocument.body.appendChild( styleElement );

return styleElement;
} );

syncDarkThemeBodyClassname( node );
const { defaultView, body } = ownerDocument;
const canvas = ownerDocument.querySelector(
EDITOR_STYLES_SELECTOR
);
const backgroundColor = defaultView
.getComputedStyle( canvas, null )
.getPropertyValue( 'background-color' );

if ( tinycolor( backgroundColor ).getLuminance() > 0.5 ) {
body.classList.remove( 'is-dark-theme' );
} else {
body.classList.add( 'is-dark-theme' );
}
},
[ styles ]
);
}

export default function EditorStyles( { styles } ) {
return (
<>
{ /* Use an empty style element to have a document reference,
but this could be any element. */ }
<style ref={ useDarkThemeBodyClassName( styles ) } />
{ transformStyles( styles, EDITOR_STYLES_SELECTOR ).map(
( css, index ) => (
<style key={ index }>{ css }</style>
)
) }
</>
);
}
24 changes: 13 additions & 11 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import mergeRefs from 'react-merge-refs';

/**
* WordPress dependencies
*/
Expand All @@ -13,6 +8,7 @@ import {
forwardRef,
} from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useMergeRefs } from '@wordpress/compose';

const BODY_CLASS_NAME = 'editor-styles-wrapper';
const BLOCK_PREFIX = 'wp-block';
Expand Down Expand Up @@ -136,7 +132,7 @@ function setHead( doc, head ) {
'<style>body{margin:0}</style>' + head;
}

function Iframe( { contentRef, children, head, ...props }, ref ) {
function Iframe( { contentRef, children, head, headHTML, ...props }, ref ) {
const [ iframeDocument, setIframeDocument ] = useState();

const setRef = useCallback( ( node ) => {
Expand All @@ -146,19 +142,24 @@ function Iframe( { contentRef, children, head, ...props }, ref ) {

function setDocumentIfReady() {
const { contentDocument } = node;
const { readyState } = contentDocument;
const { readyState, body } = contentDocument;

if ( readyState !== 'interactive' && readyState !== 'complete' ) {
return false;
}

contentRef.current = contentDocument.body;
setIframeDocument( contentDocument );
setHead( contentDocument, head );
if ( typeof contentRef === 'function' ) {
contentRef( body );
} else if ( contentRef ) {
contentRef.current = body;
}

setHead( contentDocument, headHTML );
setBodyClassName( contentDocument );
styleSheetsCompat( contentDocument );
bubbleEvents( contentDocument );
setBodyClassName( contentDocument );
setIframeDocument( contentDocument );

return true;
}
Expand All @@ -176,12 +177,13 @@ function Iframe( { contentRef, children, head, ...props }, ref ) {
return (
<iframe
{ ...props }
ref={ useCallback( mergeRefs( [ ref, setRef ] ), [] ) }
ref={ useMergeRefs( [ ref, setRef ] ) }
tabIndex="0"
title={ __( 'Editor canvas' ) }
name="editor-canvas"
>
{ iframeDocument && createPortal( children, iframeDocument.body ) }
{ iframeDocument && createPortal( head, iframeDocument.head ) }
</iframe>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export {
useClipboardHandler as __unstableUseClipboardHandler,
} from './copy-handler';
export { default as DefaultBlockAppender } from './default-block-appender';
export { default as __unstableUseEditorStyles } from './editor-styles';
export { default as __unstableEditorStyles } from './editor-styles';
export { default as Inserter } from './inserter';
export { default as __experimentalLibrary } from './inserter/library';
export { default as __experimentalSearchForm } from './inserter/search-form';
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Allow setting the `crossOrigin` attribute so the `useTransformImage` hook can use cross-origin sources ([#28255](https://github.com/WordPress/gutenberg/pull/28255/)).

### Bug Fixes

- Fix a regression where the Cover block migration would not work with custom units for `minHeight` ([#28627](https://github.com/WordPress/gutenberg/pull/28627))

## 2.27.0 (2020-12-17)

### Enhancement
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"memize": "^1.1.0",
"moment": "^2.22.1",
"react-easy-crop": "^3.0.0",
"react-merge-refs": "^1.1.0",
"tinycolor2": "^1.4.2"
},
"publishConfig": {
Expand Down
12 changes: 12 additions & 0 deletions packages/block-library/src/cover/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,19 @@ const deprecated = [
minHeight: {
type: 'number',
},
minHeightUnit: {
type: 'string',
},
gradient: {
type: 'string',
},
customGradient: {
type: 'string',
},
},
supports: {
align: true,
},
save( { attributes } ) {
const {
backgroundType,
Expand Down Expand Up @@ -216,6 +222,9 @@ const deprecated = [
type: 'string',
},
},
supports: {
align: true,
},
save( { attributes } ) {
const {
backgroundType,
Expand Down Expand Up @@ -319,6 +328,9 @@ const deprecated = [
type: 'string',
},
},
supports: {
align: true,
},
save( { attributes } ) {
const {
backgroundType,
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/embed/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
}
}

// Supply a min-width when inside a cover block, to prevent it from collapsing.
.wp-block-cover .wp-block-embed {
min-width: 320px;
min-height: 240px;
}

.wp-block-embed {
// Supply caption styles to embeds, even if the theme hasn't opted in.
// Reason being: the new markup, figcaptions, are not likely to be styled in the majority of existing themes,
Expand Down
Loading