Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Form Gutenblock #10256

Closed
wants to merge 142 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
5e25b34
Ignore node_modules regardless of depth
georgestephanis Oct 2, 2018
52e1173
Add build tools for contact form
georgestephanis Oct 2, 2018
cc8a8db
First pass.
georgestephanis Oct 2, 2018
7238d2c
Redo fields.
georgestephanis Oct 2, 2018
f15a3f8
Update some icons, renders, etc.
georgestephanis Oct 2, 2018
4479c89
Correct how I'm grabbing the label.
georgestephanis Oct 2, 2018
73713a4
Assorted changes.
georgestephanis Oct 2, 2018
c20c2a3
d'oh copypasta fail
georgestephanis Oct 2, 2018
97e64d9
Do it the easy way, not the tidy way.
georgestephanis Oct 2, 2018
b9d9dd3
Begin saving `to` and `subject` fields, add `required` toggle.
georgestephanis Oct 3, 2018
1b04126
whitespace tidying / reorg
georgestephanis Oct 3, 2018
47dc2d5
Abstract out the label stuff for simpler components and reusability.
georgestephanis Oct 3, 2018
01e9b30
Add the compiled version to make for easier testing.
georgestephanis Oct 3, 2018
dbe61c0
Start experimenting with options parameters and rendering.
georgestephanis Oct 3, 2018
71d652d
Have each option save its value.
georgestephanis Oct 3, 2018
f075497
compile!
georgestephanis Oct 3, 2018
31e6e6e
tabs
georgestephanis Oct 3, 2018
89d4059
whitespace tidying
georgestephanis Oct 3, 2018
dfadbe4
update build file
georgestephanis Oct 3, 2018
7a8f38a
Stub out render functions
georgestephanis Oct 3, 2018
c67b7e4
Get radio control working
georgestephanis Oct 3, 2018
bbabdb1
Get Select fields running, and make "Add New" translateable
georgestephanis Oct 3, 2018
bddab06
Compile!
georgestephanis Oct 3, 2018
710ca7c
Add more php parsing for varied block types.
georgestephanis Oct 4, 2018
413aa1d
Handle arrays for atts as gutenberg uses json
georgestephanis Oct 4, 2018
0170466
whitespace tidying
georgestephanis Oct 4, 2018
d51d26b
We don't need this for numeric attrs, as gutenberg won't make it numeric
georgestephanis Oct 4, 2018
f35025e
add a bool handler for required
georgestephanis Oct 4, 2018
a8f46bd
Consolidate the multi select options
georgestephanis Oct 4, 2018
df8fdd1
Add some rudimentary styles to the back-end form editor.
georgestephanis Oct 4, 2018
a7e7a36
build
georgestephanis Oct 4, 2018
888411f
Tidy up legacy supportHTML option to object and change widgets to common
georgestephanis Oct 5, 2018
198d26b
Minor styling changes for labels and spacing.
mapk Oct 5, 2018
be901ba
Merge branch 'gm18/grunionblock' of github.com:Automattic/jetpack int…
mapk Oct 5, 2018
3ba151f
Purge some of the local build tools
georgestephanis Oct 8, 2018
7e6fc72
Start experimenting with Block Transforms.
georgestephanis Oct 8, 2018
a5a95f6
Merge branch 'gm18/grunionblock' of https://github.com/Automattic/jet…
georgestephanis Oct 8, 2018
c3e6f3a
Change methodology to use Calypso build tool SDK?
georgestephanis Oct 8, 2018
fa9c5d7
Build via calypso builder instead.
georgestephanis Oct 8, 2018
b391042
spaces 👉🏼 tabs 🆒
georgestephanis Oct 8, 2018
0b11ea3
Remove map file no longer generated by calypso
georgestephanis Oct 8, 2018
e4aa2de
Make the 'submit' button editable.
georgestephanis Oct 8, 2018
f02943e
Tidy up some code standards stuff
georgestephanis Oct 9, 2018
5da01df
Make it possible to swap the button text, and some whitespace tidying.
georgestephanis Oct 11, 2018
7e14f16
Tidy up how we're passing around functions to set attributes.
georgestephanis Oct 11, 2018
3a0e9bb
Whitespace
georgestephanis Oct 11, 2018
cd1d669
Ignore the cform gutenblock while I'm working on it.
georgestephanis Oct 11, 2018
f609b6f
Whitespace tidying and change option add button.
georgestephanis Oct 11, 2018
3b16cd6
Update the styling of some elements.
georgestephanis Oct 11, 2018
4afc7e1
Enhancement: add ability to delete options from multi select field types
georgestephanis Oct 11, 2018
3ef297d
Add placeholder to multi fields
georgestephanis Oct 11, 2018
d8a3a72
Add alternate transforms.
georgestephanis Oct 15, 2018
0da9b34
whitespace formatting / tidying
georgestephanis Oct 15, 2018
800dc05
Switch to
georgestephanis Oct 15, 2018
204c4da
Build.
georgestephanis Oct 15, 2018
b2ef95c
Add matches and transforms for single/multi field types
georgestephanis Oct 15, 2018
8f7ea33
Abstract out the processing logic.
georgestephanis Oct 15, 2018
0e31a45
build
georgestephanis Oct 15, 2018
2de2f7e
Punt jQuery.
georgestephanis Oct 15, 2018
e1d9bc0
Stop using underscore for `_.map()`
georgestephanis Oct 15, 2018
1d8c40f
Vanilla js way of cloning an object in js.
georgestephanis Oct 15, 2018
639d7ae
Remove last vestiges of underscore.
georgestephanis Oct 15, 2018
d924a31
build
georgestephanis Oct 15, 2018
3d845f6
Simplify some classes down to functions.
georgestephanis Oct 15, 2018
796fae5
Simplify out how we're adding new items
georgestephanis Oct 15, 2018
756512e
Add wp global back in -- oops
georgestephanis Oct 15, 2018
31ca531
Pull out setAttributes fn call.
georgestephanis Oct 15, 2018
f36bf93
Abstract out onChanges
georgestephanis Oct 15, 2018
c7bb399
Switch to placeholders
georgestephanis Oct 15, 2018
7156524
tabs > spaces
georgestephanis Oct 15, 2018
c6ae74e
Build
georgestephanis Oct 15, 2018
a25e3ff
Simplify the disabled attribute so we don't need the `true` assignment
georgestephanis Oct 16, 2018
3ae96a8
Update some naming and patterns
georgestephanis Oct 16, 2018
bd0b78d
Add missing textdomains.
georgestephanis Oct 16, 2018
a425c1d
Use the Gutenberg generated className as well.
georgestephanis Oct 16, 2018
b96942d
Better scope some CSS
georgestephanis Oct 16, 2018
ccdaa56
Build.
georgestephanis Oct 16, 2018
368686e
Rearrange some icons and tidy some whitespace.
georgestephanis Oct 16, 2018
4073815
Build.
georgestephanis Oct 16, 2018
cca93bb
Renamespace everything from Grunion to Jetpack
georgestephanis Oct 16, 2018
f0352a7
Build.
georgestephanis Oct 16, 2018
3de7e2a
First attempt at extracting to sub file
georgestephanis Oct 16, 2018
919cbff
Minor bookkeeping
georgestephanis Oct 16, 2018
a13597b
Build.
georgestephanis Oct 16, 2018
25a8f30
Extract out components for maintainability.
georgestephanis Oct 16, 2018
f8cc516
Build.
georgestephanis Oct 16, 2018
3010d3e
Make scss version of gutenblock css
georgestephanis Oct 16, 2018
c5bfaa2
Shuffle around files to match Calypso structure.
georgestephanis Oct 17, 2018
5acf98d
Build.
georgestephanis Oct 17, 2018
7c1b4da
These changes are no longer necessary.
georgestephanis Oct 17, 2018
096c56f
Make sure we're building the scss as well.
georgestephanis Oct 17, 2018
a9213a2
Build.
georgestephanis Oct 17, 2018
c782ddc
Convert the css to scss and build back to css.
georgestephanis Oct 17, 2018
9d1b6b4
Add RTL
georgestephanis Oct 17, 2018
7e1f18e
Don't scan these files -- they're synced with Calypso and actually js…
georgestephanis Oct 17, 2018
488dfac
Style revised to match default G blocks on elements for hover and foc…
mapk Oct 17, 2018
d5dd3e1
Rebuild editor.css
georgestephanis Oct 18, 2018
af4e42d
Minor styling for the multiple checkbox.
mapk Oct 18, 2018
4c4b0ad
Add a conditional for how the innerblocks are passed back up.
georgestephanis Oct 18, 2018
794f45f
Merge branch 'gm18/grunionblock' of https://github.com/Automattic/jet…
georgestephanis Oct 18, 2018
aeb16b9
More form styling for the checkbox and radio options. Made checkbox f…
mapk Oct 18, 2018
2945f64
Merge branch 'gm18/grunionblock' of github.com:Automattic/jetpack int…
mapk Oct 18, 2018
5bb2730
Removed arrow from form submit btn
mapk Oct 18, 2018
16ac9ba
Styled the appender to hide with the block is not selected. Added som…
mapk Oct 22, 2018
89dcd71
Build.
georgestephanis Oct 22, 2018
cb0e74d
Change "Type here..." to a placeholder instead of value.
georgestephanis Oct 22, 2018
0d53322
Tidy up some missing options
georgestephanis Oct 22, 2018
7c2e7dd
Default the label value to the field type.
georgestephanis Oct 22, 2018
042adaa
Build.
georgestephanis Oct 22, 2018
c0d4d9e
Switch checkbox and multiple components to use `BaseControl`
georgestephanis Oct 23, 2018
4f0ac3e
Populate multis with the actual check and radio boxes
georgestephanis Oct 23, 2018
98e9b91
Build.
georgestephanis Oct 23, 2018
1a52835
Switch submit button to ContentEditable instead.
georgestephanis Oct 23, 2018
755d286
Spaces to tabs
georgestephanis Oct 23, 2018
b22d14d
Build.
georgestephanis Oct 23, 2018
7bccaf1
Bump this around for scss structure nesting.
georgestephanis Oct 23, 2018
9bd82d6
Build.
georgestephanis Oct 23, 2018
64b6da6
Fix the case of the vanishing appender.
georgestephanis Oct 23, 2018
eef9480
Build.
georgestephanis Oct 23, 2018
4ad8207
suppressContentEditableWarning
georgestephanis Oct 23, 2018
9087614
Build.
georgestephanis Oct 23, 2018
cbf5a51
Fixed minor bug with alignment of 'x' btn for multiple radios and che…
mapk Oct 23, 2018
cb81c9f
Merge branch 'gm18/grunionblock' of github.com:Automattic/jetpack int…
mapk Oct 23, 2018
55f4e04
Reorganize scss for better hierarchy and make submit button not conte…
georgestephanis Oct 24, 2018
d702c1d
Build.
georgestephanis Oct 24, 2018
a12356b
Add in a new caveat for block rendering.
georgestephanis Oct 24, 2018
8fe6139
Oops, the type was getting lost on these fields. Better add in A Bet…
georgestephanis Oct 24, 2018
88c0173
TABS TABS TABS
georgestephanis Oct 24, 2018
e6399c7
Correcting the default fieldset to match historical configurations.
georgestephanis Oct 24, 2018
7fa62e7
Whitespace
georgestephanis Oct 24, 2018
223e8c3
Allow all blocks inside a Contact Form.
georgestephanis Oct 24, 2018
85d25a4
Build.
georgestephanis Oct 24, 2018
cb701ad
Clear the last vestiges of `»` away from the submit button.
georgestephanis Oct 24, 2018
6d0bb05
Fixed submit btn padding
mapk Oct 24, 2018
ab72871
Disallow non-field child blocks for now.
georgestephanis Oct 25, 2018
57d8906
Build.
georgestephanis Oct 25, 2018
919462b
Swap in most SVGs from Material Design for fields.
georgestephanis Oct 25, 2018
2e229e5
Build.
georgestephanis Oct 25, 2018
44a0ef6
Swap to the specified outline style icons.
georgestephanis Oct 25, 2018
3c26a29
Switch over to Gutenberg's SVG primitives for accessibility.
georgestephanis Oct 25, 2018
86b2869
Build.
georgestephanis Oct 25, 2018
6d2c04e
Strip out legacy ways of rendering -- no longer useful.
georgestephanis Oct 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ phpcs.xml
/css
_inc/jetpack-strings.php
/modules/**/*/block.js

