Skip to content

Commit

Permalink
prep build 08/03
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Aug 3, 2024
2 parents 740fc76 + 79b0752 commit 548cead
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 43 deletions.
Binary file removed docs/assets/plugin-sidebar-closed-state.png
Binary file not shown.
Binary file modified docs/assets/plugin-sidebar-open-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 53 additions & 15 deletions docs/reference-guides/slotfills/plugin-sidebar.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,68 @@
# PluginSidebar

This slot allows for adding items into the Gutenberg Toolbar.
Using this slot will add an icon to the bar that, when clicked, will open a sidebar with the content of the items wrapped in the `<PluginSidebar />` component.
This slot allows adding items to the tool bar of either the Post or Site editor screens.
Using this slot will add an icon to the toolbar that, when clicked, opens a panel with containing the items wrapped in the `<PluginSidebar />` component.

## Example

```js
import { registerPlugin } from '@wordpress/plugins';
```jsx
import { __ } from '@wordpress/i18n';
import { PluginSidebar } from '@wordpress/editor';
import { image } from '@wordpress/icons';
import {
PanelBody,
Button,
TextControl,
SelectControl,
} from '@wordpress/components';
import { registerPlugin } from '@wordpress/plugins';
import { useState } from '@wordpress/element';

const PluginSidebarExample = () => {
const [ text, setText ] = useState( '' );
const [ select, setSelect ] = useState( 'a' );

const PluginSidebarTest = () => (
<PluginSidebar name="plugin-sidebar-test" title="My Plugin" icon={ image }>
<p>Plugin Sidebar</p>
</PluginSidebar>
);
return (
<PluginSidebar
name="plugin-sidebar-example"
title={ __( 'My PluginSidebar' ) }
icon={ 'smiley' }
>
<PanelBody>
<h2>
{ __( 'This is a heading for the PluginSidebar example.' ) }
</h2>
<p>
{ __(
'This is some example text for the PluginSidebar example.'
) }
</p>
<TextControl
label={ __( 'Text Control' ) }
value={ text }
onChange={ ( newText ) => setText( newText ) }
/>
<SelectControl
label={ __( 'Select Control' ) }
value={ select }
options={ [
{ value: 'a', label: 'Option A' },
{ value: 'b', label: 'Option B' },
{ value: 'c', label: 'Option C' },
] }
onChange={ ( newSelect ) => setSelect( newSelect ) }
/>
<Button variant="primary">{ __( 'Primary Button' ) } </Button>
</PanelBody>
</PluginSidebar>
);
};

