Skip to content

Commit

Permalink
Restore json attributes and add classes and styles to the editor comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
Copons committed Nov 1, 2019
1 parent be27caa commit a8207d3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 35 deletions.
29 changes: 29 additions & 0 deletions packages/block-library/src/site-description/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,34 @@
"supports": {
"align": [ "wide", "full" ],
"html": false
},
"attributes": {
"align": {
"type": "string",
"default": "wide"
},
"textAlign": {
"type": "string",
"default": "center"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
"customBackgroundColor": {
"type": "string"
},
"fontSize": {
"type": "string",
"default": "small"
},
"customFontSize": {
"type": "number"
}
}
}
25 changes: 22 additions & 3 deletions packages/block-library/src/site-description/edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classNames from 'classnames';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -25,6 +30,7 @@ import { ENTER } from '@wordpress/keycodes';
function SiteDescriptionEdit( {
attributes,
backgroundColor,
className,
fontSize,
insertDefaultBlock,
setAttributes,
Expand Down Expand Up @@ -98,11 +104,24 @@ function SiteDescriptionEdit( {
{ __( 'Update' ) }
</Button>
<PlainText
placeholder={ __( 'Site Description' ) }
value={ description }
onChange={ setDescription }
className={ classNames( 'site-description', className, {
'has-text-color': textColor.color,
'has-background': backgroundColor.color,
[ `has-text-align-${ textAlign }` ]: textAlign,
[ backgroundColor.class ]: backgroundColor.class,
[ textColor.class ]: textColor.class,
[ fontSize.class ]: ! customFontSize && fontSize.class,
} ) }
isStylable
onChange={ setDescription }
onKeyDown={ preventNewlines }
placeholder={ __( 'Site Description' ) }
style={ {
backgroundColor: backgroundColor.color,
color: textColor.color,
fontSize: actualFontSize ? actualFontSize + 'px' : undefined,
} }
value={ description }
/>
</>
);
Expand Down
33 changes: 1 addition & 32 deletions packages/block-library/src/site-description/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,7 @@ function register_block_core_site_description() {
register_block_type(
'core/site-description',
array(
'attributes' => array(
'className' => array(
'type' => 'string',
'default' => '',
),
'align' => array(
'type' => 'string',
),
'textAlign' => array(
'type' => 'string',
'default' => 'center',
),
'textColor' => array(
'type' => 'string',
),
'customTextColor' => array(
'type' => 'string',
),
'backgroundColor' => array(
'type' => 'string',
),
'customBackgroundColor' => array(
'type' => 'string',
),
'fontSize' => array(
'type' => 'string',
),
'customFontSize' => array(
'type' => 'number',
),
),
'render_callback' => 'render_block_core_site_description',
'render_callback' => 'render_block_core_site_description',
)
);
}
Expand Down

0 comments on commit a8207d3

Please sign in to comment.