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
9 changes: 6 additions & 3 deletions packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { audio as icon } from '@wordpress/icons';
import { createBlock } from '@wordpress/blocks';
Expand Down Expand Up @@ -157,7 +157,7 @@ function AudioEdit( {
checked={ loop }
/>
<SelectControl
label={ __( 'Preload' ) }
label={ _x( 'Preload', 'noun; Audio block parameter' ) }
value={ preload || '' }
// `undefined` is required for the preload attribute to be unset.
onChange={ ( value ) =>
Expand All @@ -169,7 +169,10 @@ function AudioEdit( {
{ value: '', label: __( 'Browser default' ) },
{ value: 'auto', label: __( 'Auto' ) },
{ value: 'metadata', label: __( 'Metadata' ) },
{ value: 'none', label: __( 'None' ) },
{
value: 'none',
label: _x( 'None', '"Preload" value' ),
},
] }
/>
</PanelBody>
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/audio/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
MediaUploadProgress,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { audio as icon, replace } from '@wordpress/icons';
import { useState } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -197,7 +197,10 @@ function AudioEdit( {
checked={ loop }
/>
<SelectControl
label={ __( 'Preload' ) }
label={ _x(
'Preload',
'noun; Audio block parameter'
) }
value={ preload || '' }
// `undefined` is required for the preload attribute to be unset.
onChange={ ( value ) =>
Expand All @@ -209,7 +212,10 @@ function AudioEdit( {
{ value: '', label: __( 'Browser default' ) },
{ value: 'auto', label: __( 'Auto' ) },
{ value: 'metadata', label: __( 'Metadata' ) },
{ value: 'none', label: __( 'None' ) },
{
value: 'none',
label: _x( 'None', '"Preload" value' ),
},
] }
hideCancelButton={ true }
/>
Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { View, AccessibilityInfo, Platform, Text } from 'react-native';
* WordPress dependencies
*/
import { withInstanceId, compose } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import {
RichText,
InspectorControls,
Expand Down Expand Up @@ -136,7 +136,10 @@ class ButtonEdit extends Component {
},
linkRel: {
label: __( 'Link Rel' ),
placeholder: __( 'None' ),
placeholder: _x(
'None',
'Link rel attribute value placeholder'
),
},
};

Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
useBlockProps,
} from '@wordpress/block-editor';
import { Platform, useEffect, useMemo } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { withViewportMatch } from '@wordpress/viewport';
import { View } from '@wordpress/primitives';
Expand Down Expand Up @@ -57,7 +57,10 @@ const MAX_COLUMNS = 8;
const linkOptions = [
{ value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },
{ value: LINK_DESTINATION_MEDIA, label: __( 'Media File' ) },
{ value: LINK_DESTINATION_NONE, label: __( 'None' ) },
{
value: LINK_DESTINATION_NONE,
label: _x( 'None', 'Media item link option' ),
},
];
const ALLOWED_MEDIA_TYPES = [ 'image' ];

Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
BlockStyles,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { getProtocol, hasQueryArg } from '@wordpress/url';
import { doAction, hasAction } from '@wordpress/hooks';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
Expand Down Expand Up @@ -121,7 +121,10 @@ export class ImageEdit extends Component {
},
linkRel: {
label: __( 'Link Rel' ),
placeholder: __( 'None' ),
placeholder: _x(
'None',
'Link rel attribute value placeholder'
),
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-link/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* Navigation Items.
*/

.wp-block-navigation-link {
.wp-block-navigation-item {
.wp-block-navigation__submenu-container {
display: block;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Low specificity default to ensure background color applies to submenus.
.wp-block-navigation__container,
.wp-block-navigation-link {
.wp-block-navigation-item {
background-color: inherit;
}

Expand Down Expand Up @@ -215,7 +215,7 @@ $color-control-label-height: 20px;

// Style skeleton elements to mostly match the metrics of actual menu items.
// Needs specificity.
.wp-block-navigation-link.wp-block-navigation-link {
.wp-block-navigation-item.wp-block-navigation-item {
position: relative;
min-width: 72px;

Expand All @@ -237,7 +237,7 @@ $color-control-label-height: 20px;
}


.wp-block-navigation-link.wp-block-navigation-link,
.wp-block-navigation-item.wp-block-navigation-item,
.wp-block-navigation-placeholder__preview-search-icon {
opacity: 0.3;
}
Expand All @@ -250,6 +250,7 @@ $color-control-label-height: 20px;
width: 0;
overflow: hidden;
flex-wrap: nowrap;
flex: 0;
}

// Hide entirely when vertical.
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/navigation/placeholder-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Icon, search } from '@wordpress/icons';
const PlaceholderPreview = () => {
return (
<ul className="wp-block-navigation-placeholder__preview wp-block-navigation__container">
<li className="wp-block-navigation-link">&#8203;</li>
<li className="wp-block-navigation-link">&#8203;</li>
<li className="wp-block-navigation-link">&#8203;</li>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-placeholder__preview-search-icon">
<Icon icon={ search } />
</li>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/video/edit-common-settings.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { ToggleControl, SelectControl } from '@wordpress/components';
import { useMemo, useCallback, Platform } from '@wordpress/element';

const options = [
{ value: 'auto', label: __( 'Auto' ) },
{ value: 'metadata', label: __( 'Metadata' ) },
{ value: 'none', label: __( 'None' ) },
{ value: 'none', label: _x( 'None', 'Preload value' ) },
];

const VideoSettings = ( { setAttributes, attributes } ) => {
Expand Down
6 changes: 4 additions & 2 deletions packages/blocks/src/api/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = {
},
backgroundColor: {
value: [ 'color', 'background' ],
support: [ 'color' ],
support: [ 'color', 'background' ],
requiresOptOut: true,
},
borderColor: {
value: [ 'border', 'color' ],
Expand All @@ -50,7 +51,8 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = {
},
color: {
value: [ 'color', 'text' ],
support: [ 'color' ],
support: [ 'color', 'text' ],
requiresOptOut: true,
},
linkColor: {
value: [ 'elements', 'link', 'color', 'text' ],
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/dimension-control/sizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { _x } from '@wordpress/i18n';

/**
* Finds the correct size object from the provided sizes
Expand All @@ -26,23 +26,23 @@ export const findSizeBySlug = ( sizes, slug ) =>

export default [
{
name: __( 'None' ),
name: _x( 'None', 'Size of a UI element' ),
slug: 'none',
},
{
name: __( 'Small' ),
name: _x( 'Small', 'Size of a UI element' ),
slug: 'small',
},
{
name: __( 'Medium' ),
name: _x( 'Medium', 'Size of a UI element' ),
slug: 'medium',
},
{
name: __( 'Large' ),
name: _x( 'Large', 'Size of a UI element' ),
slug: 'large',
},
{
name: __( 'Extra Large' ),
name: _x( 'Extra Large', 'Size of a UI element' ),
slug: 'xlarge',
},
];
9 changes: 9 additions & 0 deletions packages/components/src/navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ const MyNavigation = () => (
</Navigation>
);
```
## CSS Classes leveraged

The structural CSS for the navigation block targets generic classnames across menu items of multiple types including those automatically generated by the Page List block. Here are some of the notable classnames and what they are used for:

- `.wp-block-navigation__submenu-container` is applied to submenus to main menu items.
- `.wp-block-navigation-item` is applied to every menu item.
- `.wp-block-navigation-item__content` is applied to the link inside a menu item.
- `.wp-block-navigation-link__label` is applied to the innermost container around the menu item text label.
- `.wp-block-navigation__submenu-icon` is applied to the submenu indicator (chevron).

## Navigation Props

Expand Down
8 changes: 4 additions & 4 deletions packages/edit-navigation/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
font-family: $default-font;

// Increase specificity.
.wp-block-navigation-link {
.wp-block-navigation-item {
display: block;

// Show submenus on click.
Expand All @@ -55,7 +55,7 @@

// Menu items.
// This needs high specificity to override inherited values.
&.wp-block-navigation-link.wp-block-navigation-link {
&.wp-block-navigation-item.wp-block-navigation-item {
margin-right: 0;
}

Expand Down Expand Up @@ -124,7 +124,7 @@
}

// Override inherited values to optimize menu items for the screen context.
.wp-block-navigation-link.has-child {
.wp-block-navigation-item.has-child {
cursor: default;
border-radius: $radius-block-ui;
}
Expand All @@ -137,7 +137,7 @@

// When editing a link with children, highlight the parent
// and adjust the spacing and submenu icon.
.wp-block-navigation-link.has-child.is-editing {
.wp-block-navigation-item.has-child.is-editing {
> .wp-block-navigation__container,
> .wp-block-navigation__submenu-container {
opacity: 1;
Expand Down
20 changes: 18 additions & 2 deletions packages/edit-site/src/components/editor/global-styles-provider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { set, get, mergeWith, mapValues, setWith, clone } from 'lodash';
import { set, get, has, mergeWith, mapValues, setWith, clone } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -75,8 +75,24 @@ export const useGlobalStylesReset = () => {
const extractSupportKeys = ( supports ) => {
const supportKeys = [];
Object.keys( STYLE_PROPERTY ).forEach( ( name ) => {
if ( ! STYLE_PROPERTY[ name ].support ) {
return;
}

// Opting out means that, for certain support keys like background color,
// blocks have to explicitly set the support value false. If the key is
// unset, we still enable it.
if ( STYLE_PROPERTY[ name ].requiresOptOut ) {
if (
has( supports, STYLE_PROPERTY[ name ].support[ 0 ] ) &&
get( supports, STYLE_PROPERTY[ name ].support ) !== false
) {
return supportKeys.push( name );
}
}

if ( get( supports, STYLE_PROPERTY[ name ].support, false ) ) {
supportKeys.push( name );
return supportKeys.push( name );
}
} );
return supportKeys;
Expand Down
Loading