Skip to content

Commit

Permalink
Transfer oik/content-block from oik-blocks. Remove calls to get_attri…
Browse files Browse the repository at this point in the history
…butes() #180
  • Loading branch information
bobbingwide committed Aug 16, 2021
1 parent ffcda3e commit 9ad01df
Show file tree
Hide file tree
Showing 12 changed files with 981 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
import './oik-address'; // From oik & oik-user
import './oik-contact-form'; // From oik bw_contact_form
import './oik-content'; // Dynamic content block
import './oik-countdown'; // From oik bw_countdown
import './oik-follow-me'; // From oik bw_follow_me
import './oik-googlemap'; // From oik bw_show_googlemap
Expand Down
52 changes: 52 additions & 0 deletions src/oik-content/SelectTextControlCombo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Implements a Select Control / Text control combo where the
* text value overrides the option(s) selected from the SelectControl.
*
*
* @copyright (C) Copyright Bobbing Wide 2020
* @author Herb Miller @bobbingwide
*/


const { Component, Fragment } = wp.element;
const { SelectControl, TextControl } = wp.components;

export class SelectTextControlCombo extends Component {
constructor() {
super(...arguments);

}

renderSelect( props ) {

//var options = formats.map((format) => this.formatsOption(format));
var custom_label = `Custom value: ${this.props.label}`;
return (
<Fragment>
<SelectControl label={this.props.label} value={this.props.value}
options={this.props.options}
onChange={this.props.onChange}
/>
<TextControl label={custom_label} hideLabelFromVision={ true } value={this.props.value} onChange={this.props.onChange} />
</Fragment>
);

}



/**
* Map the format_option to a select list option
*
* @param format
* @returns {{label: *, value: *}}
*/
formatOption( format ) {
return( { value: format.value, label: format.label });
}

render() {
return( this.renderSelect()
);
}
}
92 changes: 92 additions & 0 deletions src/oik-content/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const { __ } = wp.i18n;

const shortcode_attributes =
{
shortcode: {
type: 'string',
default: '',
},

parameters: {
type: 'string',
default: '',
},

post_type: {
type: 'string',
default: '',
},

// post_parent = ., 0, ID null
post_parent: {
type: 'string',
default: '',
},

// number_posts = -1, 1->100
numberposts: {
type: 'integer',
default: 10,
},

// orderby =
orderby: {
type: 'string',
default: 'date',
},

// order = ASC / DESC
order: {
type: 'string',
default: 'desc',
},

format: {
type: 'string',
default: 'LIER',
},

// categories=
// category_name=
// customcategoryname=
// include
// exclude
// offset = null,
// meta_key
// meta_value
// meta_compare
// post_status
// id=id1,id2

// posts_per_page
//


};


const orderby = [
{ label: 'Date', value: 'date',},
{ label: 'ID', value: 'ID',},
{ label: 'Title', value: 'title',},
{ label: 'Parent', value: 'parent', },
{ label: 'Random', value: 'rand',},
{ label: 'Menu order', value: 'menu_order',},
];

const order =
[
{
label: __( 'Descending order' ),
value: 'desc',
},
{
label: __( 'Ascending order' ),
value: 'asc',
},

];



export { shortcode_attributes, orderby, order };
91 changes: 91 additions & 0 deletions src/oik-content/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"apiVersion": 2,
"name": "oik/content-block",
"title": "Dynamic content block",
"category": "layout",
"icon": "shortcode",
"description": "Expands content for dynamic oik shortcodes.",
"attributes": {
"shortcode": {
"type": "string",
"default": ""
},
"content": {
"type": "string",
"default": ""
},
"parameters": {
"type": "string",
"default": ""
},
"post_type": {
"type": "string",
"default": ""
},
"post_parent": {
"type": "string",
"default": ""
},
"numberposts": {
"type": "integer",
"default": 10
},
"orderby": {
"type": "string",
"default": "date"
},
"order": {
"type": "string",
"default": "desc"
},
"align": {
"type": "string",
"default": ""
},
"format": {
"type": "string",
"default": "LIER"
},
"textAlign": {
"type": "string"
},
"className": {
"type": "string"
},
"textColor": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
"style": {
"type": "object"
},
"fontSize": {
"type": "string"
},
"gradient": {
"type": "string"
}
},
"supports": {
"align": true,
"alignWide": true,
"alignFull": true,
"html": false,
"customClassName": false,
"className": true,
"color": {
"gradients": false,
"text": true,
"background": false,
"link": false
},
"typography": {
"fontSize": false,
"lineHeight": false
}
},
"keywords": [ "content", "shortcode", "dynamic", "oik" ],
"textdomain": "oik-blocks"
}
Loading

0 comments on commit 9ad01df

Please sign in to comment.