Skip to content

Commit

Permalink
Merge pull request #5 from michelegiorgi/development
Browse files Browse the repository at this point in the history
release 1.2
  • Loading branch information
michelegiorgi authored Jan 10, 2021
2 parents a52aedc + f0fd20a commit 78d209e
Show file tree
Hide file tree
Showing 26 changed files with 374 additions and 220 deletions.
25 changes: 11 additions & 14 deletions assets/scripts/editor/blocks/email.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/**
* Formality block
*
*
*/

const blockName = 'formality/email'
Expand All @@ -17,25 +17,25 @@ import {
} from '../utility/blocks.js'

const { __ } = wp.i18n;
const {
const {
registerBlockType,
createBlock,
} = wp.blocks;

const {
const {
PanelBody,
Icon,
} = wp.components;

const {
const {
InspectorControls,
} = wp.blockEditor;

import { iconEmail as blockicon } from '../utility/icons.js'

registerBlockType( blockName, {
title: __('E-mail', 'formality'),
description: __('Text field that accepts only valid email address.', 'formality'),
description: __('Text field that accepts only valid email address.', 'formality'),
icon: blockicon,
category: 'formality',
attributes: {
Expand All @@ -46,11 +46,8 @@ registerBlockType( blockName, {
placeholder: { type: 'string', default: ''},
required: { type: 'boolean', default: false },
value: { type: 'string', default: ''},
rules: {
type: 'string|array',
attribute: 'rules',
default: [],
},
rules: { type: 'string|array', attribute: 'rules', default: [], },
dbg: { type: 'string|object', default: {}, },
preview: { type: 'boolean', default: false },
},
example: { attributes: { preview: true } },
Expand All @@ -66,7 +63,7 @@ registerBlockType( blockName, {
}],
},
edit(props) {

checkUID(props)
let { name, label, placeholder, required, uid, value, rules, preview } = props.attributes
let focus = props.isSelected
Expand Down Expand Up @@ -104,8 +101,8 @@ registerBlockType( blockName, {
</div>
</div>,
])
},
},
save () {
return null
},
});
});
20 changes: 8 additions & 12 deletions assets/scripts/editor/blocks/media.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/**
* Formality block
*
*
*/

const blockName = 'formality/media'
Expand All @@ -17,11 +17,11 @@ import {
} from '../utility/blocks.js'

const { __ } = wp.i18n;
const {
const {
registerBlockType,
} = wp.blocks;

const {
const {
Icon,
Button,
BaseControl,
Expand All @@ -42,7 +42,7 @@ import { iconPlay } from '../utility/icons.js'

registerBlockType( blockName, {
title: __('Media', 'formality'),
description: __('Hero image, how-to video or any type of visual content for your users.', 'formality'),
description: __('Hero image, how-to video or any type of visual content for your users.', 'formality'),
icon: blockicon,
category: 'formality_nav',
attributes: {
Expand All @@ -51,11 +51,7 @@ registerBlockType( blockName, {
media_type: { type: 'string', default: ''},
media_id: { type: 'integer', default: 0},
exclude: { type: 'integer', default: 99},
rules: {
type: 'string|array',
attribute: 'rules',
default: [],
},
rules: { type: 'string|array', attribute: 'rules', default: [], },
preview: { type: 'boolean', default: false },
},
example: { attributes: { preview: true } },
Expand Down Expand Up @@ -107,8 +103,8 @@ registerBlockType( blockName, {
{ media ? ( media_type == "video" ? <fragment><video><source src={ media } type="video/mp4"/></video><a href="#">{ iconPlay }</a></fragment> : <img src={ media } alt="" /> ) : __('Please select an image or video, from the right sidebar.', 'formality') }
</div>,
])
},
},
save () {
return null
},
});
});
22 changes: 9 additions & 13 deletions assets/scripts/editor/blocks/message.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/**
* Formality block
*
*
*/

const blockName = 'formality/message'
Expand All @@ -16,15 +16,15 @@ import {
} from '../utility/blocks.js'

const { __ } = wp.i18n;
const {
const {
registerBlockType,
} = wp.blocks;

const {
const {
Icon,
} = wp.components;

const {
const {
RichText,
InspectorControls,
} = wp.blockEditor;
Expand All @@ -33,18 +33,14 @@ import { iconMessage as blockicon } from '../utility/icons.js'

registerBlockType( blockName, {
title: __('Message', 'formality'),
description: __('Custom message/information for your users.', 'formality'),
description: __('Custom message/information for your users.', 'formality'),
icon: blockicon,
category: 'formality_nav',
attributes: {
//uid: { type: 'string', default: '' },
text: { type: 'string', default: ''},
exclude: { type: 'integer', default: 99},
rules: {
type: 'string|array',
attribute: 'rules',
default: [],
},
rules: { type: 'string|array', attribute: 'rules', default: [], },
preview: { type: 'boolean', default: false },
},
example: { attributes: { preview: true } },
Expand Down Expand Up @@ -75,8 +71,8 @@ registerBlockType( blockName, {
/>
</div>,
])
},
},
save () {
return null
},
});
});
35 changes: 14 additions & 21 deletions assets/scripts/editor/blocks/multiple.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/**
* Formality block
*
*
*/

const blockName = 'formality/multiple'
Expand All @@ -24,12 +24,12 @@ const {
sprintf,
} = wp.i18n;

const {
const {
registerBlockType,
createBlock,
} = wp.blocks;

const {
const {
PanelBody,
PanelRow,
TextControl,
Expand All @@ -41,7 +41,7 @@ const {
Icon,
} = wp.components;

const {
const {
InspectorControls,
} = wp.blockEditor;

Expand All @@ -51,7 +51,7 @@ const {

registerBlockType( blockName, {
title: __('Multiple choice', 'formality'),
description: __('Checkbox grid with all available options that users can select.', 'formality'),
description: __('Checkbox grid with all available options that users can select.', 'formality'),
icon: blockicon,
category: 'formality',
attributes: {
Expand All @@ -63,16 +63,9 @@ registerBlockType( blockName, {
halfwidth: { type: 'boolean', default: false },
value: { type: 'string', default: ''},
style: { type: 'string', default: 'default' },
rules: {
type: 'string|array',
attribute: 'rules',
default: [],
},
options: {
type: 'string|array',
attribute: 'options',
default: [],
},
rules: { type: 'string|array', attribute: 'rules', default: [], },
dbg: { type: 'string|object', default: {}, },
options: { type: 'string|array', attribute: 'options', default: [], },
option_labels: { type: 'boolean', default: false },
single: { type: 'boolean', default: false },
option_grid: { type: 'integer', default: 2 },
Expand All @@ -96,9 +89,9 @@ registerBlockType( blockName, {
let { name, label, placeholder, required, uid, value, rules, preview, options, option_labels, option_grid, single, style } = props.attributes
let focus = props.isSelected
if ( preview ) { return getPreview(props.name) }

if(!option_grid && style=="default") { option_grid = 1; }

return ([
<InspectorControls>
<PanelBody title={__('Field options', 'formality')}>
Expand Down Expand Up @@ -182,7 +175,7 @@ registerBlockType( blockName, {
>
<div className="formality__note">{ placeholder }</div>
<div className={ "formality__input__grid formality__input__grid--" + style + " formality__input__grid--" + option_grid }>
{options.map(option => {
{options.map(option => {
return <Fragment>
<input
type={ single ? "radio" : "checkbox" }
Expand All @@ -203,8 +196,8 @@ registerBlockType( blockName, {
</div>
</div>,
])
},
},
save () {
return null
},
});
});
25 changes: 11 additions & 14 deletions assets/scripts/editor/blocks/number.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/**
* Formality block
*
*
*/

const blockName = 'formality/number'
Expand All @@ -18,27 +18,27 @@ import {
} from '../utility/blocks.js'

const { __ } = wp.i18n;
const {
const {
registerBlockType,
createBlock,
} = wp.blocks;

const {
const {
PanelBody,
PanelRow,
TextControl,
Icon,
} = wp.components;

const {
const {
InspectorControls,
} = wp.blockEditor;

import { iconNumber as blockicon } from '../utility/icons.js'

registerBlockType( blockName, {
title: __('Number', 'formality'),
description: __('Number field, accept integer or float number value', 'formality'),
description: __('Number field, accept integer or float number value', 'formality'),
icon: blockicon,
category: 'formality',
attributes: {
Expand All @@ -49,11 +49,8 @@ registerBlockType( blockName, {
required: { type: 'boolean', default: false },
halfwidth: { type: 'boolean', default: false },
value: { type: 'string', default: ''},
rules: {
type: 'string|array',
attribute: 'rules',
default: [],
},
rules: { type: 'string|array', attribute: 'rules', default: [], },
dbg: { type: 'string|object', default: {}, },
value_min: { type: 'string', default: ''},
value_max: { type: 'string', default: ''},
value_step: { type: 'string', default: '1'},
Expand All @@ -72,7 +69,7 @@ registerBlockType( blockName, {
}],
},
edit(props) {

checkUID(props)
let { name, label, placeholder, required, uid, value, rules, preview, value_min, value_max, value_step } = props.attributes
let focus = props.isSelected
Expand Down Expand Up @@ -132,8 +129,8 @@ registerBlockType( blockName, {
</div>
</div>,
])
},
},
save () {
return null
},
});
});
Loading

0 comments on commit 78d209e

Please sign in to comment.