Skip to content

Commit

Permalink
Issue #138 - implement transforms to oik/countdown from oik-blocks/co…
Browse files Browse the repository at this point in the history
…untdown and [bw_countdown]
  • Loading branch information
bobbingwide committed Jan 14, 2020
1 parent d29ac4d commit a7b3b1a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
4 changes: 4 additions & 0 deletions blocks/oik-countdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const {
} = wp.compose;

const Fragment = wp.element.Fragment;
import { transforms } from './transforms.js';



/**
Expand Down Expand Up @@ -110,6 +112,8 @@ registerBlockType(

supports: { html: false, className: false},

transforms,

edit: props => {

const onChangeSince = ( event ) => {
Expand Down
62 changes: 62 additions & 0 deletions blocks/oik-countdown/transforms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Transformation to oik/countdown of oik-blocks/countdown and [bw_coundtown].
*/
const { createBlock
} = wp.blocks;

const transforms = {
from: [
{
type: 'block',
blocks: ['oik-block/countdown'],
transform: function (attributes) {
return createBlock('oik/countdown', attributes );
},
},
{
type: 'shortcode',
tag: 'bw_countdown',
attributes: {
since: {
type: 'string',
shortcode: ( { named: { since } } ) => {
return since;
},
},
until: {
type: 'string',
shortcode: ( { named: { until } } ) => {
return until;
},
},
url: {
type: 'string',
shortcode: ( { named: { url } } ) => {
return url;
},
},
description: {
type: 'string',
shortcode: ( { named: { description } } ) => {
return description;
},
},
expirytext: {
type: 'string',
shortcode: ( { named: { expirytext } } ) => {
return expirytext;
},
},
format: {
type: 'string',
shortcode: ( { named: { format } } ) => {
return format;
},
},

},
},
]
};

export { transforms } ;

0 comments on commit a7b3b1a

Please sign in to comment.