From a75159355283f395ce48fbae878919e7cb83a3e6 Mon Sep 17 00:00:00 2001 From: Daniel Gregory Date: Wed, 6 Jun 2018 12:31:14 +0100 Subject: [PATCH 1/3] Fix broken links to block readme --- packages/element/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/element/README.md b/packages/element/README.md index fee28dc87ef8db..9d0076183e144d 100644 --- a/packages/element/README.md +++ b/packages/element/README.md @@ -45,9 +45,9 @@ Refer to the [official React Quick Start guide](https://reactjs.org/docs/hello-w ## Why React? -At the risk of igniting debate surrounding any single "best" front-end framework, the choice to use any tool should be motivated specifically to serve the requirements of the system. In modeling the concept of a [block](../blocks/README.md), we observe the following technical requirements: +At the risk of igniting debate surrounding any single "best" front-end framework, the choice to use any tool should be motivated specifically to serve the requirements of the system. In modeling the concept of a [block](../../blocks/README.md), we observe the following technical requirements: -- An understanding of a block in terms of its underlying values (in the [random image example](../blocks/README.md#example), a category) +- An understanding of a block in terms of its underlying values (in the [random image example](../../blocks/README.md#example), a category) - A means to describe the UI of a block given these values At its most basic, React provides a simple input / output mechanism. __Given a set of inputs ("props"), a developer describes the output to be shown on the page.__ This is most elegantly observed in its [function components](https://reactjs.org/docs/components-and-props.html#functional-and-class-components). React serves the role of reconciling the desired output with the current state of the page. From 924c37f5c85311affc4c27aadbdfb28f5626f6ca Mon Sep 17 00:00:00 2001 From: mrmadhat Date: Wed, 28 Nov 2018 22:51:16 +0000 Subject: [PATCH 2/3] Made cover block text a heading with selectable level --- packages/block-library/src/cover/index.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/cover/index.js b/packages/block-library/src/cover/index.js index 8dff936dc440d1..0b6e3835237f91 100644 --- a/packages/block-library/src/cover/index.js +++ b/packages/block-library/src/cover/index.js @@ -6,6 +6,8 @@ import classnames from 'classnames'; /** * WordPress dependencies */ +import HeadingToolbar from '../heading/heading-toolbar'; + import { IconButton, PanelBody, @@ -40,7 +42,11 @@ const blockAttributes = { title: { type: 'string', source: 'html', - selector: 'p', + selector: 'h1, h2, h3, h4, h5, h6', + }, + level: { + type: 'number', + default: 2, }, url: { type: 'string', @@ -189,6 +195,7 @@ export const settings = { id, title, url, + level, } = attributes; const updateAlignment = ( nextAlign ) => setAttributes( { align: nextAlign } ); const onSelectMedia = ( media ) => { @@ -226,6 +233,8 @@ export const settings = { const setDimRatio = ( ratio ) => setAttributes( { dimRatio: ratio } ); const setTitle = ( newTitle ) => setAttributes( { title: newTitle } ); + const tagName = 'h' + level; + const style = { ...( backgroundType === IMAGE_BACKGROUND_TYPE ? @@ -282,7 +291,10 @@ export const settings = { { !! url && ( - + + setAttributes( { level: newLevel } ) } /> + + { IMAGE_BACKGROUND_TYPE === backgroundType && ( ) } { ! RichText.isEmpty( title ) && ( - + ) } ); From 12df6f2df52e00660fa21035b438e88cd52df630 Mon Sep 17 00:00:00 2001 From: mrmadhat Date: Wed, 28 Nov 2018 23:13:29 +0000 Subject: [PATCH 3/3] Added old save method/attributes to depreciated array --- packages/block-library/src/cover/index.js | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/block-library/src/cover/index.js b/packages/block-library/src/cover/index.js index 0b6e3835237f91..6ae7bc11ffae3f 100644 --- a/packages/block-library/src/cover/index.js +++ b/packages/block-library/src/cover/index.js @@ -506,6 +506,62 @@ export const settings = { ); }, + }, { + attributes: { + ...blockAttributes, + title: { + type: 'string', + source: 'html', + selector: 'p', + }, + }, + + save( { attributes } ) { + const { + align, + backgroundType, + contentAlign, + customOverlayColor, + dimRatio, + hasParallax, + overlayColor, + title, + url, + } = attributes; + const overlayColorClass = getColorClassName( 'background-color', overlayColor ); + const style = backgroundType === IMAGE_BACKGROUND_TYPE ? + backgroundImageStyles( url ) : + {}; + if ( ! overlayColorClass ) { + style.backgroundColor = customOverlayColor; + } + + const classes = classnames( + dimRatioToClass( dimRatio ), + overlayColorClass, + { + 'has-background-dim': dimRatio !== 0, + 'has-parallax': hasParallax, + [ `has-${ contentAlign }-content` ]: contentAlign !== 'center', + }, + align ? `align${ align }` : null, + ); + + return ( +
+ { VIDEO_BACKGROUND_TYPE === backgroundType && url && (
+ ); + }, } ], };