From bb35aaf7b15414a52760b33caa612e62fc53a35e Mon Sep 17 00:00:00 2001 From: David Ryan Date: Wed, 20 Nov 2019 21:58:27 -0700 Subject: [PATCH 01/10] add aria-label to social link block --- .../block-library/src/social-link/edit.js | 80 +++-- .../block-library/src/social-link/index.js | 3 + .../block-library/src/social-link/index.php | 315 +++++++++++------- .../src/social-link/social-list.js | 4 + 4 files changed, 250 insertions(+), 152 deletions(-) diff --git a/packages/block-library/src/social-link/edit.js b/packages/block-library/src/social-link/edit.js index 986de58e60b92..6475c20d7a083 100644 --- a/packages/block-library/src/social-link/edit.js +++ b/packages/block-library/src/social-link/edit.js @@ -6,21 +6,24 @@ import classNames from 'classnames'; /** * WordPress dependencies */ -import { URLPopover } from '@wordpress/block-editor'; -import { useState } from '@wordpress/element'; +import { InspectorControls, URLPopover } from '@wordpress/block-editor'; +import { Fragment, useState } from '@wordpress/element'; import { Button, IconButton, + PanelBody, + PanelRow, + TextControl, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ -import { getIconBySite } from './social-list'; +import { getIconBySite, getNameBySite } from './social-list'; const SocialLinkEdit = ( { attributes, setAttributes, isSelected } ) => { - const { url, site } = attributes; + const { url, site, label } = attributes; const [ showURLPopover, setPopover ] = useState( false ); const classes = classNames( 'wp-social-link', @@ -30,35 +33,50 @@ const SocialLinkEdit = ( { attributes, setAttributes, isSelected } ) => { // Import icon. const IconComponent = getIconBySite( site ); + const SocialLinkName = getNameBySite( site ); return ( - + + + + + setAttributes( { label: value } ) } + /> + + + + + ); }; diff --git a/packages/block-library/src/social-link/index.js b/packages/block-library/src/social-link/index.js index 692ff27f82fa5..a601364431025 100644 --- a/packages/block-library/src/social-link/index.js +++ b/packages/block-library/src/social-link/index.js @@ -38,6 +38,9 @@ export const sites = Object.keys( socialList ).map( type: 'string', default: site, }, + label: { + type: 'string', + }, }, }, }; diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index 86d83b685e21e..d9b58b52f97c7 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -13,8 +13,9 @@ * @return string Rendered HTML of the referenced block. */ function render_core_social_link( $attributes ) { - $site = ( isset( $attributes['site'] ) ) ? $attributes['site'] : 'Icon'; - $url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false; + $site = ( isset( $attributes['site'] ) ) ? $attributes['site'] : 'Icon'; + $url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false; + $label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : __( 'Link to ' ) . core_social_link_get_name( $site ); // Don't render a link if there is no URL set. if ( ! $url ) { @@ -22,7 +23,7 @@ function render_core_social_link( $attributes ) { } $icon = core_social_link_get_icon( $site ); - return ''; + return ''; } /** @@ -83,6 +84,9 @@ function register_block_core_social_link() { 'type' => 'string', 'default' => $site, ), + 'label' => array( + 'type' => 'string', + ), ), 'render_callback' => 'render_core_social_link', ) @@ -100,128 +104,197 @@ function register_block_core_social_link() { * @return string SVG Element for site icon. */ function core_social_link_get_icon( $site ) { - switch ( $site ) { - - case 'fivehundredpx': - return ''; - - case 'amazon': - return ''; - - case 'bandcamp': - return ''; - - case 'behance': - return ''; - - case 'chain': - return ''; - - case 'codepen': - return ''; - - case 'deviantart': - return ''; - - case 'dribbble': - return ''; - - case 'dropbox': - return ''; - - case 'etsy': - return ''; - - case 'facebook': - return ''; - - case 'feed': - return ''; - - case 'flickr': - return ''; - - case 'foursquare': - return ''; - - case 'goodreads': - return ''; - - case 'google': - return ''; - - case 'github': - return ''; - - case 'instagram': - return ''; - - case 'lastfm': - return ''; - - case 'linkedin': - return ''; - - case 'mail': - return ''; - - case 'mastodon': - return ''; - - case 'meetup': - return ''; - - case 'medium': - return ''; - - case 'pinterest': - return ''; - - case 'pocket': - return ''; - - case 'reddit': - return ''; - - case 'skype': - return ''; - - case 'snapchat': - return ''; - - case 'soundcloud': - return ''; - - case 'spotify': - return ''; - - case 'tumblr': - return ''; - - case 'twitch': - return ''; - - case 'twitter': - return ''; - - case 'vimeo': - return ''; + $sites = core_social_link_sites(); + if ( isset( $sites[ $site ] ) && isset( $sites[ $site ]['icon'] ) ) { + return $sites[ $site ][ 'icon' ]; + } - case 'vk': - return ''; + return $sites['share']['icon']; +} - // phpcs:disable WordPress.WP.CapitalPDangit.Misspelled - case 'wordpress': - return ''; +function core_social_link_get_name( $site ) { + $sites = core_social_link_sites(); + if ( isset( $sites[ $site ] ) && isset( $sites[ $site ]['name'] ) ) { + return $sites[ $site ][ 'name' ]; + } - case 'yelp': - return ''; + return $sites['share']['name']; +} - case 'youtube': - return ''; +function core_social_link_sites( $site = '', $field = '' ) { + $sites_data = array( + 'fivehundredpx' => array( + 'name' => '500px', + 'icon' => '', + ), + 'amazon' => array( + 'name' => 'Amazon', + 'icon' => '' + ), + 'bandcamp' => array( + 'name' => 'Bandcamp', + 'icon' => '' + ), + 'behance' => array( + 'name' => 'Behance', + 'icon' => '' + ), + 'chain' => array( + 'name' => 'Link', + 'icon' => '' + ), + 'codepen' => array( + 'name' => 'CodePen', + 'icon' => '' + ), + 'deviantart' => array( + 'name' => 'DeviantArt', + 'icon' => '' + ), + 'dribbble' => array( + 'name' => 'Dribbble', + 'icon' => '' + ), + 'dropbox' => array( + 'name' => 'Dropbox', + 'icon' => '' + ), + 'etsy' => array( + 'name' => 'Etsy', + 'icon' => '' + ), + 'facebook' => array( + 'name' => 'Facebook', + 'icon' => '' + ), + 'feed' => array( + 'name' => 'RSS Feed', + 'icon' => '' + ), + 'flickr' => array( + 'name' => 'Flickr', + 'icon' => '' + ), + 'foursquare' => array( + 'name' => 'Foursquare', + 'icon' => '' + ), + 'goodreads' => array( + 'name' => 'Goodreads', + 'icon' => '' + ), + 'google' => array( + 'name' => 'Google', + 'icon' => '' + ), + 'github' => array( + 'name' => 'Github', + 'icon' => '' + ), + 'instagram' => array( + 'name' => 'Instagram', + 'icon' => '' + ), + 'lastfm' => array( + 'name' => 'Last.fm', + 'icon' => '' + ), + 'linkedin' => array( + 'name' => 'Linkedin', + 'icon' => '' + ), + 'mail' => array( + 'name' => 'Mail', + 'icon' => '' + ), + 'mastodon' => array( + 'name' => 'Mastodon', + 'icon' => '' + ), + 'meetup' => array( + 'name' => 'Meetup', + 'icon' => '' + ), + 'medium' => array( + 'name' => 'Medium', + 'icon' => '' + ), + 'pinterest' => array( + 'name' => 'Pinterest', + 'icon' => '' + ), + 'pocket' => array( + 'name' => 'Pocket', + 'icon' => '' + ), + 'reddit' => array( + 'name' => 'Reddit', + 'icon' => '' + ), + 'skype' => array( + 'name' => 'Skype', + 'icon' => '' + ), + 'snapchat' => array( + 'name' => 'Snapchat', + 'icon' => '' + ), + 'soundcloud' => array( + 'name' => 'Soundcloud', + 'icon' => '' + ), + 'spotify' => array( + 'name' => 'Spotify', + 'icon' => '' + ), + 'tumblr' => array( + 'name' => 'Tumblr', + 'icon' => '' + ), + 'twitch' => array( + 'name' => 'Twitch', + 'icon' => '' + ), + 'twitter' => array( + 'name' => 'Twitter', + 'icon' => '' + ), + 'vimeo' => array( + 'name' => 'Vimeo', + 'icon' => '' + ), + 'vk' => array( + 'name' => 'VK', + 'icon' => '' + ), + 'wordpress' => array( + 'name' => 'WordPress', + 'icon' => '' + ), + 'yelp' => array( + 'name' => 'Yelp', + 'icon' => '' + ), + 'youtube' => array( + 'name' => 'YouTube', + 'icon' => '' + ), + 'share' => array( + 'name' => 'Share Icon', + 'icon' => '' + ), + ); - case 'share': - default: - return ''; + if ( + ! empty( $site ) + && ! empty( $field ) + && isset( $sites_data[ $site ] ) + && ( 'icon' === $field || 'label' === $field ) + ) { + return $sites_data[ $site ][ $field ]; + } elseif ( ! empty( $site ) && isset( $sites_data[ $site ] ) ) { + return $sites_data[ $site ]; } + + return $sites_data; } diff --git a/packages/block-library/src/social-link/social-list.js b/packages/block-library/src/social-link/social-list.js index 98c8120449c5a..4801c1cc3c2c7 100644 --- a/packages/block-library/src/social-link/social-list.js +++ b/packages/block-library/src/social-link/social-list.js @@ -207,3 +207,7 @@ export default socialList; export const getIconBySite = ( site ) => { return socialList[ site ].icon; }; + +export const getNameBySite = ( site ) => { + return socialList[ site ].name; +}; From aadde3773c29e5def7dd8f87acaab6cc175cb546 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Wed, 20 Nov 2019 22:45:58 -0700 Subject: [PATCH 02/10] phpcs codesmells --- .../block-library/src/social-link/index.php | 261 +++++++++--------- 1 file changed, 130 insertions(+), 131 deletions(-) diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index d9b58b52f97c7..a49bc57506412 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -13,9 +13,9 @@ * @return string Rendered HTML of the referenced block. */ function render_core_social_link( $attributes ) { - $site = ( isset( $attributes['site'] ) ) ? $attributes['site'] : 'Icon'; - $url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false; - $label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : __( 'Link to ' ) . core_social_link_get_name( $site ); + $site = ( isset( $attributes['site'] ) ) ? $attributes['site'] : 'Icon'; + $url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false; + $label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : __( 'Link to ' ) . core_social_link_get_name( $site ); // Don't render a link if there is no URL set. if ( ! $url ) { @@ -23,7 +23,7 @@ function render_core_social_link( $attributes ) { } $icon = core_social_link_get_icon( $site ); - return ''; + return ''; } /** @@ -77,10 +77,10 @@ function register_block_core_social_link() { 'core/social-link-' . $site, array( 'attributes' => array( - 'url' => array( + 'url' => array( 'type' => 'string', ), - 'site' => array( + 'site' => array( 'type' => 'string', 'default' => $site, ), @@ -106,7 +106,7 @@ function register_block_core_social_link() { function core_social_link_get_icon( $site ) { $sites = core_social_link_sites(); if ( isset( $sites[ $site ] ) && isset( $sites[ $site ]['icon'] ) ) { - return $sites[ $site ][ 'icon' ]; + return $sites[ $site ]['icon']; } return $sites['share']['icon']; @@ -115,7 +115,7 @@ function core_social_link_get_icon( $site ) { function core_social_link_get_name( $site ) { $sites = core_social_link_sites(); if ( isset( $sites[ $site ] ) && isset( $sites[ $site ]['name'] ) ) { - return $sites[ $site ][ 'name' ]; + return $sites[ $site ]['name']; } return $sites['share']['name']; @@ -124,172 +124,171 @@ function core_social_link_get_name( $site ) { function core_social_link_sites( $site = '', $field = '' ) { $sites_data = array( 'fivehundredpx' => array( - 'name' => '500px', - 'icon' => '', + 'name' => '500px', + 'icon' => '', ), - 'amazon' => array( - 'name' => 'Amazon', - 'icon' => '' + 'amazon' => array( + 'name' => 'Amazon', + 'icon' => '', ), - 'bandcamp' => array( - 'name' => 'Bandcamp', - 'icon' => '' + 'bandcamp' => array( + 'name' => 'Bandcamp', + 'icon' => '', ), - 'behance' => array( - 'name' => 'Behance', - 'icon' => '' + 'behance' => array( + 'name' => 'Behance', + 'icon' => '', ), - 'chain' => array( - 'name' => 'Link', - 'icon' => '' + 'chain' => array( + 'name' => 'Link', + 'icon' => '', ), - 'codepen' => array( - 'name' => 'CodePen', - 'icon' => '' + 'codepen' => array( + 'name' => 'CodePen', + 'icon' => '', ), - 'deviantart' => array( - 'name' => 'DeviantArt', - 'icon' => '' + 'deviantart' => array( + 'name' => 'DeviantArt', + 'icon' => '', ), - 'dribbble' => array( - 'name' => 'Dribbble', - 'icon' => '' + 'dribbble' => array( + 'name' => 'Dribbble', + 'icon' => '', ), - 'dropbox' => array( - 'name' => 'Dropbox', - 'icon' => '' + 'dropbox' => array( + 'name' => 'Dropbox', + 'icon' => '', ), - 'etsy' => array( - 'name' => 'Etsy', - 'icon' => '' + 'etsy' => array( + 'name' => 'Etsy', + 'icon' => '', ), - 'facebook' => array( - 'name' => 'Facebook', - 'icon' => '' + 'facebook' => array( + 'name' => 'Facebook', + 'icon' => '', ), - 'feed' => array( - 'name' => 'RSS Feed', - 'icon' => '' + 'feed' => array( + 'name' => 'RSS Feed', + 'icon' => '', ), - 'flickr' => array( - 'name' => 'Flickr', - 'icon' => '' + 'flickr' => array( + 'name' => 'Flickr', + 'icon' => '', ), - 'foursquare' => array( - 'name' => 'Foursquare', - 'icon' => '' + 'foursquare' => array( + 'name' => 'Foursquare', + 'icon' => '', ), - 'goodreads' => array( - 'name' => 'Goodreads', - 'icon' => '' + 'goodreads' => array( + 'name' => 'Goodreads', + 'icon' => '', ), - 'google' => array( - 'name' => 'Google', - 'icon' => '' + 'google' => array( + 'name' => 'Google', + 'icon' => '', ), - 'github' => array( - 'name' => 'Github', - 'icon' => '' + 'github' => array( + 'name' => 'Github', + 'icon' => '', ), - 'instagram' => array( - 'name' => 'Instagram', - 'icon' => '' + 'instagram' => array( + 'name' => 'Instagram', + 'icon' => '', ), - 'lastfm' => array( - 'name' => 'Last.fm', - 'icon' => '' + 'lastfm' => array( + 'name' => 'Last.fm', + 'icon' => '', ), - 'linkedin' => array( - 'name' => 'Linkedin', - 'icon' => '' + 'linkedin' => array( + 'name' => 'Linkedin', + 'icon' => '', ), - 'mail' => array( - 'name' => 'Mail', - 'icon' => '' + 'mail' => array( + 'name' => 'Mail', + 'icon' => '', ), - 'mastodon' => array( - 'name' => 'Mastodon', - 'icon' => '' + 'mastodon' => array( + 'name' => 'Mastodon', + 'icon' => '', ), - 'meetup' => array( - 'name' => 'Meetup', - 'icon' => '' + 'meetup' => array( + 'name' => 'Meetup', + 'icon' => '', ), - 'medium' => array( - 'name' => 'Medium', - 'icon' => '' + 'medium' => array( + 'name' => 'Medium', + 'icon' => '', ), - 'pinterest' => array( - 'name' => 'Pinterest', - 'icon' => '' + 'pinterest' => array( + 'name' => 'Pinterest', + 'icon' => '', ), - 'pocket' => array( - 'name' => 'Pocket', - 'icon' => '' + 'pocket' => array( + 'name' => 'Pocket', + 'icon' => '', ), - 'reddit' => array( - 'name' => 'Reddit', - 'icon' => '' + 'reddit' => array( + 'name' => 'Reddit', + 'icon' => '', ), - 'skype' => array( - 'name' => 'Skype', - 'icon' => '' + 'skype' => array( + 'name' => 'Skype', + 'icon' => '', ), - 'snapchat' => array( - 'name' => 'Snapchat', - 'icon' => '' + 'snapchat' => array( + 'name' => 'Snapchat', + 'icon' => '', ), - 'soundcloud' => array( - 'name' => 'Soundcloud', - 'icon' => '' + 'soundcloud' => array( + 'name' => 'Soundcloud', + 'icon' => '', ), - 'spotify' => array( - 'name' => 'Spotify', - 'icon' => '' + 'spotify' => array( + 'name' => 'Spotify', + 'icon' => '', ), - 'tumblr' => array( - 'name' => 'Tumblr', - 'icon' => '' + 'tumblr' => array( + 'name' => 'Tumblr', + 'icon' => '', ), - 'twitch' => array( - 'name' => 'Twitch', - 'icon' => '' + 'twitch' => array( + 'name' => 'Twitch', + 'icon' => '', ), - 'twitter' => array( - 'name' => 'Twitter', - 'icon' => '' + 'twitter' => array( + 'name' => 'Twitter', + 'icon' => '', ), - 'vimeo' => array( - 'name' => 'Vimeo', - 'icon' => '' + 'vimeo' => array( + 'name' => 'Vimeo', + 'icon' => '', ), - 'vk' => array( - 'name' => 'VK', - 'icon' => '' + 'vk' => array( + 'name' => 'VK', + 'icon' => '', ), - 'wordpress' => array( - 'name' => 'WordPress', - 'icon' => '' + 'wordpress' => array( + 'name' => 'WordPress', + 'icon' => '', ), - 'yelp' => array( - 'name' => 'Yelp', - 'icon' => '' + 'yelp' => array( + 'name' => 'Yelp', + 'icon' => '', ), - 'youtube' => array( - 'name' => 'YouTube', - 'icon' => '' + 'youtube' => array( + 'name' => 'YouTube', + 'icon' => '', ), - 'share' => array( - 'name' => 'Share Icon', - 'icon' => '' + 'share' => array( + 'name' => 'Share Icon', + 'icon' => '', ), ); - if ( - ! empty( $site ) - && ! empty( $field ) + if ( ! empty( $site ) + && ! empty( $field ) && isset( $sites_data[ $site ] ) - && ( 'icon' === $field || 'label' === $field ) + && ( 'icon' === $field || 'label' === $field ) ) { return $sites_data[ $site ][ $field ]; } elseif ( ! empty( $site ) && isset( $sites_data[ $site ] ) ) { From fcee78e82d5bb3af1602cf40bd4875528b87592a Mon Sep 17 00:00:00 2001 From: David Ryan Date: Wed, 20 Nov 2019 22:59:58 -0700 Subject: [PATCH 03/10] phpcs docblock and one bad array key --- .../block-library/src/social-link/index.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index a49bc57506412..35586f4bd54dd 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -112,6 +112,13 @@ function core_social_link_get_icon( $site ) { return $sites['share']['icon']; } +/** + * Returns the brand name for social link. + * + * @param string $site The site icon. + * + * @return string Brand label. + */ function core_social_link_get_name( $site ) { $sites = core_social_link_sites(); if ( isset( $sites[ $site ] ) && isset( $sites[ $site ]['name'] ) ) { @@ -121,6 +128,14 @@ function core_social_link_get_name( $site ) { return $sites['share']['name']; } +/** + * Returns the SVG for social link. + * + * @param string $site The site slug to extract data from. + * @param string $field The field ('name', 'icon', etc) to extract for a site. + * + * @return array|string + */ function core_social_link_sites( $site = '', $field = '' ) { $sites_data = array( 'fivehundredpx' => array( @@ -288,7 +303,7 @@ function core_social_link_sites( $site = '', $field = '' ) { if ( ! empty( $site ) && ! empty( $field ) && isset( $sites_data[ $site ] ) - && ( 'icon' === $field || 'label' === $field ) + && ( 'icon' === $field || 'name' === $field ) ) { return $sites_data[ $site ][ $field ]; } elseif ( ! empty( $site ) && isset( $sites_data[ $site ] ) ) { From c9ffe6bed5e1dbf2c9b1c4469162ca6f52f7fba4 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Mon, 2 Dec 2019 18:40:02 -0700 Subject: [PATCH 04/10] social link brand spellings --- .../src/social-link/icons/deviantart.js | 2 +- .../src/social-link/icons/github.js | 2 +- .../src/social-link/icons/linkedin.js | 2 +- .../src/social-link/icons/soundcloud.js | 2 +- .../src/social-link/icons/youtube.js | 2 +- .../block-library/src/social-link/index.php | 12 +++++++++ .../src/social-link/social-list.js | 26 +++++++++---------- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/packages/block-library/src/social-link/icons/deviantart.js b/packages/block-library/src/social-link/icons/deviantart.js index 17b2c25f832fb..f0724f09f6c45 100644 --- a/packages/block-library/src/social-link/icons/deviantart.js +++ b/packages/block-library/src/social-link/icons/deviantart.js @@ -7,7 +7,7 @@ import { SVG, } from '@wordpress/components'; -export const DeviantartIcon = ( ) => ( +export const DeviantArtIcon = ( ) => ( diff --git a/packages/block-library/src/social-link/icons/github.js b/packages/block-library/src/social-link/icons/github.js index 4dfcd29a971c3..37a65e13d0bea 100644 --- a/packages/block-library/src/social-link/icons/github.js +++ b/packages/block-library/src/social-link/icons/github.js @@ -7,7 +7,7 @@ import { SVG, } from '@wordpress/components'; -export const GithubIcon = ( ) => ( +export const GitHubIcon = ( ) => ( diff --git a/packages/block-library/src/social-link/icons/linkedin.js b/packages/block-library/src/social-link/icons/linkedin.js index 98cec8a81ca0f..41b287c19ab03 100644 --- a/packages/block-library/src/social-link/icons/linkedin.js +++ b/packages/block-library/src/social-link/icons/linkedin.js @@ -7,7 +7,7 @@ import { SVG, } from '@wordpress/components'; -export const LinkedinIcon = ( ) => ( +export const LinkedInIcon = ( ) => ( diff --git a/packages/block-library/src/social-link/icons/soundcloud.js b/packages/block-library/src/social-link/icons/soundcloud.js index 9df4e0af59bc4..558f52f547c2b 100644 --- a/packages/block-library/src/social-link/icons/soundcloud.js +++ b/packages/block-library/src/social-link/icons/soundcloud.js @@ -7,7 +7,7 @@ import { SVG, } from '@wordpress/components'; -export const SoundcloudIcon = ( ) => ( +export const SoundCloudIcon = ( ) => ( diff --git a/packages/block-library/src/social-link/icons/youtube.js b/packages/block-library/src/social-link/icons/youtube.js index 0e822aa5b4f4d..35eca5e5d8af3 100644 --- a/packages/block-library/src/social-link/icons/youtube.js +++ b/packages/block-library/src/social-link/icons/youtube.js @@ -7,7 +7,7 @@ import { SVG, } from '@wordpress/components'; -export const YoutubeIcon = ( ) => ( +export const YouTubeIcon = ( ) => ( diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index 35586f4bd54dd..854f604b0c36d 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -202,9 +202,15 @@ function core_social_link_sites( $site = '', $field = '' ) { 'name' => 'Google', 'icon' => '', ), +<<<<<<< Updated upstream 'github' => array( 'name' => 'Github', 'icon' => '', +======= + 'github' => array( + 'name' => 'GitHub', + 'icon' => '' +>>>>>>> Stashed changes ), 'instagram' => array( 'name' => 'Instagram', @@ -214,9 +220,15 @@ function core_social_link_sites( $site = '', $field = '' ) { 'name' => 'Last.fm', 'icon' => '', ), +<<<<<<< Updated upstream 'linkedin' => array( 'name' => 'Linkedin', 'icon' => '', +======= + 'linkedin' => array( + 'name' => 'LinkedIn', + 'icon' => '' +>>>>>>> Stashed changes ), 'mail' => array( 'name' => 'Mail', diff --git a/packages/block-library/src/social-link/social-list.js b/packages/block-library/src/social-link/social-list.js index 4801c1cc3c2c7..83e790fa156ff 100644 --- a/packages/block-library/src/social-link/social-list.js +++ b/packages/block-library/src/social-link/social-list.js @@ -7,7 +7,7 @@ import { BehanceIcon, ChainIcon, CodepenIcon, - DeviantartIcon, + DeviantArtIcon, DribbbleIcon, DropboxIcon, EtsyIcon, @@ -18,10 +18,10 @@ import { FoursquareIcon, GoodreadsIcon, GoogleIcon, - GithubIcon, + GitHubIcon, InstagramIcon, LastfmIcon, - LinkedinIcon, + LinkedInIcon, MailIcon, MastodonIcon, MeetupIcon, @@ -31,7 +31,7 @@ import { RedditIcon, SkypeIcon, SnapchatIcon, - SoundcloudIcon, + SoundCloudIcon, SpotifyIcon, TumblrIcon, TwitchIcon, @@ -40,7 +40,7 @@ import { VkIcon, WordPressIcon, YelpIcon, - YoutubeIcon, + YouTubeIcon, } from './icons'; const socialList = { @@ -70,7 +70,7 @@ const socialList = { }, deviantart: { name: 'DeviantArt', - icon: DeviantartIcon, + icon: DeviantArtIcon, }, dribbble: { name: 'Dribbble', @@ -109,8 +109,8 @@ const socialList = { icon: GoogleIcon, }, github: { - name: 'Github', - icon: GithubIcon, + name: 'GitHub', + icon: GitHubIcon, }, instagram: { name: 'Instagram', @@ -121,8 +121,8 @@ const socialList = { icon: LastfmIcon, }, linkedin: { - name: 'Linkedin', - icon: LinkedinIcon, + name: 'LinkedIn', + icon: LinkedInIcon, }, mail: { name: 'Mail', @@ -161,8 +161,8 @@ const socialList = { icon: SnapchatIcon, }, soundcloud: { - name: 'Soundcloud', - icon: SoundcloudIcon, + name: 'SoundCloud', + icon: SoundCloudIcon, }, spotify: { name: 'Spotify', @@ -198,7 +198,7 @@ const socialList = { }, youtube: { name: 'YouTube', - icon: YoutubeIcon, + icon: YouTubeIcon, }, }; From 05541ca97f3d0ac03dc2b5a00c21123a4c757d71 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Mon, 2 Dec 2019 18:40:20 -0700 Subject: [PATCH 05/10] sidebar helper text --- packages/block-library/src/social-link/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/social-link/edit.js b/packages/block-library/src/social-link/edit.js index 6475c20d7a083..3adb94435ac2e 100644 --- a/packages/block-library/src/social-link/edit.js +++ b/packages/block-library/src/social-link/edit.js @@ -42,7 +42,7 @@ const SocialLinkEdit = ( { attributes, setAttributes, isSelected } ) => { setAttributes( { label: value } ) } /> From f3bda4969877807446ba7f504bec878900f82a0e Mon Sep 17 00:00:00 2001 From: David Ryan Date: Wed, 25 Dec 2019 18:14:10 -0700 Subject: [PATCH 06/10] addressing feedback --- packages/block-library/src/social-link/edit.js | 6 +++--- packages/block-library/src/social-link/index.php | 12 ------------ .../block-library/src/social-link/social-list.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/social-link/edit.js b/packages/block-library/src/social-link/edit.js index 3adb94435ac2e..57f1ebd87b993 100644 --- a/packages/block-library/src/social-link/edit.js +++ b/packages/block-library/src/social-link/edit.js @@ -15,7 +15,7 @@ import { PanelRow, TextControl, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies @@ -33,12 +33,12 @@ const SocialLinkEdit = ( { attributes, setAttributes, isSelected } ) => { // Import icon. const IconComponent = getIconBySite( site ); - const SocialLinkName = getNameBySite( site ); + const socialLinkName = getNameBySite( site ); return ( - + 'Google', 'icon' => '', ), -<<<<<<< Updated upstream - 'github' => array( - 'name' => 'Github', - 'icon' => '', -======= 'github' => array( 'name' => 'GitHub', 'icon' => '' ->>>>>>> Stashed changes ), 'instagram' => array( 'name' => 'Instagram', @@ -220,15 +214,9 @@ function core_social_link_sites( $site = '', $field = '' ) { 'name' => 'Last.fm', 'icon' => '', ), -<<<<<<< Updated upstream - 'linkedin' => array( - 'name' => 'Linkedin', - 'icon' => '', -======= 'linkedin' => array( 'name' => 'LinkedIn', 'icon' => '' ->>>>>>> Stashed changes ), 'mail' => array( 'name' => 'Mail', diff --git a/packages/block-library/src/social-link/social-list.js b/packages/block-library/src/social-link/social-list.js index 83e790fa156ff..47d598e643e14 100644 --- a/packages/block-library/src/social-link/social-list.js +++ b/packages/block-library/src/social-link/social-list.js @@ -204,10 +204,24 @@ const socialList = { export default socialList; +/** + * Retrieves the social service's icon component. + * + * @param {string} site key for a social service (lowercase slug) + * + * @return {WPComponent} Icon component for social service. + */ export const getIconBySite = ( site ) => { return socialList[ site ].icon; }; +/** + * Retrieves the display name for the social service. + * + * @param {string} site key for a social service (lowercase slug) + * + * @return {string} Display name for social service + */ export const getNameBySite = ( site ) => { return socialList[ site ].name; }; From 982b894ca448022fa175c5b1880833ed3013bbcc Mon Sep 17 00:00:00 2001 From: David Ryan Date: Wed, 25 Dec 2019 18:30:01 -0700 Subject: [PATCH 07/10] linting --- packages/block-library/src/social-link/edit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/social-link/edit.js b/packages/block-library/src/social-link/edit.js index b24f4ec977594..f859d0eb08bda 100644 --- a/packages/block-library/src/social-link/edit.js +++ b/packages/block-library/src/social-link/edit.js @@ -65,13 +65,13 @@ const SocialLinkEdit = ( { attributes, setAttributes, isSelected } ) => { } } >
setAttributes( { url: nextURL } ) } - placeholder={ __( 'Enter Address' ) } - disableSuggestions={ true } + value={ url } + onChange={ ( nextURL ) => setAttributes( { url: nextURL } ) } + placeholder={ __( 'Enter Address' ) } + disableSuggestions={ true } />
-