registerPlugin( 'plugin-sidebar-test', { render: PluginSidebarTest } );
// Register the plugin.
registerPlugin( 'plugin-sidebar-example', { render: PluginSidebarExample } );
```

## Location

### Closed State

![Closed State](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/plugin-sidebar-closed-state.png?raw=true)

### Open State

![Open State](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/plugin-sidebar-open-state.png?raw=true)
3 changes: 3 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions packages/base-styles/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
animation-fill-mode: forwards;
@include reduce-motion("animation");
}

@mixin editor-canvas-resize-animation() {
transition: all 0.5s cubic-bezier(0.65, 0, 0.45, 1);
@include reduce-motion("transition");
}
2 changes: 1 addition & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ _Returns_

> **Deprecated**
This function was accidentially exposed for mobile/native usage.
This function was accidentally exposed for mobile/native usage.

_Returns_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ iframe[name="editor-canvas"] {
height: 100%;
display: block;
background-color: transparent;
@include editor-canvas-resize-animation;
}
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/iframe/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
}

.block-editor-iframe__html {
border: 0 solid $gray-300;
transform-origin: top center;
transition: transform 0.3s;
@include reduce-motion("transition");
@include editor-canvas-resize-animation;
}

.block-editor-iframe__html.is-zoomed-out {
Expand Down
4 changes: 1 addition & 3 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function Iframe( {

iframeDocument.documentElement.classList.add( 'is-zoomed-out' );

const maxWidth = 800;
const maxWidth = 750;
iframeDocument.documentElement.style.setProperty(
'--wp-block-editor-iframe-zoom-out-scale',
scale === 'default'
Expand Down Expand Up @@ -378,10 +378,8 @@ function Iframe( {
<iframe
{ ...props }
style={ {
border: 0,
...props.style,
height: props.style?.height,
transition: 'all .3s',
} }
ref={ useMergeRefs( [ ref, setRef ] ) }
tabIndex={ tabIndex }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function useResizeCanvas( deviceType ) {
return deviceWidth < actualWidth ? deviceWidth : actualWidth;
};

const marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );
const marginValue = () => ( window.innerHeight < 800 ? 36 : 64 );

const contentInlineStyles = ( device ) => {
const height = device === 'Mobile' ? '768px' : '1024px';
Expand All @@ -62,8 +62,6 @@ export default function useResizeCanvas( deviceType ) {
marginLeft: marginHorizontal,
marginRight: marginHorizontal,
height,
borderRadius: '2px 2px 2px 2px',
border: '1px solid #ddd',
overflowY: 'auto',
};
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/utils/get-editor-region.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function getEditorRegion( editor ) {
return iframeDocument === editor.ownerDocument;
} ) ?? editor;

// The region is provivided by the editor, not the block-editor.
// The region is provided by the editor, not the block-editor.
// We should send focus to the region if one is available to reuse the
// same interface for navigating landmarks. If no region is available,
// use the canvas instead.
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/utils/get-px-from-css-unit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This function was accidentially exposed for mobile/native usage.
* This function was accidentally exposed for mobile/native usage.
*
* @deprecated
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const _HeaderMenu = forwardRef( function HeaderMenu< Item >(
} }
>
<DropdownMenuItemLabel>
{ __( 'Hide' ) }
{ __( 'Hide column' ) }
</DropdownMenuItemLabel>
</DropdownMenuItem>
) }
Expand Down
13 changes: 11 additions & 2 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import clsx from 'clsx';
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { Button, __experimentalHStack as HStack } from '@wordpress/components';
import {
Button,
__experimentalHStack as HStack,
VisuallyHidden,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
Expand Down Expand Up @@ -80,9 +84,14 @@ const SiteHub = memo(
variant="link"
href={ homeUrl }
target="_blank"
label={ __( 'View site (opens in a new tab)' ) }
>
{ decodeEntities( siteTitle ) }
<VisuallyHidden as="span">
{
/* translators: accessibility text */
__( '(opens in a new tab)' )
}
</VisuallyHidden>
</Button>
</div>
<HStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { store as coreStore } from '@wordpress/core-data';
*/
import { useSupportedStyles } from '../../components/global-styles/hooks';
import { unlock } from '../../lock-unlock';
import cloneDeep from '../../utils/clone-deep';
import setNestedValue from '../../utils/set-nested-value';

const { cleanEmptyObject, GlobalStylesContext } = unlock(
Expand Down Expand Up @@ -259,8 +258,8 @@ function PushChangesToGlobalStylesControl( {
if ( changes.length > 0 ) {
const { style: blockStyles } = attributes;

const newBlockStyles = cloneDeep( blockStyles );
const newUserConfig = cloneDeep( userConfig );
const newBlockStyles = structuredClone( blockStyles );
const newUserConfig = structuredClone( userConfig );

for ( const { path, value } of changes ) {
setNestedValue( newBlockStyles, path, undefined );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import cloneDeep from '../../utils/clone-deep';
import { unlock } from '../../lock-unlock';

const { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(
Expand Down Expand Up @@ -91,7 +90,7 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig(
const propertiesAsString = properties.toString();

return useMemo( () => {
const clonedUserVariation = cloneDeep( userVariation );
const clonedUserVariation = structuredClone( userVariation );

// Get user variation and remove the settings for the given property.
const userVariationWithoutProperties = removePropertiesFromObject(
Expand Down Expand Up @@ -167,7 +166,7 @@ export const filterObjectByProperties = ( object, properties ) => {
*/
export function isVariationWithProperties( variation, properties ) {
const variationWithProperties = filterObjectByProperties(
cloneDeep( variation ),
structuredClone( variation ),
properties
);

Expand Down
8 changes: 0 additions & 8 deletions packages/edit-site/src/utils/clone-deep.js

This file was deleted.

3 changes: 3 additions & 0 deletions packages/primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"@wordpress/element": "file:../element",
"clsx": "^2.1.1"
},
"peerDependencies": {
"react": "^18.0.0"
},
"publishConfig": {
"access": "public"
}
Expand Down

0 comments on commit 548cead

Please sign in to comment.