1 change: 1 addition & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ gulp.task( 'js:hint', function() {
'!modules/*.min.',
'!modules/**/*.min.js',
'!**/*/*block.js',
'!**/*/editor.js', // Don't scan these files -- they're synced with Calypso and actually jsx or built files.
] )
.pipe( jshint( '.jshintrc' ) )
.pipe( jshint.reporter( 'jshint-stylish' ) )
Expand Down
72 changes: 72 additions & 0 deletions modules/contact-form/block/build/editor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* SASS placeholder selectors for form styles
*/
.jetpack-form .components-base-control * {
margin: 0; }

.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label {
border-color: #fff;
border-radius: 0;
font-weight: bold;
margin: 0;
margin-bottom: 2px;
width: calc( 100% - 100px); }
.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label:hover {
border-color: #357CB5; }
.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label:focus {
border-color: #E3E5E8;
-webkit-box-shadow: none;
box-shadow: none; }

.jetpack-form .jetpack-field input:disabled,
.jetpack-form .jetpack-field textarea:disabled {
border-color: #8d96a0;
padding: 10px 8px; }

.jetpack-form .jetpack-field input:disabled {
margin-right: 4px; }

.jetpack-form .jetpack-field span.required {
float: right; }

.editor-block-list__block[data-type="jetpack/field-checkbox-multiple"] ol, .editor-block-list__block[data-type="jetpack/field-radio"] ol, .editor-block-list__block[data-type="jetpack/field-select"] ol {
list-style-type: none; }
.editor-block-list__block[data-type="jetpack/field-checkbox-multiple"] ol:empty, .editor-block-list__block[data-type="jetpack/field-radio"] ol:empty, .editor-block-list__block[data-type="jetpack/field-select"] ol:empty {
display: none; }

.editor-block-list__block[data-type="jetpack/field-select"] ol {
border: 1px solid #8d96a0;
border-radius: 4px;
padding: 4px; }

.editor-block-list__block ol li button.components-icon-button {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
padding: 6px;
vertical-align: bottom; }

.editor-block-list__block input.option {
border-color: #fff;
border-radius: 0;
width: calc( 100% - 5em);
display: inline-block; }
.editor-block-list__block input.option:hover {
border-color: #357CB5; }
.editor-block-list__block input.option:focus {
border-color: #E3E5E8;
-webkit-box-shadow: none;
box-shadow: none; }

.editor-block-list__block .block-list-appender__toggle {
background-color: #f7f7f7;
display: none;
margin: 32px auto;
width: calc(100% - 32px); }
.editor-block-list__block .block-list-appender__toggle:hover {
outline: 1px solid #555d66; }

.editor-block-list__block.is-selected .block-list-appender__toggle, .editor-block-list__block.is-selected-parent .block-list-appender__toggle,
.editor-block-list__block.is-typing ~ .block-list-appender .block-list-appender__toggle {
display: block; }

385 changes: 385 additions & 0 deletions modules/contact-form/block/build/editor.js

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions modules/contact-form/block/build/editor.rtl.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* SASS placeholder selectors for form styles
*/
.jetpack-form .components-base-control * {
margin: 0; }

.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label {
border-color: #fff;
border-radius: 0;
font-weight: bold;
margin: 0;
margin-bottom: 2px;
width: calc( 100% - 100px); }
.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label:hover {
border-color: #357CB5; }
.jetpack-form .jetpack-field .jetpack-field-label.jetpack-field-label.jetpack-field-label:focus {
border-color: #E3E5E8;
-webkit-box-shadow: none;
box-shadow: none; }

.jetpack-form .jetpack-field input:disabled,
.jetpack-form .jetpack-field textarea:disabled {
border-color: #8d96a0;
padding: 10px 8px; }

.jetpack-form .jetpack-field input:disabled {
margin-left: 4px; }

.jetpack-form .jetpack-field span.required {
float: left; }

.editor-block-list__block[data-type="jetpack/field-checkbox-multiple"] ol, .editor-block-list__block[data-type="jetpack/field-radio"] ol, .editor-block-list__block[data-type="jetpack/field-select"] ol {
list-style-type: none; }
.editor-block-list__block[data-type="jetpack/field-checkbox-multiple"] ol:empty, .editor-block-list__block[data-type="jetpack/field-radio"] ol:empty, .editor-block-list__block[data-type="jetpack/field-select"] ol:empty {
display: none; }

.editor-block-list__block[data-type="jetpack/field-select"] ol {
border: 1px solid #8d96a0;
border-radius: 4px;
padding: 4px; }

.editor-block-list__block ol li button.components-icon-button {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
padding: 6px;
vertical-align: bottom; }

.editor-block-list__block input.option {
border-color: #fff;
border-radius: 0;
width: calc( 100% - 5em);
display: inline-block; }
.editor-block-list__block input.option:hover {
border-color: #357CB5; }
.editor-block-list__block input.option:focus {
border-color: #E3E5E8;
-webkit-box-shadow: none;
box-shadow: none; }

.editor-block-list__block .block-list-appender__toggle {
background-color: #f7f7f7;
display: none;
margin: 32px auto;
width: calc(100% - 32px); }
.editor-block-list__block .block-list-appender__toggle:hover {
outline: 1px solid #555d66; }

.editor-block-list__block.is-selected .block-list-appender__toggle, .editor-block-list__block.is-selected-parent .block-list-appender__toggle,
.editor-block-list__block.is-typing ~ .block-list-appender .block-list-appender__toggle {
display: block; }

44 changes: 44 additions & 0 deletions modules/contact-form/block/components/JetpackField.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*global wp*/
/** @jsx wp.element.createElement */
/** @format */

/**
* External dependencies
*/
import {
TextControl
} from '@wordpress/components';

import {
Fragment
} from '@wordpress/element';

/**
* Internal dependencies
*/
import JetpackFieldSettings from './JetpackFieldSettings';
import JetpackFieldLabel from './JetpackFieldLabel';

function JetpackField( props ) {
return (
<Fragment>
<JetpackFieldSettings
required={ props.required }
setAttributes={ props.setAttributes }
/>
<div className="jetpack-field">
<TextControl
type={ props.type }
label={ <JetpackFieldLabel
required={ props.required }
label={ props.label }
setAttributes={ props.setAttributes }
/> }
disabled
/>
</div>
</Fragment>
);
}

export default JetpackField;
52 changes: 52 additions & 0 deletions modules/contact-form/block/components/JetpackFieldCheckbox.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*global wp*/
/** @jsx wp.element.createElement */
/** @format */

/**
* External dependencies
*/
import {
BaseControl,
CheckboxControl
} from '@wordpress/components';

import {
withInstanceId
} from '@wordpress/compose';

import {
Fragment
} from '@wordpress/element';

/**
* Internal dependencies
*/
import JetpackFieldSettings from './JetpackFieldSettings';
import JetpackFieldLabel from './JetpackFieldLabel';

function JetpackFieldCheckbox( props ) {
return (
<Fragment>
<JetpackFieldSettings
required={ props.required }
setAttributes={ props.setAttributes }
/>
<BaseControl
id={ `jetpack-field-checkbox-${ props.instanceId }` }
className="jetpack-field"
>
<CheckboxControl
id={ `jetpack-field-checkbox-${ props.instanceId }` }
label={ <JetpackFieldLabel
required={ props.required }
label={ props.label }
setAttributes={ props.setAttributes }
/> }
disabled
/>
</BaseControl>
</Fragment>
);
}

export default withInstanceId( JetpackFieldCheckbox );
44 changes: 44 additions & 0 deletions modules/contact-form/block/components/JetpackFieldLabel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*global wp*/
/** @jsx wp.element.createElement */
/** @format */

/**
* External dependencies
*/

import {
Component,
Fragment
} from '@wordpress/element';

import {
__
} from '@wordpress/i18n';

class JetpackFieldLabel extends Component {
constructor( ...args ) {
super( ...args );
this.onChangeLabel = this.onChangeLabel.bind( this );
}

onChangeLabel( event ) {
this.props.setAttributes( { label: event.target.value } );
}

render() {
return (
<Fragment>
<input
type="text"
value={ this.props.label }
className="jetpack-field-label"
onChange={ this.onChangeLabel }
placeholder={ __( 'Type here…', 'jetpack' ) }
/>
{ this.props.required && <span className="required">{ __( '(required)', 'jetpack' ) }</span> }
</Fragment>
);
}
}

export default JetpackFieldLabel;
91 changes: 91 additions & 0 deletions modules/contact-form/block/components/JetpackFieldMultiple.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*global wp*/
/** @jsx wp.element.createElement */
/** @format */

/**
* External dependencies
*/
import {
BaseControl,
IconButton
} from '@wordpress/components';

import {
withInstanceId
} from '@wordpress/compose';

import {
Component,
Fragment
} from '@wordpress/element';

import {
__
} from '@wordpress/i18n';

/**
* Internal dependencies
*/
import JetpackFieldSettings from './JetpackFieldSettings';
import JetpackFieldLabel from './JetpackFieldLabel';
import JetpackOption from './JetpackOption';

class JetpackFieldMultiple extends Component {
constructor( ...args ) {
super( ...args );
this.onChangeOption = this.onChangeOption.bind( this );
}

onChangeOption( key = null, option = null ) {
const newOptions = this.props.options.slice( 0 );
if ( 'object' === typeof key ) {
newOptions.push( '' );
} else if ( null === option ) {
newOptions.splice( key, 1 );
} else {
newOptions.splice( key, 1, option );
}
this.props.setAttributes( { options: newOptions } );
}

render() {
this.type = this.props.type;

return (
<Fragment>
<JetpackFieldSettings
required={ this.props.required }
setAttributes={ this.props.setAttributes }
/>
<BaseControl
id={ `jetpack-field-multiple-${ this.props.instanceId }` }
className="jetpack-field"
label={ <JetpackFieldLabel
required={ this.props.required }
label={ this.props.label }
setAttributes={ this.props.setAttributes }
/> }
>
<ol id={ `jetpack-field-multiple-${ this.props.instanceId }` }>
{ this.props.options.map( ( option, index )=>(
<JetpackOption
type={ this.type }
key={ index }
option={ option }
index={ index }
onChangeOption={ this.onChangeOption }
/>
) ) }
</ol>
<IconButton
icon="insert"
label={ __( 'Insert option', 'jetpack' ) }
onClick={ this.onChangeOption }
> { __( 'Add', 'jetpack' ) }</IconButton>
</BaseControl>
</Fragment>
);
}
}

export default withInstanceId( JetpackFieldMultiple );
Loading