Skip to content

Commit

Permalink
prep build 05/06
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed May 6, 2024
2 parents 1a0486c + ccf9d33 commit b8f2437
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/block-supports/background.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ function gutenberg_render_background_support( $block_content, $block ) {
}

$background_styles = array();
$background_styles['backgroundSize'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover';
$background_styles['backgroundImage'] = isset( $block_attributes['style']['background']['backgroundImage'] ) ? $block_attributes['style']['background']['backgroundImage'] : array();

if ( isset( $background_styles['backgroundImage']['source'] ) && 'file' === $background_styles['backgroundImage']['source'] && isset( $background_styles['backgroundImage']['url'] ) ) {
if ( ! empty( $background_styles['backgroundImage'] ) ) {
$background_styles['backgroundSize'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover';
$background_styles['backgroundPosition'] = isset( $block_attributes['style']['background']['backgroundPosition'] ) ? $block_attributes['style']['background']['backgroundPosition'] : null;
$background_styles['backgroundRepeat'] = isset( $block_attributes['style']['background']['backgroundRepeat'] ) ? $block_attributes['style']['background']['backgroundRepeat'] : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe( 'getGlobalStylesChanges and utils', () => {
background: {
backgroundImage: {
url: 'https://example.com/image.jpg',
source: 'file',
},
backgroundSize: 'contain',
backgroundPosition: '30% 30%',
Expand Down Expand Up @@ -96,7 +95,6 @@ describe( 'getGlobalStylesChanges and utils', () => {
background: {
backgroundImage: {
url: 'https://example.com/image_new.jpg',
source: 'file',
},
backgroundSize: 'contain',
backgroundPosition: '40% 77%',
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function setBackgroundStyleDefaults( backgroundStyle ) {
let backgroundStylesWithDefaults;

// Set block background defaults.
if ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) {
if ( !! backgroundImage?.url ) {
if ( ! backgroundStyle?.backgroundSize ) {
backgroundStylesWithDefaults = {
backgroundSize: 'cover',
Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/embed/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,12 @@ export const embedPocketCastsIcon = {
</SVG>
),
};

export const embedBlueskyIcon = (
<SVG viewBox="0 0 24 24">
<Path
fill="#0a7aff"
d="M6.3,4.2c2.3,1.7,4.8,5.3,5.7,7.2.9-1.9,3.4-5.4,5.7-7.2,1.7-1.3,4.3-2.2,4.3.9s-.4,5.2-.6,5.9c-.7,2.6-3.3,3.2-5.6,2.8,4,.7,5.1,3,2.9,5.3-5,5.2-6.7-2.8-6.7-2.8,0,0-1.7,8-6.7,2.8-2.2-2.3-1.2-4.6,2.9-5.3-2.3.4-4.9-.3-5.6-2.8-.2-.7-.6-5.3-.6-5.9,0-3.1,2.7-2.1,4.3-.9h0Z"
/>
</SVG>
);
9 changes: 9 additions & 0 deletions packages/block-library/src/embed/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
embedPinterestIcon,
embedWolframIcon,
embedPocketCastsIcon,
embedBlueskyIcon,
} from './icons';

/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
Expand Down Expand Up @@ -360,6 +361,14 @@ const variations = [
patterns: [ /^https?:\/\/(www\.)?wolframcloud\.com\/obj\/.+/i ],
attributes: { providerNameSlug: 'wolfram-cloud', responsive: true },
},
{
name: 'bluesky',
title: 'Bluesky',
icon: embedBlueskyIcon,
description: __( 'Embed a Bluesky post.' ),
patterns: [ /^https?:\/\/bsky\.app\/profile\/.+\/post\/.+/i ],
attributes: { providerNameSlug: 'bluesky' },
},
];

/**
Expand Down
6 changes: 1 addition & 5 deletions packages/style-engine/src/styles/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ const backgroundImage = {
name: 'backgroundImage',
generate: ( style: Style, options: StyleOptions ) => {
const _backgroundImage = style?.background?.backgroundImage;
if (
typeof _backgroundImage === 'object' &&
_backgroundImage?.source === 'file' &&
_backgroundImage?.url
) {
if ( typeof _backgroundImage === 'object' && _backgroundImage?.url ) {
return [
{
selector: options.selector,
Expand Down
1 change: 0 additions & 1 deletion packages/style-engine/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ describe( 'getCSSRules', () => {
{
background: {
backgroundImage: {
source: 'file',
url: 'https://example.com/image.jpg',
},
backgroundPosition: '50% 50%',
Expand Down
3 changes: 1 addition & 2 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4812,8 +4812,7 @@ public function test_get_top_level_background_image_styles() {
'core/paragraph' => array(
'background' => array(
'backgroundImage' => array(
'url' => 'http://example.org/image.png',
'source' => 'file',
'url' => 'http://example.org/image.png',
),
'backgroundSize' => 'cover',
'backgroundRepeat' => 'no-repeat',
Expand Down
6 changes: 0 additions & 6 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2331,12 +2331,6 @@
{
"type": "object",
"properties": {
"source": {
"description": "The origin of the image. 'file' denotes that the 'url' is a path to an image or other file.",
"type": "string",
"enum": [ "file" ],
"default": "file"
},
"url": {
"description": "A URL to an image file.",
"type": "string"
Expand Down

0 comments on commit b8f2437

Please sign in to comment.