' );
expect( console ).toHaveWarned();
expect( isEquivalent ).toBe( false );
} );
it( 'should return false when difference of boolean attribute', () => {
- const isEquivalent = isEquivalentHTML(
- '
',
- '
'
- );
+ const isEquivalent = isEquivalentHTML( '
', '
' );
expect( console ).toHaveWarned();
expect( isEquivalent ).toBe( false );
@@ -582,10 +532,7 @@ describe( 'validation', () => {
} );
it( 'should return true when comparing empty strings', () => {
- const isEquivalent = isEquivalentHTML(
- '',
- '',
- );
+ const isEquivalent = isEquivalentHTML( '', '' );
expect( isEquivalent ).toBe( true );
} );
@@ -593,7 +540,7 @@ describe( 'validation', () => {
it( 'should return false if supplied malformed HTML', () => {
const isEquivalent = isEquivalentHTML(
'
fsdfsdfsdfdsfsdfsdd
',
- '
fsdfsdfsdfdsfsdfsdd
',
+ '
fsdfsdfsdfdsfsdfsdd
'
);
expect( console ).toHaveWarned();
@@ -603,7 +550,7 @@ describe( 'validation', () => {
it( 'should return false if supplied two sets of malformed HTML', () => {
const isEquivalent = isEquivalentHTML(
'
',
- '
fsdfsdfsdfdsfsdfsdd
',
+ '
fsdfsdfsdfdsfsdfsdd
'
);
expect( console ).toHaveWarned();
@@ -647,11 +594,7 @@ describe( 'validation', () => {
it( 'returns false if block is not valid', () => {
registerBlockType( 'core/test-block', defaultBlockSettings );
- const isValid = isValidBlockContent(
- 'core/test-block',
- { fruit: 'Bananas' },
- 'Apples'
- );
+ const isValid = isValidBlockContent( 'core/test-block', { fruit: 'Bananas' }, 'Apples' );
expect( console ).toHaveWarned();
expect( console ).toHaveErrored();
@@ -666,11 +609,7 @@ describe( 'validation', () => {
},
} );
- const isValid = isValidBlockContent(
- 'core/test-block',
- { fruit: 'Bananas' },
- 'Bananas'
- );
+ const isValid = isValidBlockContent( 'core/test-block', { fruit: 'Bananas' }, 'Bananas' );
expect( console ).toHaveErrored();
expect( isValid ).toBe( false );
@@ -679,11 +618,7 @@ describe( 'validation', () => {
it( 'returns true is block is valid', () => {
registerBlockType( 'core/test-block', defaultBlockSettings );
- const isValid = isValidBlockContent(
- 'core/test-block',
- { fruit: 'Bananas' },
- 'Bananas'
- );
+ const isValid = isValidBlockContent( 'core/test-block', { fruit: 'Bananas' }, 'Bananas' );
expect( isValid ).toBe( true );
} );
diff --git a/packages/blocks/src/api/utils.js b/packages/blocks/src/api/utils.js
index 3ee762b28fe0f..e33b986e34919 100644
--- a/packages/blocks/src/api/utils.js
+++ b/packages/blocks/src/api/utils.js
@@ -52,8 +52,9 @@ export function isUnmodifiedDefaultBlock( block ) {
const newDefaultBlock = isUnmodifiedDefaultBlock.block;
const blockType = getBlockType( defaultBlockName );
- return every( blockType.attributes, ( value, key ) =>
- newDefaultBlock.attributes[ key ] === block.attributes[ key ]
+ return every(
+ blockType.attributes,
+ ( value, key ) => newDefaultBlock.attributes[ key ] === block.attributes[ key ]
);
}
@@ -66,11 +67,12 @@ export function isUnmodifiedDefaultBlock( block ) {
*/
export function isValidIcon( icon ) {
- return !! icon && (
- isString( icon ) ||
- isValidElement( icon ) ||
- isFunction( icon ) ||
- icon instanceof Component
+ return (
+ !! icon &&
+ ( isString( icon ) ||
+ isValidElement( icon ) ||
+ isFunction( icon ) ||
+ icon instanceof Component )
);
}
@@ -95,11 +97,13 @@ export function normalizeIconObject( icon ) {
return {
...icon,
- foreground: icon.foreground ? icon.foreground : mostReadable(
- tinyBgColor,
- ICON_COLORS,
- { includeFallbackColors: true, level: 'AA', size: 'large' }
- ).toHexString(),
+ foreground: icon.foreground
+ ? icon.foreground
+ : mostReadable( tinyBgColor, ICON_COLORS, {
+ includeFallbackColors: true,
+ level: 'AA',
+ size: 'large',
+ } ).toHexString(),
shadowColor: tinyBgColor.setAlpha( 0.3 ).toRgbString(),
};
}
@@ -135,10 +139,7 @@ export function normalizeBlockType( blockTypeOrName ) {
* @return {string} The block label.
*/
export function getBlockLabel( blockType, attributes, context = 'visual' ) {
- const {
- __experimentalLabel: getLabel,
- title,
- } = blockType;
+ const { __experimentalLabel: getLabel, title } = blockType;
const label = getLabel && getLabel( attributes, { context } );
@@ -189,7 +190,7 @@ export function getAccessibleBlockLabel( blockType, attributes, position, direct
/* translators: accessibility text. %s: The block title, %d The block row number. */
__( '%s Block. Row %d' ),
title,
- position,
+ position
);
} else if ( hasPosition && direction === 'horizontal' ) {
if ( hasLabel ) {
@@ -206,7 +207,7 @@ export function getAccessibleBlockLabel( blockType, attributes, position, direct
/* translators: accessibility text. %s: The block title, %d The block column number. */
__( '%s Block. Column %d' ),
title,
- position,
+ position
);
}
diff --git a/packages/blocks/src/api/validation/index.js b/packages/blocks/src/api/validation/index.js
index aab7517307e30..7463558c96aea 100644
--- a/packages/blocks/src/api/validation/index.js
+++ b/packages/blocks/src/api/validation/index.js
@@ -2,14 +2,7 @@
* External dependencies
*/
import { Tokenizer } from 'simple-html-tokenizer';
-import {
- identity,
- xor,
- fromPairs,
- isEqual,
- includes,
- stubTrue,
-} from 'lodash';
+import { identity, xor, fromPairs, isEqual, includes, stubTrue } from 'lodash';
/**
* WordPress dependencies
@@ -137,10 +130,7 @@ const ENUMERATED_ATTRIBUTES = [
*
* @type {Array}
*/
-const MEANINGFUL_ATTRIBUTES = [
- ...BOOLEAN_ATTRIBUTES,
- ...ENUMERATED_ATTRIBUTES,
-];
+const MEANINGFUL_ATTRIBUTES = [ ...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES ];
/**
* Array of functions which receive a text string on which to apply normalizing
@@ -149,10 +139,7 @@ const MEANINGFUL_ATTRIBUTES = [
*
* @type {Array}
*/
-const TEXT_NORMALIZATIONS = [
- identity,
- getTextWithCollapsedWhitespace,
-];
+const TEXT_NORMALIZATIONS = [ identity, getTextWithCollapsedWhitespace ];
/**
* Regular expression matching a named character reference. In lieu of bundling
@@ -285,11 +272,7 @@ export function getTextWithCollapsedWhitespace( text ) {
export function getMeaningfulAttributePairs( token ) {
return token.attributes.filter( ( pair ) => {
const [ key, value ] = pair;
- return (
- value ||
- key.indexOf( 'data-' ) === 0 ||
- includes( MEANINGFUL_ATTRIBUTES, key )
- );
+ return value || key.indexOf( 'data-' ) === 0 || includes( MEANINGFUL_ATTRIBUTES, key );
} );
}
@@ -336,9 +319,11 @@ export function isEquivalentTextTokens( actual, expected, logger = createLogger(
* @return {string} Normalized style value.
*/
export function getNormalizedStyleValue( value ) {
- return value
- // Normalize URL type to omit whitespace or quotes
- .replace( REGEXP_STYLE_URL_TYPE, 'url($1)' );
+ return (
+ value
+ // Normalize URL type to omit whitespace or quotes
+ .replace( REGEXP_STYLE_URL_TYPE, 'url($1)' )
+ );
}
/**
@@ -360,10 +345,7 @@ export function getStyleProperties( text ) {
const [ key, ...valueParts ] = style.split( ':' );
const value = valueParts.join( ':' );
- return [
- key.trim(),
- getNormalizedStyleValue( value.trim() ),
- ];
+ return [ key.trim(), getNormalizedStyleValue( value.trim() ) ];
} );
return fromPairs( pairs );
@@ -431,12 +413,22 @@ export function isEqualTagAttributePairs( actual, expected, logger = createLogge
if ( isEqualAttributes ) {
// Defer custom attribute equality handling
if ( ! isEqualAttributes( actualValue, expectedValue ) ) {
- logger.warning( 'Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue );
+ logger.warning(
+ 'Expected attribute `%s` of value `%s`, saw `%s`.',
+ name,
+ expectedValue,
+ actualValue
+ );
return false;
}
} else if ( actualValue !== expectedValue ) {
// Otherwise strict inequality should bail
- logger.warning( 'Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue );
+ logger.warning(
+ 'Expected attribute `%s` of value `%s`, saw `%s`.',
+ name,
+ expectedValue,
+ actualValue
+ );
return false;
}
}
@@ -458,7 +450,11 @@ export const isEqualTokensOfType = {
// have exactly equal tag names.
actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()
) {
- logger.warning( 'Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName );
+ logger.warning(
+ 'Expected tag name `%s`, instead saw `%s`.',
+ expected.tagName,
+ actual.tagName
+ );
return false;
}
@@ -548,8 +544,8 @@ export function isClosedByToken( currentToken, nextToken ) {
*/
export function isEquivalentHTML( actual, expected, logger = createLogger() ) {
// Tokenize input content and reserialized save content
- const [ actualTokens, expectedTokens ] = [ actual, expected ].map(
- ( html ) => getHTMLTokens( html, logger )
+ const [ actualTokens, expectedTokens ] = [ actual, expected ].map( ( html ) =>
+ getHTMLTokens( html, logger )
);
// If either is malformed then stop comparing - the strings are not equivalent
@@ -569,7 +565,13 @@ export function isEquivalentHTML( actual, expected, logger = createLogger() ) {
// Inequal if next non-whitespace token of each set are not same type
if ( actualToken.type !== expectedToken.type ) {
- logger.warning( 'Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken );
+ logger.warning(
+ 'Expected token of type `%s` (%o), instead saw `%s` (%o).',
+ expectedToken.type,
+ expectedToken,
+ actualToken.type,
+ actualToken
+ );
return false;
}
@@ -616,13 +618,21 @@ export function isEquivalentHTML( actual, expected, logger = createLogger() ) {
*
* @return {Object} Whether block is valid and contains validation messages.
*/
-export function getBlockContentValidationResult( blockTypeOrName, attributes, originalBlockContent, logger = createQueuedLogger() ) {
+export function getBlockContentValidationResult(
+ blockTypeOrName,
+ attributes,
+ originalBlockContent,
+ logger = createQueuedLogger()
+) {
const blockType = normalizeBlockType( blockTypeOrName );
let generatedBlockContent;
try {
generatedBlockContent = getSaveContent( blockType, attributes );
} catch ( error ) {
- logger.error( 'Block validation failed because an error occurred while generating block content:\n\n%s', error.toString() );
+ logger.error(
+ 'Block validation failed because an error occurred while generating block content:\n\n%s',
+ error.toString()
+ );
return {
isValid: false,
@@ -661,7 +671,12 @@ export function getBlockContentValidationResult( blockTypeOrName, attributes, or
* @return {boolean} Whether block is valid.
*/
export function isValidBlockContent( blockTypeOrName, attributes, originalBlockContent ) {
- const { isValid } = getBlockContentValidationResult( blockTypeOrName, attributes, originalBlockContent, createLogger() );
+ const { isValid } = getBlockContentValidationResult(
+ blockTypeOrName,
+ attributes,
+ originalBlockContent,
+ createLogger()
+ );
return isValid;
}
diff --git a/packages/blocks/src/block-content-provider/index.js b/packages/blocks/src/block-content-provider/index.js
index 96b9a4d31bcd1..ef23a174eb316 100644
--- a/packages/blocks/src/block-content-provider/index.js
+++ b/packages/blocks/src/block-content-provider/index.js
@@ -37,11 +37,7 @@ const BlockContentProvider = ( { children, innerBlocks } ) => {
return
{ html } ;
};
- return (
-
- { children }
-
- );
+ return
{ children } ;
};
/**
@@ -53,12 +49,7 @@ const BlockContentProvider = ( { children, innerBlocks } ) => {
export const withBlockContentContext = createHigherOrderComponent( ( OriginalComponent ) => {
return ( props ) => (
- { ( context ) => (
-
- ) }
+ { ( context ) => }
);
}, 'withBlockContentContext' );
diff --git a/packages/blocks/src/store/reducer.js b/packages/blocks/src/store/reducer.js
index 027748ba70003..66b9660182966 100644
--- a/packages/blocks/src/store/reducer.js
+++ b/packages/blocks/src/store/reducer.js
@@ -1,17 +1,7 @@
/**
* External dependencies
*/
-import {
- filter,
- find,
- get,
- isEmpty,
- keyBy,
- map,
- mapValues,
- omit,
- uniqBy,
-} from 'lodash';
+import { filter, find, get, isEmpty, keyBy, map, mapValues, omit, uniqBy } from 'lodash';
/**
* WordPress dependencies
@@ -70,26 +60,26 @@ export function blockStyles( state = {}, action ) {
return {
...state,
...mapValues( keyBy( action.blockTypes, 'name' ), ( blockType ) => {
- return uniqBy( [
- ...get( blockType, [ 'styles' ], [] ),
- ...get( state, [ blockType.name ], [] ),
- ], ( style ) => style.name );
+ return uniqBy(
+ [ ...get( blockType, [ 'styles' ], [] ), ...get( state, [ blockType.name ], [] ) ],
+ ( style ) => style.name
+ );
} ),
};
case 'ADD_BLOCK_STYLES':
return {
...state,
- [ action.blockName ]: uniqBy( [
- ...get( state, [ action.blockName ], [] ),
- ...( action.styles ),
- ], ( style ) => style.name ),
+ [ action.blockName ]: uniqBy(
+ [ ...get( state, [ action.blockName ], [] ), ...action.styles ],
+ ( style ) => style.name
+ ),
};
case 'REMOVE_BLOCK_STYLES':
return {
...state,
[ action.blockName ]: filter(
get( state, [ action.blockName ], [] ),
- ( style ) => action.styleNames.indexOf( style.name ) === -1,
+ ( style ) => action.styleNames.indexOf( style.name ) === -1
),
};
}
@@ -111,26 +101,26 @@ export function blockPatterns( state = {}, action ) {
return {
...state,
...mapValues( keyBy( action.blockTypes, 'name' ), ( blockType ) => {
- return uniqBy( [
- ...get( blockType, [ 'patterns' ], [] ),
- ...get( state, [ blockType.name ], [] ),
- ], ( pattern ) => pattern.name );
+ return uniqBy(
+ [ ...get( blockType, [ 'patterns' ], [] ), ...get( state, [ blockType.name ], [] ) ],
+ ( pattern ) => pattern.name
+ );
} ),
};
case 'ADD_BLOCK_PATTERNS':
return {
...state,
- [ action.blockName ]: uniqBy( [
- ...get( state, [ action.blockName ], [] ),
- ...( action.patterns ),
- ], ( pattern ) => pattern.name ),
+ [ action.blockName ]: uniqBy(
+ [ ...get( state, [ action.blockName ], [] ), ...action.patterns ],
+ ( pattern ) => pattern.name
+ ),
};
case 'REMOVE_BLOCK_PATTERNS':
return {
...state,
[ action.blockName ]: filter(
get( state, [ action.blockName ], [] ),
- ( pattern ) => action.patternNames.indexOf( pattern.name ) === -1,
+ ( pattern ) => action.patternNames.indexOf( pattern.name ) === -1
),
};
}
@@ -163,8 +153,12 @@ export function createBlockNameSetterReducer( setActionType ) {
}
export const defaultBlockName = createBlockNameSetterReducer( 'SET_DEFAULT_BLOCK_NAME' );
-export const freeformFallbackBlockName = createBlockNameSetterReducer( 'SET_FREEFORM_FALLBACK_BLOCK_NAME' );
-export const unregisteredFallbackBlockName = createBlockNameSetterReducer( 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME' );
+export const freeformFallbackBlockName = createBlockNameSetterReducer(
+ 'SET_FREEFORM_FALLBACK_BLOCK_NAME'
+);
+export const unregisteredFallbackBlockName = createBlockNameSetterReducer(
+ 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME'
+);
export const groupingBlockName = createBlockNameSetterReducer( 'SET_GROUPING_BLOCK_NAME' );
/**
diff --git a/packages/blocks/src/store/selectors.js b/packages/blocks/src/store/selectors.js
index 2e81931d6ef29..cf63698cb2dc2 100644
--- a/packages/blocks/src/store/selectors.js
+++ b/packages/blocks/src/store/selectors.js
@@ -2,17 +2,7 @@
* External dependencies
*/
import createSelector from 'rememo';
-import {
- deburr,
- filter,
- findLast,
- first,
- flow,
- get,
- includes,
- map,
- some,
-} from 'lodash';
+import { deburr, filter, findLast, first, flow, get, includes, map, some } from 'lodash';
/** @typedef {import('../api/registration').WPBlockPatternScope} WPBlockPatternScope */
@@ -25,11 +15,8 @@ import {
*
* @return {Object} Block type object.
*/
-const getNormalizedBlockType = ( state, nameOrType ) => (
- 'string' === typeof nameOrType ?
- getBlockType( state, nameOrType ) :
- nameOrType
-);
+const getNormalizedBlockType = ( state, nameOrType ) =>
+ 'string' === typeof nameOrType ? getBlockType( state, nameOrType ) : nameOrType;
/**
* Returns all the available block types.
@@ -47,10 +34,7 @@ export const getBlockTypes = createSelector(
};
} );
},
- ( state ) => [
- state.blockTypes,
- state.blockPatterns,
- ]
+ ( state ) => [ state.blockTypes, state.blockPatterns ]
);
/**
@@ -197,9 +181,7 @@ export const getChildBlockNames = createSelector(
( { name } ) => name
);
},
- ( state ) => [
- state.blockTypes,
- ]
+ ( state ) => [ state.blockTypes ]
);
/**
@@ -216,10 +198,7 @@ export const getChildBlockNames = createSelector(
export const getBlockSupport = ( state, nameOrType, feature, defaultSupports ) => {
const blockType = getNormalizedBlockType( state, nameOrType );
- return get( blockType, [
- 'supports',
- feature,
- ], defaultSupports );
+ return get( blockType, [ 'supports', feature ], defaultSupports );
};
/**
@@ -268,10 +247,7 @@ export function isMatchingSearchTerm( state, nameOrType, searchTerm ) {
const isSearchMatch = flow( [
getNormalizedSearchTerm,
- ( normalizedCandidate ) => includes(
- normalizedCandidate,
- normalizedSearchTerm
- ),
+ ( normalizedCandidate ) => includes( normalizedCandidate, normalizedSearchTerm ),
] );
return (
diff --git a/packages/blocks/src/store/test/actions.js b/packages/blocks/src/store/test/actions.js
index 35ece735f4486..1632e7e14e17e 100644
--- a/packages/blocks/src/store/test/actions.js
+++ b/packages/blocks/src/store/test/actions.js
@@ -1,10 +1,7 @@
/**
* Internal dependencies
*/
-import {
- __experimentalAddBlockPatterns,
- __experimentalRemoveBlockPatterns,
-} from '../actions';
+import { __experimentalAddBlockPatterns, __experimentalRemoveBlockPatterns } from '../actions';
describe( 'actions', () => {
describe( 'addBlockPatterns', () => {
@@ -22,9 +19,7 @@ describe( 'actions', () => {
const result = __experimentalAddBlockPatterns( blockName, pattern );
expect( result ).toEqual( {
type: 'ADD_BLOCK_PATTERNS',
- patterns: [
- pattern,
- ],
+ patterns: [ pattern ],
blockName,
} );
} );
@@ -33,9 +28,7 @@ describe( 'actions', () => {
const result = __experimentalRemoveBlockPatterns( blockName, patternName );
expect( result ).toEqual( {
type: 'REMOVE_BLOCK_PATTERNS',
- patternNames: [
- patternName,
- ],
+ patternNames: [ patternName ],
blockName,
} );
} );
diff --git a/packages/blocks/src/store/test/reducer.js b/packages/blocks/src/store/test/reducer.js
index 2567903962d14..e52b2824e225c 100644
--- a/packages/blocks/src/store/test/reducer.js
+++ b/packages/blocks/src/store/test/reducer.js
@@ -76,9 +76,7 @@ describe( 'blockStyles', () => {
} );
expect( state ).toEqual( {
- 'core/image': [
- { name: 'fancy' },
- ],
+ 'core/image': [ { name: 'fancy' } ],
} );
state = blockStyles( state, {
@@ -88,44 +86,33 @@ describe( 'blockStyles', () => {
} );
expect( state ).toEqual( {
- 'core/image': [
- { name: 'fancy' },
- { name: 'lightbox' },
- ],
+ 'core/image': [ { name: 'fancy' }, { name: 'lightbox' } ],
} );
} );
it( 'should add block styles when adding a block', () => {
const original = deepFreeze( {
- 'core/image': [
- { name: 'fancy' },
- ],
+ 'core/image': [ { name: 'fancy' } ],
} );
const state = blockStyles( original, {
type: 'ADD_BLOCK_TYPES',
- blockTypes: [ {
- name: 'core/image',
- styles: [
- { name: 'original' },
- ],
- } ],
+ blockTypes: [
+ {
+ name: 'core/image',
+ styles: [ { name: 'original' } ],
+ },
+ ],
} );
expect( state ).toEqual( {
- 'core/image': [
- { name: 'original' },
- { name: 'fancy' },
- ],
+ 'core/image': [ { name: 'original' }, { name: 'fancy' } ],
} );
} );
it( 'should remove block styles', () => {
const original = deepFreeze( {
- 'core/image': [
- { name: 'fancy' },
- { name: 'lightbox' },
- ],
+ 'core/image': [ { name: 'fancy' }, { name: 'lightbox' } ],
} );
const state = blockStyles( original, {
@@ -135,9 +122,7 @@ describe( 'blockStyles', () => {
} );
expect( state ).toEqual( {
- 'core/image': [
- { name: 'lightbox' },
- ],
+ 'core/image': [ { name: 'lightbox' } ],
} );
} );
} );
@@ -172,63 +157,46 @@ describe( 'blockPatterns', () => {
);
expect( state ).toEqual( {
- [ blockName ]: [
- blockPattern,
- ],
+ [ blockName ]: [ blockPattern ],
} );
} );
it( 'should add another pattern when a block pattern already present for the block', () => {
const initialState = deepFreeze( {
- [ blockName ]: [
- blockPattern,
- ],
+ [ blockName ]: [ blockPattern ],
} );
const state = blockPatterns(
initialState,
- __experimentalAddBlockPatterns( blockName, secondBlockPattern ),
+ __experimentalAddBlockPatterns( blockName, secondBlockPattern )
);
expect( state ).toEqual( {
- [ blockName ]: [
- blockPattern,
- secondBlockPattern,
- ],
+ [ blockName ]: [ blockPattern, secondBlockPattern ],
} );
} );
it( 'should prepend block patterns added when adding a block', () => {
const initialState = deepFreeze( {
- [ blockName ]: [
- secondBlockPattern,
- ],
+ [ blockName ]: [ secondBlockPattern ],
} );
const state = blockPatterns(
initialState,
addBlockTypes( {
name: blockName,
- patterns: [
- blockPattern,
- ],
+ patterns: [ blockPattern ],
} )
);
expect( state ).toEqual( {
- [ blockName ]: [
- blockPattern,
- secondBlockPattern,
- ],
+ [ blockName ]: [ blockPattern, secondBlockPattern ],
} );
} );
it( 'should remove a block pattern', () => {
const initialState = deepFreeze( {
- [ blockName ]: [
- blockPattern,
- secondBlockPattern,
- ],
+ [ blockName ]: [ blockPattern, secondBlockPattern ],
} );
const state = blockPatterns(
@@ -237,9 +205,7 @@ describe( 'blockPatterns', () => {
);
expect( state ).toEqual( {
- [ blockName ]: [
- secondBlockPattern,
- ],
+ [ blockName ]: [ secondBlockPattern ],
} );
} );
} );
@@ -346,25 +312,23 @@ describe( 'categories', () => {
} );
it( 'should override categories', () => {
- const original = deepFreeze( [
- { slug: 'chicken', title: 'Chicken' },
- ] );
+ const original = deepFreeze( [ { slug: 'chicken', title: 'Chicken' } ] );
const state = categories( original, {
type: 'SET_CATEGORIES',
categories: [ { slug: 'wings', title: 'Wings' } ],
} );
- expect( state ).toEqual( [
- { slug: 'wings', title: 'Wings' },
- ] );
+ expect( state ).toEqual( [ { slug: 'wings', title: 'Wings' } ] );
} );
it( 'should add the category icon', () => {
- const original = deepFreeze( [ {
- slug: 'chicken',
- title: 'Chicken',
- } ] );
+ const original = deepFreeze( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ },
+ ] );
const state = categories( original, {
type: 'UPDATE_CATEGORY',
@@ -374,23 +338,28 @@ describe( 'categories', () => {
},
} );
- expect( state ).toEqual( [ {
- slug: 'chicken',
- title: 'Chicken',
- icon: 'new-icon',
- } ] );
+ expect( state ).toEqual( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ icon: 'new-icon',
+ },
+ ] );
} );
it( 'should update the category icon', () => {
- const original = deepFreeze( [ {
- slug: 'chicken',
- title: 'Chicken',
- icon: 'old-icon',
- }, {
- slug: 'wings',
- title: 'Wings',
- icon: 'old-icon',
- } ] );
+ const original = deepFreeze( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ icon: 'old-icon',
+ },
+ {
+ slug: 'wings',
+ title: 'Wings',
+ icon: 'old-icon',
+ },
+ ] );
const state = categories( original, {
type: 'UPDATE_CATEGORY',
@@ -400,27 +369,33 @@ describe( 'categories', () => {
},
} );
- expect( state ).toEqual( [ {
- slug: 'chicken',
- title: 'Chicken',
- icon: 'new-icon',
- }, {
- slug: 'wings',
- title: 'Wings',
- icon: 'old-icon',
- } ] );
+ expect( state ).toEqual( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ icon: 'new-icon',
+ },
+ {
+ slug: 'wings',
+ title: 'Wings',
+ icon: 'old-icon',
+ },
+ ] );
} );
it( 'should update multiple category properties', () => {
- const original = deepFreeze( [ {
- slug: 'chicken',
- title: 'Chicken',
- icon: 'old-icon',
- }, {
- slug: 'wings',
- title: 'Wings',
- icon: 'old-icon',
- } ] );
+ const original = deepFreeze( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ icon: 'old-icon',
+ },
+ {
+ slug: 'wings',
+ title: 'Wings',
+ icon: 'old-icon',
+ },
+ ] );
const state = categories( original, {
type: 'UPDATE_CATEGORY',
@@ -431,15 +406,18 @@ describe( 'categories', () => {
},
} );
- expect( state ).toEqual( [ {
- slug: 'chicken',
- title: 'Chicken',
- icon: 'old-icon',
- }, {
- slug: 'wings',
- title: 'New Wings',
- chicken: 'ribs',
- icon: 'old-icon',
- } ] );
+ expect( state ).toEqual( [
+ {
+ slug: 'chicken',
+ title: 'Chicken',
+ icon: 'old-icon',
+ },
+ {
+ slug: 'wings',
+ title: 'New Wings',
+ chicken: 'ribs',
+ icon: 'old-icon',
+ },
+ ] );
} );
} );
diff --git a/packages/components/src/angle-picker/index.js b/packages/components/src/angle-picker/index.js
index a46d11170328b..7e83dd7039f9f 100644
--- a/packages/components/src/angle-picker/index.js
+++ b/packages/components/src/angle-picker/index.js
@@ -29,8 +29,8 @@ const AngleCircle = ( { value, onChange, ...props } ) => {
const setAngleCircleCenter = () => {
const rect = angleCircleRef.current.getBoundingClientRect();
angleCircleCenter.current = {
- x: rect.x + ( rect.width / 2 ),
- y: rect.y + ( rect.height / 2 ),
+ x: rect.x + rect.width / 2,
+ y: rect.y + rect.height / 2,
};
};
@@ -47,7 +47,7 @@ const AngleCircle = ( { value, onChange, ...props } ) => {
onDragMove: changeAngleToPosition,
onDragEnd: changeAngleToPosition,
} );
- return (
+ return (
/* eslint-disable jsx-a11y/no-static-element-interactions */
-
+
+
{
const unprocessedValue = event.target.value;
- const inputValue = unprocessedValue !== '' ?
- parseInt( event.target.value, 10 ) :
- 0;
+ const inputValue = unprocessedValue !== '' ? parseInt( event.target.value, 10 ) : 0;
onChange( inputValue );
} }
value={ value }
@@ -100,4 +90,3 @@ export default function AnglePicker( { value, onChange, label = __( 'Angle' ) }
);
}
-
diff --git a/packages/components/src/angle-picker/stories/index.js b/packages/components/src/angle-picker/stories/index.js
index 99fe93c00dd30..b3ab46f11c172 100644
--- a/packages/components/src/angle-picker/stories/index.js
+++ b/packages/components/src/angle-picker/stories/index.js
@@ -1,4 +1,3 @@
-
/**
* WordPress dependencies
*/
@@ -13,9 +12,7 @@ export default { title: 'Components|AnglePicker', component: AnglePicker };
const AnglePickerWithState = () => {
const [ angle, setAngle ] = useState();
- return (
-
- );
+ return
;
};
export const _default = () => {
diff --git a/packages/components/src/animate/index.js b/packages/components/src/animate/index.js
index ee6ca3298e006..e87f3cba737c3 100644
--- a/packages/components/src/animate/index.js
+++ b/packages/components/src/animate/index.js
@@ -9,13 +9,10 @@ function Animate( { type, options = {}, children } ) {
const [ yAxis, xAxis = 'center' ] = origin.split( ' ' );
return children( {
- className: classnames(
- 'components-animate__appear',
- {
- [ 'is-from-' + xAxis ]: xAxis !== 'center',
- [ 'is-from-' + yAxis ]: yAxis !== 'middle',
- },
- ),
+ className: classnames( 'components-animate__appear', {
+ [ 'is-from-' + xAxis ]: xAxis !== 'center',
+ [ 'is-from-' + yAxis ]: yAxis !== 'middle',
+ } ),
} );
}
@@ -23,18 +20,13 @@ function Animate( { type, options = {}, children } ) {
const { origin = 'left' } = options;
return children( {
- className: classnames(
- 'components-animate__slide-in',
- 'is-from-' + origin,
- ),
+ className: classnames( 'components-animate__slide-in', 'is-from-' + origin ),
} );
}
if ( type === 'loading' ) {
return children( {
- className: classnames(
- 'components-animate__loading',
- ),
+ className: classnames( 'components-animate__loading' ),
} );
}
diff --git a/packages/components/src/autocomplete/index.js b/packages/components/src/autocomplete/index.js
index b95bdf641252c..b8abf524b0e44 100644
--- a/packages/components/src/autocomplete/index.js
+++ b/packages/components/src/autocomplete/index.js
@@ -11,13 +11,7 @@ import { Component, renderToString } from '@wordpress/element';
import { ENTER, ESCAPE, UP, DOWN, LEFT, RIGHT, SPACE } from '@wordpress/keycodes';
import { __, _n, sprintf } from '@wordpress/i18n';
import { withInstanceId, compose } from '@wordpress/compose';
-import {
- create,
- slice,
- insert,
- isCollapsed,
- getTextContent,
-} from '@wordpress/rich-text';
+import { create, slice, insert, isCollapsed, getTextContent } from '@wordpress/rich-text';
/**
* Internal dependencies
@@ -181,9 +175,9 @@ export class Autocomplete extends Component {
const completion = getOptionCompletion( option.value, query );
const { action, value } =
- ( undefined === completion.action || undefined === completion.value ) ?
- { action: 'insert-at-caret', value: completion } :
- completion;
+ undefined === completion.action || undefined === completion.value
+ ? { action: 'insert-at-caret', value: completion }
+ : completion;
if ( 'replace' === action ) {
onReplace( [ value ] );
@@ -214,11 +208,17 @@ export class Autocomplete extends Component {
return;
}
if ( !! filteredOptions.length ) {
- debouncedSpeak( sprintf( _n(
- '%d result found, use up and down arrow keys to navigate.',
- '%d results found, use up and down arrow keys to navigate.',
- filteredOptions.length
- ), filteredOptions.length ), 'assertive' );
+ debouncedSpeak(
+ sprintf(
+ _n(
+ '%d result found, use up and down arrow keys to navigate.',
+ '%d results found, use up and down arrow keys to navigate.',
+ filteredOptions.length
+ ),
+ filteredOptions.length
+ ),
+ 'assertive'
+ );
} else {
debouncedSpeak( __( 'No results.' ), 'assertive' );
}
@@ -244,7 +244,7 @@ export class Autocomplete extends Component {
* `activePromise` in the state would result in it actually being in `this.state`
* before the promise resolves and we check to see if this is the active promise or not.
*/
- const promise = this.activePromise = Promise.resolve(
+ const promise = ( this.activePromise = Promise.resolve(
typeof options === 'function' ? options( query ) : options
).then( ( optionsData ) => {
if ( promise !== this.activePromise ) {
@@ -261,14 +261,15 @@ export class Autocomplete extends Component {
} ) );
const filteredOptions = filterOptions( this.state.search, keyedOptions );
- const selectedIndex = filteredOptions.length === this.state.filteredOptions.length ? this.state.selectedIndex : 0;
+ const selectedIndex =
+ filteredOptions.length === this.state.filteredOptions.length ? this.state.selectedIndex : 0;
this.setState( {
[ 'options_' + completer.idx ]: keyedOptions,
filteredOptions,
selectedIndex,
} );
this.announce( filteredOptions );
- } );
+ } ) );
}
handleKeyDown( event ) {
@@ -343,7 +344,9 @@ export class Autocomplete extends Component {
const prevText = deburr( getTextContent( slice( prevRecord, 0 ) ) );
if ( text !== prevText ) {
- const textAfterSelection = getTextContent( slice( record, undefined, getTextContent( record ).length ) );
+ const textAfterSelection = getTextContent(
+ slice( record, undefined, getTextContent( record ).length )
+ );
const allCompleters = map( completers, ( completer, idx ) => ( { ...completer, idx } ) );
const open = find( allCompleters, ( { triggerPrefix, allowContext } ) => {
const index = text.lastIndexOf( triggerPrefix );
@@ -379,9 +382,11 @@ export class Autocomplete extends Component {
// create a regular expression to filter the options
const search = open ? new RegExp( '(?:\\b|\\s|^)' + escapeRegExp( query ), 'i' ) : /./;
// filter the options we already have
- const filteredOptions = open ? filterOptions( search, this.state[ 'options_' + open.idx ] ) : [];
+ const filteredOptions = open
+ ? filterOptions( search, this.state[ 'options_' + open.idx ] )
+ : [];
// check if we should still suppress the popover
- const suppress = ( open && wasSuppress === open.idx ) ? wasSuppress : undefined;
+ const suppress = open && wasSuppress === open.idx ? wasSuppress : undefined;
// update the state
if ( wasOpen || open ) {
this.setState( { selectedIndex: 0, filteredOptions, suppress, search, open, query } );
@@ -405,7 +410,9 @@ export class Autocomplete extends Component {
const { className, idx } = open || {};
const isExpanded = suppress !== idx && filteredOptions.length > 0;
const listBoxId = isExpanded ? `components-autocomplete-listbox-${ instanceId }` : null;
- const activeId = isExpanded ? `components-autocomplete-item-${ instanceId }-${ selectedKey }` : null;
+ const activeId = isExpanded
+ ? `components-autocomplete-item-${ instanceId }-${ selectedKey }`
+ : null;
return (
<>
@@ -423,26 +430,23 @@ export class Autocomplete extends Component {
className="components-autocomplete__popover"
anchorRef={ getRange() }
>
-
- { isExpanded && map( filteredOptions, ( option, index ) => (
-
this.select( option ) }
- >
- { option.label }
-
- ) ) }
+
+ { isExpanded &&
+ map( filteredOptions, ( option, index ) => (
+ this.select( option ) }
+ >
+ { option.label }
+
+ ) ) }
) }
@@ -451,7 +455,4 @@ export class Autocomplete extends Component {
}
}
-export default compose( [
- withSpokenMessages,
- withInstanceId,
-] )( Autocomplete );
+export default compose( [ withSpokenMessages, withInstanceId ] )( Autocomplete );
diff --git a/packages/components/src/base-control/index.js b/packages/components/src/base-control/index.js
index 689cc98f42420..270c02beca227 100644
--- a/packages/components/src/base-control/index.js
+++ b/packages/components/src/base-control/index.js
@@ -12,33 +12,38 @@ function BaseControl( { id, label, hideLabelFromVision, help, className, childre
return (
- { label && id && ( hideLabelFromVision ?
- { label } :
- { label }
- ) }
- { label && ! id && ( hideLabelFromVision ?
- { label } :
- { label }
- ) }
+ { label &&
+ id &&
+ ( hideLabelFromVision ? (
+
+ { label }
+
+ ) : (
+
+ { label }
+
+ ) ) }
+ { label &&
+ ! id &&
+ ( hideLabelFromVision ? (
+ { label }
+ ) : (
+ { label }
+ ) ) }
{ children }
- { !! help &&
{ help }
}
+ { !! help && (
+
+ { help }
+
+ ) }
);
}
BaseControl.VisualLabel = ( { className, children } ) => {
className = classnames( 'components-base-control__label', className );
- return (
-
- { children }
-
- );
+ return
{ children } ;
};
export default BaseControl;
diff --git a/packages/components/src/base-control/index.native.js b/packages/components/src/base-control/index.native.js
index ddf4067054d83..1bf653768e753 100644
--- a/packages/components/src/base-control/index.native.js
+++ b/packages/components/src/base-control/index.native.js
@@ -5,10 +5,7 @@ import { Text, View } from 'react-native';
export default function BaseControl( { label, help, children } ) {
return (
-
+
{ label && { label } }
{ children }
{ help && { help } }
diff --git a/packages/components/src/base-control/stories/index.js b/packages/components/src/base-control/stories/index.js
index f71877b552243..ba2540d15cf4f 100644
--- a/packages/components/src/base-control/stories/index.js
+++ b/packages/components/src/base-control/stories/index.js
@@ -25,9 +25,7 @@ export const _default = () => {
hideLabelFromVision={ hideLabelFromVision }
className={ className }
>
-
+
);
};
diff --git a/packages/components/src/button-group/index.js b/packages/components/src/button-group/index.js
index b864ff7ccc701..6f4fb672c8c6e 100644
--- a/packages/components/src/button-group/index.js
+++ b/packages/components/src/button-group/index.js
@@ -6,9 +6,7 @@ import classnames from 'classnames';
function ButtonGroup( { className, ...props } ) {
const classes = classnames( 'components-button-group', className );
- return (
-
- );
+ return
;
}
export default ButtonGroup;
diff --git a/packages/components/src/button-group/stories/index.js b/packages/components/src/button-group/stories/index.js
index 604ffa61a58fb..50332eede746a 100644
--- a/packages/components/src/button-group/stories/index.js
+++ b/packages/components/src/button-group/stories/index.js
@@ -10,8 +10,12 @@ export const _default = () => {
const style = { margin: '0 4px' };
return (
- Button 1
- Button 2
+
+ Button 1
+
+
+ Button 2
+
);
};
diff --git a/packages/components/src/button/deprecated.js b/packages/components/src/button/deprecated.js
index ea7fc7ab5ab1c..6c676d0021581 100644
--- a/packages/components/src/button/deprecated.js
+++ b/packages/components/src/button/deprecated.js
@@ -9,13 +9,7 @@ import { forwardRef } from '@wordpress/element';
*/
import Button from '../button';
-function IconButton( {
- labelPosition,
- size,
- tooltip,
- label,
- ...props
-}, ref ) {
+function IconButton( { labelPosition, size, tooltip, label, ...props }, ref ) {
deprecated( 'wp.components.IconButton', {
alternative: 'wp.components.Button',
} );
diff --git a/packages/components/src/button/index.js b/packages/components/src/button/index.js
index 2094b358983ef..cc5f615e70726 100644
--- a/packages/components/src/button/index.js
+++ b/packages/components/src/button/index.js
@@ -16,10 +16,7 @@ import { forwardRef } from '@wordpress/element';
import Tooltip from '../tooltip';
import Icon from '../icon';
-const disabledEventsOnDisabledButton = [
- 'onMouseDown',
- 'onClick',
-];
+const disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ];
export function Button( props, ref ) {
const {
@@ -70,9 +67,10 @@ export function Button( props, ref ) {
const trulyDisabled = disabled && ! isFocusable;
const Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';
- const tagProps = Tag === 'a' ?
- { href, target } :
- { type: 'button', disabled: trulyDisabled, 'aria-pressed': isPressed };
+ const tagProps =
+ Tag === 'a'
+ ? { href, target }
+ : { type: 'button', disabled: trulyDisabled, 'aria-pressed': isPressed };
if ( disabled && isFocusable ) {
// In this case, the button will be disabled, but still focusable and
@@ -88,20 +86,18 @@ export function Button( props, ref ) {
}
// Should show the tooltip if...
- const shouldShowTooltip = ! trulyDisabled && (
+ const shouldShowTooltip =
+ ! trulyDisabled &&
// an explicit tooltip is passed or...
- ( showTooltip && label ) ||
- // there's a shortcut or...
- shortcut ||
- (
+ ( ( showTooltip && label ) ||
+ // there's a shortcut or...
+ shortcut ||
// there's a label and...
- !! label &&
- // the children are empty and...
- ( ! children || ( isArray( children ) && ! children.length ) ) &&
- // the tooltip is not explicitly disabled.
- false !== showTooltip
- )
- );
+ ( !! label &&
+ // the children are empty and...
+ ( ! children || ( isArray( children ) && ! children.length ) ) &&
+ // the tooltip is not explicitly disabled.
+ false !== showTooltip ) );
const element = (
{
- return child ? cloneElement( child, { colorScheme: props.preferredColorScheme, isPressed } ) : child;
+ return child
+ ? cloneElement( child, { colorScheme: props.preferredColorScheme, isPressed } )
+ : child;
} );
// Should show the tooltip if...
- const shouldShowTooltip = ! isDisabled && (
+ const shouldShowTooltip =
+ ! isDisabled &&
// an explicit tooltip is passed or...
- ( showTooltip && label ) ||
- // there's a shortcut or...
- shortcut ||
- (
+ ( ( showTooltip && label ) ||
+ // there's a shortcut or...
+ shortcut ||
// there's a label and...
- !! label &&
- // the children are empty and...
- ( ! children || ( isArray( children ) && ! children.length ) ) &&
- // the tooltip is not explicitly disabled.
- false !== showTooltip
- )
- );
-
- const newIcon = icon ? cloneElement( ( ),
- { colorScheme: props.preferredColorScheme, isPressed } ) : null;
+ ( !! label &&
+ // the children are empty and...
+ ( ! children || ( isArray( children ) && ! children.length ) ) &&
+ // the tooltip is not explicitly disabled.
+ false !== showTooltip ) );
+
+ const newIcon = icon
+ ? cloneElement( , {
+ colorScheme: props.preferredColorScheme,
+ isPressed,
+ } )
+ : null;
const element = (
{ newIcon }
{ newChildren }
- { subscript && ( { subscript } ) }
+ { subscript && (
+
+ { subscript }
+
+ ) }
diff --git a/packages/components/src/button/stories/index.js b/packages/components/src/button/stories/index.js
index 4784b24a661e4..2b6219e078fa1 100644
--- a/packages/components/src/button/stories/index.js
+++ b/packages/components/src/button/stories/index.js
@@ -14,57 +14,43 @@ export default { title: 'Components/Button', component: Button };
export const _default = () => {
const label = text( 'Label', 'Default Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const primary = () => {
const label = text( 'Label', 'Primary Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const secondary = () => {
const label = text( 'Label', 'Secondary Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const tertiary = () => {
const label = text( 'Label', 'Tertiary Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const small = () => {
const label = text( 'Label', 'Small Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const pressed = () => {
const label = text( 'Label', 'Pressed Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const disabled = () => {
const label = text( 'Label', 'Disabled Button' );
- return (
-
{ label }
- );
+ return
{ label } ;
};
export const disabledFocusable = () => {
@@ -102,13 +88,7 @@ export const icon = () => {
const label = text( 'Label', 'More' );
const size = number( 'Size' );
- return (
-
- );
+ return
;
};
export const disabledFocusableIcon = () => {
@@ -147,14 +127,22 @@ export const buttons = () => {
Small Buttons
Button
- Primary Button
- Secondary Button
- Tertiary Button
+
+ Primary Button
+
+
+ Secondary Button
+
+
+ Tertiary Button
+
- Icon & Text
+
+ Icon & Text
+
Regular Buttons
@@ -167,7 +155,9 @@ export const buttons = () => {
-
Icon & Text
+
+ Icon & Text
+
);
diff --git a/packages/components/src/button/test/index.js b/packages/components/src/button/test/index.js
index 211f24ceb0072..55a2d7969a9d3 100644
--- a/packages/components/src/button/test/index.js
+++ b/packages/components/src/button/test/index.js
@@ -90,13 +90,32 @@ describe( 'Button', () => {
it( 'should render a Dashicon component matching the wordpress icon', () => {
const iconButton = shallow(
);
- expect( iconButton.find( 'Icon' ).dive().shallow().hasClass( 'dashicons-wordpress' ) ).toBe( true );
+ expect(
+ iconButton
+ .find( 'Icon' )
+ .dive()
+ .shallow()
+ .hasClass( 'dashicons-wordpress' )
+ ).toBe( true );
} );
it( 'should render child elements and icon', () => {
- const iconButton = shallow(
Test } /> );
- expect( iconButton.find( 'Icon' ).dive().shallow().hasClass( 'dashicons-wordpress' ) ).toBe( true );
- expect( iconButton.find( '.test' ).shallow().text() ).toBe( 'Test' );
+ const iconButton = shallow(
+ Test } />
+ );
+ expect(
+ iconButton
+ .find( 'Icon' )
+ .dive()
+ .shallow()
+ .hasClass( 'dashicons-wordpress' )
+ ).toBe( true );
+ expect(
+ iconButton
+ .find( '.test' )
+ .shallow()
+ .text()
+ ).toBe( 'Test' );
} );
it( 'should add an aria-label when the label property is used, with Tooltip wrapper', () => {
@@ -112,7 +131,9 @@ describe( 'Button', () => {
} );
it( 'should allow tooltip disable', () => {
- const iconButton = shallow( );
+ const iconButton = shallow(
+
+ );
expect( iconButton.name() ).toBe( 'button' );
expect( iconButton.prop( 'aria-label' ) ).toBe( 'WordPress' );
} );
@@ -124,12 +145,20 @@ describe( 'Button', () => {
} );
it( 'should not show the tooltip when icon and children defined', () => {
- const iconButton = shallow( Children );
+ const iconButton = shallow(
+
+ Children
+
+ );
expect( iconButton.name() ).toBe( 'button' );
} );
it( 'should force showing the tooltip even if icon and children defined', () => {
- const iconButton = shallow( Children );
+ const iconButton = shallow(
+
+ Children
+
+ );
expect( iconButton.name() ).toBe( 'Tooltip' );
} );
} );
diff --git a/packages/components/src/card/divider.js b/packages/components/src/card/divider.js
index 09a4a59c72664..9d76dc955409b 100644
--- a/packages/components/src/card/divider.js
+++ b/packages/components/src/card/divider.js
@@ -14,12 +14,7 @@ export function CardDivider( props ) {
const classes = classnames( 'components-card__divider', className );
return (
-
+
);
}
diff --git a/packages/components/src/card/index.js b/packages/components/src/card/index.js
index 765b980567abf..5a9d12c32c1c0 100644
--- a/packages/components/src/card/index.js
+++ b/packages/components/src/card/index.js
@@ -16,13 +16,7 @@ export const defaultProps = {
};
export function Card( props ) {
- const {
- className,
- isBorderless,
- isElevated,
- size,
- ...additionalProps
- } = props;
+ const { className, isBorderless, isElevated, size, ...additionalProps } = props;
const { Provider } = CardContext;
const contextProps = {
diff --git a/packages/components/src/card/stories/_index.js b/packages/components/src/card/stories/_index.js
index 5a241fc0ae5e1..b9c0b640ec4a7 100644
--- a/packages/components/src/card/stories/_index.js
+++ b/packages/components/src/card/stories/_index.js
@@ -31,13 +31,9 @@ export const _default = () => {
return (
- { header && (
- { header }
- ) }
+ { header && { header } }
{ body && { body } }
- { footer && (
- { footer }
- ) }
+ { footer && { footer } }
);
};
diff --git a/packages/components/src/card/stories/media.js b/packages/components/src/card/stories/media.js
index d06eb5197fcfc..9d7f6ef86e5c9 100644
--- a/packages/components/src/card/stories/media.js
+++ b/packages/components/src/card/stories/media.js
@@ -122,11 +122,11 @@ const HorizontallyAlignedCard = styled( Card )`
flex-direction: row-reverse;
}
- ${ StyledCardBody } {
+ ${StyledCardBody} {
flex: 1;
}
- ${ StyledCardMedia } {
+ ${StyledCardMedia} {
&.is-left {
border-radius: 3px 0 0 3px;
}
@@ -151,10 +151,7 @@ export const horizontallyAligned = () => {
return (
<>
-
- Note: This story demonstrates how this UI may be created. It
- requires extra styling.
-
+ Note: This story demonstrates how this UI may be created. It requires extra styling.
diff --git a/packages/components/src/card/styles/card-styles.js b/packages/components/src/card/styles/card-styles.js
index 95375baf3198e..b4b5b5dafd7f0 100644
--- a/packages/components/src/card/styles/card-styles.js
+++ b/packages/components/src/card/styles/card-styles.js
@@ -22,33 +22,32 @@ export const styleProps = {
const { borderColor, borderRadius, backgroundShady } = styleProps;
export const CardUI = styled.div`
- background: ${ color( 'white' ) };
+ background: ${color( 'white' )};
box-sizing: border-box;
- border-radius: ${ borderRadius };
- border: 1px solid ${ borderColor };
+ border-radius: ${borderRadius};
+ border: 1px solid ${borderColor};
- ${ handleBorderless };
+ ${handleBorderless};
&.is-elevated {
- box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.2),
- 0px 1px 1px 0px rgba(0, 0, 0, 0.14),
- 0px 2px 1px -1px rgba(0, 0, 0, 0.12);
+ box-shadow: 0px 1px 3px 0px rgba( 0, 0, 0, 0.2 ), 0px 1px 1px 0px rgba( 0, 0, 0, 0.14 ),
+ 0px 2px 1px -1px rgba( 0, 0, 0, 0.12 );
}
`;
export const HeaderUI = styled.div`
- border-bottom: 1px solid ${ borderColor };
- border-top-left-radius: ${ borderRadius };
- border-top-right-radius: ${ borderRadius };
+ border-bottom: 1px solid ${borderColor};
+ border-top-left-radius: ${borderRadius};
+ border-top-right-radius: ${borderRadius};
box-sizing: border-box;
&:last-child {
border-bottom: none;
}
- ${ headerFooterSizes };
- ${ handleBorderless };
- ${ handleShady };
+ ${headerFooterSizes};
+ ${handleBorderless};
+ ${handleShady};
`;
export const MediaUI = styled.div`
@@ -64,41 +63,41 @@ export const MediaUI = styled.div`
}
&:first-of-type {
- border-top-left-radius: ${ borderRadius };
- border-top-right-radius: ${ borderRadius };
+ border-top-left-radius: ${borderRadius};
+ border-top-right-radius: ${borderRadius};
}
&:last-of-type {
- border-bottom-left-radius: ${ borderRadius };
- border-bottom-right-radius: ${ borderRadius };
+ border-bottom-left-radius: ${borderRadius};
+ border-bottom-right-radius: ${borderRadius};
}
`;
export const BodyUI = styled.div`
box-sizing: border-box;
- ${ bodySize };
- ${ handleShady };
+ ${bodySize};
+ ${handleShady};
`;
export const FooterUI = styled.div`
- border-top: 1px solid ${ borderColor };
- border-bottom-left-radius: ${ borderRadius };
- border-bottom-right-radius: ${ borderRadius };
+ border-top: 1px solid ${borderColor};
+ border-bottom-left-radius: ${borderRadius};
+ border-bottom-right-radius: ${borderRadius};
box-sizing: border-box;
&:first-of-type {
border-top: none;
}
- ${ headerFooterSizes };
- ${ handleBorderless };
- ${ handleShady };
+ ${headerFooterSizes};
+ ${handleBorderless};
+ ${handleShady};
`;
export const DividerUI = styled( HorizontalRule )`
all: unset;
- border-top: 1px solid ${ borderColor };
+ border-top: 1px solid ${borderColor};
box-sizing: border-box;
display: block;
height: 0;
diff --git a/packages/components/src/checkbox-control/index.js b/packages/components/src/checkbox-control/index.js
index 301f0953d16d1..17437d814855e 100644
--- a/packages/components/src/checkbox-control/index.js
+++ b/packages/components/src/checkbox-control/index.js
@@ -9,7 +9,15 @@ import { Icon, check } from '@wordpress/icons';
*/
import BaseControl from '../base-control';
-export default function CheckboxControl( { label, className, heading, checked, help, onChange, ...props } ) {
+export default function CheckboxControl( {
+ label,
+ className,
+ heading,
+ checked,
+ help,
+ onChange,
+ ...props
+} ) {
const instanceId = useInstanceId( CheckboxControl );
const id = `inspector-checkbox-control-${ instanceId }`;
const onChangeValue = ( event ) => onChange( event.target.checked );
@@ -27,7 +35,13 @@ export default function CheckboxControl( { label, className, heading, checked, h
aria-describedby={ !! help ? id + '__help' : undefined }
{ ...props }
/>
- { checked ? : null }
+ { checked ? (
+
+ ) : null }
{ label }
diff --git a/packages/components/src/checkbox-control/stories/index.js b/packages/components/src/checkbox-control/stories/index.js
index 30f1e5af765d7..43bc408640e8e 100644
--- a/packages/components/src/checkbox-control/stories/index.js
+++ b/packages/components/src/checkbox-control/stories/index.js
@@ -18,24 +18,13 @@ export default { title: 'Components/CheckboxControl', component: CheckboxControl
const CheckboxControlWithState = ( { checked, ...props } ) => {
const [ isChecked, setChecked ] = useState( checked );
- return (
-
- );
+ return ;
};
export const _default = () => {
const label = text( 'Label', 'Is author' );
- return (
-
- );
+ return ;
};
export const all = () => {
@@ -43,12 +32,5 @@ export const all = () => {
const label = text( 'Label', 'Is author' );
const help = text( 'Help', 'Is the user an author or not?' );
- return (
-
- );
+ return ;
};
diff --git a/packages/components/src/circular-option-picker/index.js b/packages/components/src/circular-option-picker/index.js
index 53b4c3016c957..1a25bc4ae8b6b 100644
--- a/packages/components/src/circular-option-picker/index.js
+++ b/packages/components/src/circular-option-picker/index.js
@@ -15,39 +15,23 @@ import Button from '../button';
import Dropdown from '../dropdown';
import Tooltip from '../tooltip';
-function Option( {
- className,
- isSelected,
- tooltipText,
- ...additionalProps
-} ) {
+function Option( { className, isSelected, tooltipText, ...additionalProps } ) {
const optionButton = (
);
return (
- { tooltipText ?
- ( { optionButton } ) :
- optionButton
- }
+ { tooltipText ? { optionButton } : optionButton }
{ isSelected && }
);
}
-function DropdownLinkAction( {
- buttonProps,
- className,
- dropdownProps,
- linkText,
-} ) {
+function DropdownLinkAction( { buttonProps, className, dropdownProps, linkText } ) {
return (
(
-
+
{ linkText }
) }
@@ -69,17 +48,10 @@ function DropdownLinkAction( {
);
}
-function ButtonAction( {
- className,
- children,
- ...additionalProps
-} ) {
+function ButtonAction( { className, children, ...additionalProps } ) {
return (
{ options }
{ children }
{ actions && (
-
- { actions }
-
+ { actions }
) }
);
diff --git a/packages/components/src/clipboard-button/index.js b/packages/components/src/clipboard-button/index.js
index 091b3a26df7e9..bf008d86a4163 100644
--- a/packages/components/src/clipboard-button/index.js
+++ b/packages/components/src/clipboard-button/index.js
@@ -27,7 +27,7 @@ class ClipboardButton extends Component {
const { getText, onCopy } = this;
const container = this.containerRef.current;
- this.clipboard = new Clipboard( container.firstChild, {
+ this.clipboard = new Clipboard( container.firstChild, {
text: getText,
container,
} );
diff --git a/packages/components/src/color-indicator/stories/index.js b/packages/components/src/color-indicator/stories/index.js
index 13ccee622f7d0..f01d534ad0335 100644
--- a/packages/components/src/color-indicator/stories/index.js
+++ b/packages/components/src/color-indicator/stories/index.js
@@ -15,7 +15,5 @@ export default {
export const _default = () => {
const color = text( 'Color', '#0073aa' );
- return (
-
;
};
diff --git a/packages/components/src/color-palette/index.js b/packages/components/src/color-palette/index.js
index 9a0b1a1af4ab0..ea5d0ccfa8c8d 100644
--- a/packages/components/src/color-palette/index.js
+++ b/packages/components/src/color-palette/index.js
@@ -23,33 +23,29 @@ export default function ColorPalette( {
onChange,
value,
} ) {
- const clearColor = useCallback(
- () => onChange( undefined ),
- [ onChange ]
- );
- const colorOptions = useMemo(
- () => {
- return map( colors, ( { color, name } ) => (
-