Skip to content
Draft
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
16,724 changes: 10,883 additions & 5,841 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"identity-obj-proxy": "^3.0.0",
"lint-staged": "^16.1.0",
"newspack-components": "^3.1.0",
"newspack-scripts": "^5.5.2",
"newspack-scripts": "^5.6.0",
"postcss-scss": "^4.0.9"
},
"description": "=== Newspack Blocks === Contributors: (this should be a list of wordpress.org userid's) Donate link: https://example.com/ Tags: comments, spam Requires at least: 4.5 Tested up to: 5.1.1 Stable tag: 0.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
Expand Down
68 changes: 17 additions & 51 deletions src/blocks/author-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ import {
} from '@wordpress/components';
import { Fragment, useEffect, useState } from '@wordpress/element';
import { decodeEntities } from '@wordpress/html-entities';
import {
Icon,
columns as columnsIcon,
edit,
listView,
pullLeft,
pullRight,
} from '@wordpress/icons';
import { Icon, columns as columnsIcon, edit, listView, pullLeft, pullRight } from '@wordpress/icons';
import { __, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { avatarSizeOptions, textSizeOptions, units } from '../author-profile/edit';
Expand Down Expand Up @@ -138,12 +131,12 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
'all' === authorType
? __( 'Both guest authors and WP users', 'newspack-blocks' )
: sprintf(
// translators: currently selected author type option.
__( '%s only', 'newspack-blocks' ),
'guest-authors' === authorType
? __( 'Guest authors', 'newspack-blocks' )
: __( 'WP users', 'newspack-blocks' )
)
// translators: currently selected author type option.
__( '%s only', 'newspack-blocks' ),
'guest-authors' === authorType
? __( 'Guest authors', 'newspack-blocks' )
: __( 'WP users', 'newspack-blocks' )
)
) }
selected={ authorType || 'all' }
options={ [
Expand All @@ -169,20 +162,15 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
) }
{ 'guest-authors' !== authorType && (
<PanelRow>
<BaseControl
id="newspack-blocks__author-list-roles"
label={ __( 'WP User Roles', 'newspack-blocks' ) }
>
<BaseControl id="newspack-blocks__author-list-roles" label={ __( 'WP User Roles', 'newspack-blocks' ) }>
{ editableRoles.map( ( role, index ) => (
<CheckboxControl
checked={ -1 < authorRoles.indexOf( role ) }
key={ index }
label={ role }
value={ role }
onChange={ check => {
const selectedRoles = check
? [ ...authorRoles, role ]
: authorRoles.filter( _role => _role !== role );
const selectedRoles = check ? [ ...authorRoles, role ] : authorRoles.filter( _role => _role !== role );

setAttributes( { authorRoles: selectedRoles } );
} }
Expand All @@ -203,10 +191,7 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
<PanelRow>
<ToggleControl
label={ __( 'Group authors by alphabet', 'newspack-blocks' ) }
help={ __(
'Display each alphabetical chunk as a discrete section.',
'newspack-blocks'
) }
help={ __( 'Display each alphabetical chunk as a discrete section.', 'newspack-blocks' ) }
checked={ separatorSections }
onChange={ () => setAttributes( { separatorSections: ! separatorSections } ) }
/>
Expand All @@ -220,9 +205,7 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
help={ sprintf(
// Translators: Help message for "include empty authors" toggle.
__( 'Authors with no published posts will be %s.', 'newspack-blocks' ),
excludeEmpty
? __( 'hidden', 'newspack-blocks' )
: __( 'displayed', 'newspack-blocks' )
excludeEmpty ? __( 'hidden', 'newspack-blocks' ) : __( 'displayed', 'newspack-blocks' )
) }
checked={ excludeEmpty }
onChange={ () => setAttributes( { excludeEmpty: ! excludeEmpty } ) }
Expand Down Expand Up @@ -266,15 +249,9 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
</PanelRow>
</PanelBody>
<PanelBody title={ __( 'Author Profile Settings', 'newspack-blocks' ) }>
<BaseControl
label={ __( 'Text Size', 'newspack-blocks' ) }
id="newspack-blocks__text-size-control"
>
<BaseControl label={ __( 'Text Size', 'newspack-blocks' ) } id="newspack-blocks__text-size-control">
<PanelRow>
<ButtonGroup
id="newspack-blocks__text-size-control-buttons"
aria-label={ __( 'Text Size', 'newspack-blocks' ) }
>
<ButtonGroup id="newspack-blocks__text-size-control-buttons" aria-label={ __( 'Text Size', 'newspack-blocks' ) }>
{ textSizeOptions.map( option => {
const isCurrent = textSize === option.value;
return (
Expand Down Expand Up @@ -312,15 +289,9 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
</PanelRow>
) }
{ showAvatar && (
<BaseControl
label={ __( 'Avatar Size', 'newspack-blocks' ) }
id="newspack-blocks__avatar-size-control"
>
<BaseControl label={ __( 'Avatar Size', 'newspack-blocks' ) } id="newspack-blocks__avatar-size-control">
<PanelRow>
<ButtonGroup
id="newspack-blocks__avatar-size-control-buttons"
aria-label={ __( 'Avatar Size', 'newspack-blocks' ) }
>
<ButtonGroup id="newspack-blocks__avatar-size-control-buttons" aria-label={ __( 'Avatar Size', 'newspack-blocks' ) }>
{ avatarSizeOptions.map( option => {
const isCurrent = avatarSize === option.value;
return (
Expand All @@ -347,9 +318,7 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
__unstableInputWidth="80px"
units={ units }
value={ avatarBorderRadius }
onChange={ value =>
setAttributes( { avatarBorderRadius: 0 > parseFloat( value ) ? '0' : value } )
}
onChange={ value => setAttributes( { avatarBorderRadius: 0 > parseFloat( value ) ? '0' : value } ) }
/>
</PanelRow>
) }
Expand Down Expand Up @@ -474,10 +443,7 @@ const AuthorList = ( { attributes, clientId, setAttributes } ) => {
</>
) }
{ ( ! authors || isLoading ) && (
<Placeholder
icon={ <Icon icon={ listView } /> }
label={ __( 'Author List', 'newspack-blocks' ) }
>
<Placeholder icon={ <Icon icon={ listView } /> } label={ __( 'Author List', 'newspack-blocks' ) }>
{ error && (
<Notice status="error" isDismissible={ false }>
{ error }
Expand Down
84 changes: 17 additions & 67 deletions src/blocks/author-profile/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,22 @@ export const textSizeOptions = [
{
value: 'small',
label: /* translators: label for small text size option */ __( 'Small', 'newspack-blocks' ),
shortName: /* translators: abbreviation for small text size option */ __(
'S',
'newspack-blocks'
),
shortName: /* translators: abbreviation for small text size option */ __( 'S', 'newspack-blocks' ),
},
{
value: 'medium',
label: /* translators: label for medium text size option */ __( 'Medium', 'newspack-blocks' ),
shortName: /* translators: abbreviation for medium text size option */ __(
'M',
'newspack-blocks'
),
shortName: /* translators: abbreviation for medium text size option */ __( 'M', 'newspack-blocks' ),
},
{
value: 'large',
label: /* translators: label for small text size option */ __( 'Large', 'newspack-blocks' ),
shortName: /* translators: abbreviation for large text size option */ __(
'L',
'newspack-blocks'
),
shortName: /* translators: abbreviation for large text size option */ __( 'L', 'newspack-blocks' ),
},
{
value: 'extra-large',
label: /* translators: label for extra-large text size option */ __(
'Extra Large',
'newspack-blocks'
),
shortName: /* translators: abbreviation for small text size option */ __(
'XL',
'newspack-blocks'
),
label: /* translators: label for extra-large text size option */ __( 'Extra Large', 'newspack-blocks' ),
shortName: /* translators: abbreviation for small text size option */ __( 'XL', 'newspack-blocks' ),
},
];

Expand All @@ -98,37 +83,22 @@ export const avatarSizeOptions = [
{
value: 72,
label: /* translators: label for small avatar size option */ __( 'Small', 'newspack-blocks' ),
shortName: /* translators: abbreviation for small avatar size option */ __(
'S',
'newspack-blocks'
),
shortName: /* translators: abbreviation for small avatar size option */ __( 'S', 'newspack-blocks' ),
},
{
value: 128,
label: /* translators: label for medium avatar size option */ __( 'Medium', 'newspack-blocks' ),
shortName: /* translators: abbreviation for medium avatar size option */ __(
'M',
'newspack-blocks'
),
shortName: /* translators: abbreviation for medium avatar size option */ __( 'M', 'newspack-blocks' ),
},
{
value: 192,
label: /* translators: label for large avatar size option */ __( 'Large', 'newspack-blocks' ),
shortName: /* translators: abbreviation for large avatar size option */ __(
'L',
'newspack-blocks'
),
shortName: /* translators: abbreviation for large avatar size option */ __( 'L', 'newspack-blocks' ),
},
{
value: 256,
label: /* translators: label for extra-large avatar size option */ __(
'Extra-large',
'newspack-blocks'
),
shortName: /* translators: abbreviation for extra-large avatar size option */ __(
'XL',
'newspack-blocks'
),
label: /* translators: label for extra-large avatar size option */ __( 'Extra-large', 'newspack-blocks' ),
shortName: /* translators: abbreviation for extra-large avatar size option */ __( 'XL', 'newspack-blocks' ),
},
];

Expand Down Expand Up @@ -211,15 +181,9 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
<>
<InspectorControls>
<PanelBody title={ __( 'Author Profile Settings', 'newspack-blocks' ) }>
<BaseControl
label={ __( 'Text Size', 'newspack-blocks' ) }
id="newspack-blocks__text-size-control"
>
<BaseControl label={ __( 'Text Size', 'newspack-blocks' ) } id="newspack-blocks__text-size-control">
<PanelRow>
<ButtonGroup
id="newspack-blocks__text-size-control-buttons"
aria-label={ __( 'Text Size', 'newspack-blocks' ) }
>
<ButtonGroup id="newspack-blocks__text-size-control-buttons" aria-label={ __( 'Text Size', 'newspack-blocks' ) }>
{ textSizeOptions.map( option => {
const isCurrent = textSize === option.value;
return (
Expand Down Expand Up @@ -257,15 +221,9 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
</PanelRow>
) }
{ showAvatar && (
<BaseControl
label={ __( 'Avatar size', 'newspack-blocks' ) }
id="newspack-blocks__avatar-size-control"
>
<BaseControl label={ __( 'Avatar size', 'newspack-blocks' ) } id="newspack-blocks__avatar-size-control">
<PanelRow>
<ButtonGroup
id="newspack-blocks__avatar-size-control-buttons"
aria-label={ __( 'Avatar size', 'newspack-blocks' ) }
>
<ButtonGroup id="newspack-blocks__avatar-size-control-buttons" aria-label={ __( 'Avatar size', 'newspack-blocks' ) }>
{ avatarSizeOptions.map( option => {
const isCurrent = avatarSize === option.value;
return (
Expand All @@ -292,9 +250,7 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
__unstableInputWidth="80px"
units={ units }
value={ avatarBorderRadius }
onChange={ value =>
setAttributes( { avatarBorderRadius: 0 > parseFloat( value ) ? '0' : value } )
}
onChange={ value => setAttributes( { avatarBorderRadius: 0 > parseFloat( value ) ? '0' : value } ) }
/>
</PanelRow>
) }
Expand Down Expand Up @@ -356,10 +312,7 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
{ ! isLoading && (
<AutocompleteWithSuggestions
label={ __( 'Search for an author to display', 'newspack-blocks' ) }
help={ __(
'Begin typing name, click autocomplete result to select.',
'newspack-blocks'
) }
help={ __( 'Begin typing name, click autocomplete result to select.', 'newspack-blocks' ) }
fetchSuggestions={ async ( search = null, offset = 0 ) => {
// Reset suggestions in state.
setSuggestions( null );
Expand Down Expand Up @@ -404,10 +357,7 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
// We need to check whether the selected author is a guest author or not.
if ( suggestions ) {
suggestions.forEach( suggestion => {
if (
parseInt( selection?.value ) === parseInt( suggestion?.value ) &&
suggestion?.isGuestAuthor
) {
if ( parseInt( selection?.value ) === parseInt( suggestion?.value ) && suggestion?.isGuestAuthor ) {
selectionIsGuest = true;
}
} );
Expand Down
42 changes: 9 additions & 33 deletions src/blocks/author-profile/single-author.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ const MaybeLink = ( { author, children, showArchiveLink } ) =>
);

export const SingleAuthor = ( { author, attributes } ) => {
const {
showBio,
showSocial,
showEmail,
showArchiveLink,
showAvatar,
textSize,
avatarAlignment,
avatarBorderRadius,
avatarSize,
} = attributes;
const { showBio, showSocial, showEmail, showArchiveLink, showAvatar, textSize, avatarAlignment, avatarBorderRadius, avatarSize } = attributes;

// Combine social links and email, which are shown together.
const socialLinks = ( showSocial && author && author.social ) || {};
Expand All @@ -48,22 +38,16 @@ export const SingleAuthor = ( { author, attributes } ) => {
delete socialLinks.newspack_phone_number;
}

const employment = [
attributes.shownewspack_role && author.newspack_role,
attributes.shownewspack_employer && author.newspack_employer,
]
const employment = [ attributes.shownewspack_role && author.newspack_role, attributes.shownewspack_employer && author.newspack_employer ]
.filter( Boolean )
.join( ', ' );
const socialLinksItems = Object.keys( socialLinks );

return (
<div
className={ classnames(
'wp-block-newspack-blocks-author-profile',
'avatar-' + avatarAlignment,
'text-size-' + textSize,
{ 'is-style-center': 'is-style-center' === attributes.className }
) }
className={ classnames( 'wp-block-newspack-blocks-author-profile', 'avatar-' + avatarAlignment, 'text-size-' + textSize, {
'is-style-center': 'is-style-center' === attributes.className,
} ) }
>
{ showAvatar && author.avatar && (
<div className="wp-block-newspack-blocks-author-profile__avatar">
Expand All @@ -84,13 +68,9 @@ export const SingleAuthor = ( { author, attributes } ) => {
</MaybeLink>
</h3>
{ attributes.shownewspack_job_title && author.newspack_job_title && (
<p className="wp-block-newspack-blocks-author-profile__job-title">
{ author.newspack_job_title }
</p>
) }
{ employment && (
<p className="wp-block-newspack-blocks-author-profile__employment">{ employment }</p>
<p className="wp-block-newspack-blocks-author-profile__job-title">{ author.newspack_job_title }</p>
) }
{ employment && <p className="wp-block-newspack-blocks-author-profile__employment">{ employment }</p> }
{ showBio && author.bio && (
<p>
<RawHTML>{ autop( author.bio ) } </RawHTML>
Expand All @@ -106,12 +86,8 @@ export const SingleAuthor = ( { author, attributes } ) => {
{ socialLinksItems.map( service => (
<li key={ service }>
<a href="#" className="no-op">
{ socialLinks[ service ].svg && (
<span dangerouslySetInnerHTML={ { __html: socialLinks[ service ].svg } } />
) }
<span className={ socialLinks[ service ].svg ? 'hidden' : 'visible' }>
{ service }
</span>
{ socialLinks[ service ].svg && <span dangerouslySetInnerHTML={ { __html: socialLinks[ service ].svg } } /> }
<span className={ socialLinks[ service ].svg ? 'hidden' : 'visible' }>{ service }</span>
</a>
</li>
) ) }
Expand Down
Loading