Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
34e73e7
Enable the color, spacing and alignment controls in the sidebar
donnchawp Dec 8, 2022
2416585
Add new parameters to the Name field
donnchawp Dec 8, 2022
ccc0dde
changelog
donnchawp Dec 8, 2022
67c266e
Updated name of project in changelog
donnchawp Dec 8, 2022
8d16597
Minor adjustment to supports.
donnchawp Dec 8, 2022
c0f42b9
Replace block supports by blockRadius sidebar component
donnchawp Dec 14, 2022
3fe55b3
Style the corner radius input box
donnchawp Dec 15, 2022
51b9417
Use an attributes object instead of passing the settings
donnchawp Dec 15, 2022
8da98c7
This should still be the setting.
donnchawp Dec 15, 2022
604f2b2
Added borderWidth and lineHeight.
donnchawp Dec 15, 2022
8b7263f
Added textcolor, backgroundcolor and bordercolor attributes
donnchawp Dec 15, 2022
448d5e3
Allow the color of the labels of the text input field to be changed.
donnchawp Dec 15, 2022
65d8e78
Style the label, instead of the default field
donnchawp Dec 15, 2022
0b605a2
Pass the attributes so it displays without error
donnchawp Dec 21, 2022
b78e6eb
Changes to sidebar settings:
donnchawp Dec 21, 2022
927c1c9
Rename panels, add Typography, move things
donnchawp Dec 21, 2022
98a14e5
Updates to styling:
donnchawp Dec 22, 2022
c7bc8ba
Make field and label styles into class variables.
donnchawp Dec 22, 2022
9089063
Style the textarea block background
donnchawp Dec 22, 2022
d17782f
Simplify how styles are represented.
donnchawp Dec 22, 2022
303e745
Add remaining typography and border controls
ice9js Jan 5, 2023
d7847e8
Fix JS condition
ice9js Jan 5, 2023
12d5945
Fix block settings defaults
ice9js Jan 5, 2023
2cfcc9d
Apply new block settings to all form blocks inside the editor
ice9js Jan 5, 2023
68fd1d7
Add control for changing field border color
ice9js Jan 5, 2023
443ff40
Fix edge cases for 0 values
ice9js Jan 5, 2023
b446ea5
Merge 'trunk' into 'add/styling_for_input_fields'
ice9js Jan 5, 2023
219b0cd
Fix field border control not indicating the right color
ice9js Jan 6, 2023
aea03e1
Add a useJetpackFieldStyles hook to manage processing attributes into…
ice9js Jan 6, 2023
5639367
Remove remaining style defaults
ice9js Jan 6, 2023
fdb4731
Fix multiple/single choice block
ice9js Jan 6, 2023
b42ed9b
Disable style controls for the dropdown field
ice9js Jan 6, 2023
90f1a5e
Fix number inputs
ice9js Jan 6, 2023
4433f99
Correctly parse '0' values on number inputs
ice9js Jan 9, 2023
b265a01
[not verified] Merge branch 'trunk' into add/styling_for_input_fields
ice9js Jan 11, 2023
668c599
Apply styles to the new dropdown block
ice9js Jan 11, 2023
313643e
Reorder the settings in the sidebar
ice9js Jan 11, 2023
92b8d1f
Pass attributes to the checkbox so it can be used in the label and field
donnchawp Jan 12, 2023
883f3a7
Add styling to checkbox in editor
donnchawp Jan 12, 2023
29479aa
[not verified]
donnchawp Jan 12, 2023
9dbb459
Apply label styles to the checkbox input
donnchawp Jan 12, 2023
494ed88
Pass the attributes to the consent terms field
donnchawp Jan 16, 2023
27ed4d9
Match these strings to the JS
donnchawp Jan 16, 2023
edd8032
Checkboxes only have limited settings
donnchawp Jan 16, 2023
868e25b
Only show text color settings on radio and checkboxes
donnchawp Jan 17, 2023
2dc9564
Avoid "uncontrolled input" errors by setting these properly
donnchawp Jan 17, 2023
b2b2146
Merge branch 'trunk' into add/styling_for_input_fields
donnchawp Jan 17, 2023
fcdba1c
Set defaults to avoid "uncontrolled to controlled" errors
donnchawp Jan 17, 2023
e80c863
Set defaults to '' and don't set block border settings
donnchawp Jan 18, 2023
70e2e6c
Remove border controls from single/multi selects
donnchawp Jan 18, 2023
4e87483
Simple change of "Input Field Styles" header text
donnchawp Jan 18, 2023
64bf2fe
Move the field width control into the "Input Field Styles" section
donnchawp Jan 18, 2023
c5432ff
Put these back in the fieldStyle with a shorthand check
donnchawp Jan 18, 2023
10cd3ec
Clean up the colorSettings and border controls, props @ice9js
donnchawp Jan 18, 2023
87fb92b
hasBorderControls should be inverted to work.
donnchawp Jan 18, 2023
380b205
Added blockBorder settings for the dropdown input
donnchawp Jan 19, 2023
9ce41d8
Replace TextControl with RangeControl, for testing
donnchawp Jan 19, 2023
19a1d81
Add lineheight control for labels
donnchawp Jan 19, 2023
93ee491
Frontend support for label lineheight
donnchawp Jan 19, 2023
10aadd3
Remove "Field" as we only have one border
donnchawp Jan 19, 2023
3fe323d
Fix padding above "BORDER WIDTH" setting. Props @ice9js
donnchawp Jan 23, 2023
998ca53
Linter change
donnchawp Jan 23, 2023
bf7eec9
Remove margin from lineheight control
donnchawp Jan 23, 2023
906b44f
Use border-size instead of border-width so dropdown behaves, props @j…
donnchawp Jan 23, 2023
4c7fa8f
Remove the block background colour attribute
donnchawp Jan 24, 2023
0a9bbd6
Remove the block background colour from the frontend too
donnchawp Jan 24, 2023
2a3526c
Remove withSlider from FontsizePicker, testing a bug
donnchawp Jan 24, 2023
0f613d7
Add this attribute to avoid a Gutenberg warning about the margin
donnchawp Jan 25, 2023
5414fea
Style the dropdown input only, not the outer div
donnchawp Jan 26, 2023
06e5f5d
Use the field border settings for the block
donnchawp Jan 26, 2023
32503e2
Swap label and input settings in sidebar
donnchawp Jan 26, 2023
34e4e5e
Put a paragraph tag around border controls. Not much margin
donnchawp Jan 26, 2023
bcebc81
Remove the <p> tag, it does nothing for the margin
donnchawp Jan 26, 2023
4959f8e
Collapse label and input settings by default
donnchawp Jan 26, 2023
e900f7a
Clean up dropdown, props @@jcheringer
donnchawp Jan 26, 2023
0dcf35f
Fix Sidebar elements spacing
jcheringer Jan 27, 2023
23d4b8e
Merge remote-tracking branch 'origin/trunk' into add/styling_for_inpu…
jeherve Jan 27, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Form Block: add styling of input fields
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ const FieldDefaults = {
type: 'number',
default: 100,
},
borderRadius: {
type: 'number',
default: '',
},
borderWidth: {
type: 'number',
default: '',
},
labelFontSize: {
type: 'string',
},
fieldFontSize: {
type: 'string',
},
lineHeight: {
type: 'number',
},
labelLineHeight: {
type: 'number',
},
inputColor: {
type: 'string',
},
labelColor: {
type: 'string',
},
fieldBackgroundColor: {
type: 'string',
},
borderColor: {
type: 'string',
},
},
transforms: {
to: [
Expand Down Expand Up @@ -134,6 +166,7 @@ const editField = type => props => {

return (
<JetpackField
clientId={ props.clientId }
type={ type }
label={ getFieldLabel( props ) }
required={ props.attributes.required }
Expand All @@ -144,6 +177,7 @@ const editField = type => props => {
placeholder={ props.attributes.placeholder }
id={ props.attributes.id }
width={ props.attributes.width }
attributes={ props.attributes }
/>
);
};
Expand All @@ -153,6 +187,7 @@ const editMultiField = type => props => {

return (
<JetpackFieldMultiple
clientId={ props.clientId }
label={ getFieldLabel( props ) }
required={ props.attributes.required }
requiredText={ props.attributes.requiredText }
Expand All @@ -162,6 +197,7 @@ const editMultiField = type => props => {
isSelected={ props.isSelected }
id={ props.attributes.id }
width={ props.attributes.width }
attributes={ props.attributes }
/>
);
};
Expand All @@ -174,6 +210,7 @@ const EditTextarea = props => {
label={ props.attributes.label }
required={ props.attributes.required }
requiredText={ props.attributes.requiredText }
attributes={ props.attributes }
setAttributes={ props.setAttributes }
isSelected={ props.isSelected }
defaultValue={ props.attributes.defaultValue }
Expand All @@ -197,6 +234,7 @@ const EditCheckbox = props => {
defaultValue={ props.attributes.defaultValue }
id={ props.attributes.id }
width={ props.attributes.width }
attributes={ props.attributes }
/>
);
};
Expand All @@ -214,6 +252,7 @@ const EditConsent = ( { attributes, clientId, isSelected, name, setAttributes }
implicitConsentMessage={ implicitConsentMessage }
explicitConsentMessage={ explicitConsentMessage }
setAttributes={ setAttributes }
attributes={ attributes }
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { InspectorControls } from '@wordpress/block-editor';
import {
FontSizePicker,
InspectorAdvancedControls,
InspectorControls,
PanelColorSettings,
} from '@wordpress/block-editor';
import { PanelBody, ToggleControl } from '@wordpress/components';
import { withInstanceId } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import JetpackFieldControls from './jetpack-field-controls';
import JetpackFieldCss from './jetpack-field-css';
import JetpackFieldLabel from './jetpack-field-label';
import JetpackFieldWidth from './jetpack-field-width';
import JetpackManageResponsesSettings from './jetpack-manage-responses-settings';
import { useJetpackFieldStyles } from './use-jetpack-field-styles';

function JetpackFieldCheckbox( props ) {
const {
Expand All @@ -15,12 +23,16 @@ function JetpackFieldCheckbox( props ) {
setAttributes,
width,
defaultValue,
attributes,
} = props;

const { blockStyle } = useJetpackFieldStyles( attributes );

return (
<div
id={ `jetpack-field-checkbox-${ instanceId }` }
className="jetpack-field jetpack-field-checkbox"
style={ blockStyle }
>
<input
className="jetpack-field-checkbox__checkbox"
Expand All @@ -33,12 +45,7 @@ function JetpackFieldCheckbox( props ) {
requiredText={ requiredText }
label={ label }
setAttributes={ setAttributes }
/>
<JetpackFieldControls
id={ id }
required={ required }
width={ width }
setAttributes={ setAttributes }
attributes={ attributes }
/>
<InspectorControls>
<PanelBody title={ __( 'Checkbox Settings', 'jetpack' ) }>
Expand All @@ -49,6 +56,50 @@ function JetpackFieldCheckbox( props ) {
/>
</PanelBody>
</InspectorControls>
<InspectorControls>
<PanelBody title={ __( 'Manage Responses', 'jetpack' ) }>
<JetpackManageResponsesSettings isChildBlock />
</PanelBody>
<PanelBody title={ __( 'Field Settings', 'jetpack' ) }>
<ToggleControl
label={ __( 'Field is required', 'jetpack' ) }
className="jetpack-field-label__required"
checked={ required }
onChange={ value => setAttributes( { required: value } ) }
help={ __( 'You can edit the "required" label in the editor', 'jetpack' ) }
/>
<JetpackFieldWidth setAttributes={ setAttributes } width={ width } />
</PanelBody>

<PanelColorSettings
title={ __( 'Color', 'jetpack' ) }
initialOpen={ false }
colorSettings={ [
{
value: attributes.labelColor,
onChange: value => setAttributes( { labelColor: value } ),
label: __( 'Label Text', 'jetpack' ),
},
] }
></PanelColorSettings>
<PanelBody
title={ __( 'Label Styles', 'jetpack' ) }
initialOpen={ attributes.labelFontSize }
>
<FontSizePicker
withSlider
withReset={ true }
size="__unstable-large"
__nextHasNoMarginBottom
onChange={ labelFontSize => setAttributes( { labelFontSize } ) }
value={ attributes.labelFontSize }
/>
</PanelBody>
</InspectorControls>

<InspectorAdvancedControls>
<JetpackFieldCss setAttributes={ setAttributes } id={ id } />
</InspectorAdvancedControls>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const JetpackFieldConsent = ( {
implicitConsentMessage,
explicitConsentMessage,
setAttributes,
attributes,
} ) => {
return (
<div
Expand All @@ -32,6 +33,7 @@ const JetpackFieldConsent = ( {
explicit: explicitConsentMessage,
}[ consentType ] ?? ''
}
attributes={ attributes }
setAttributes={ setAttributes }
labelFieldName={ `${ consentType }ConsentMessage` }
placeholder={ sprintf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {
FontSizePicker,
InspectorAdvancedControls,
InspectorControls,
LineHeightControl,
BlockControls,
PanelColorSettings,
} from '@wordpress/block-editor';
import {
BaseControl,
PanelBody,
TextControl,
ToggleControl,
ToolbarGroup,
ToolbarButton,
Path,
RangeControl,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import renderMaterialIcon from '../../../shared/render-material-icon';
Expand All @@ -18,13 +23,48 @@ import JetpackFieldWidth from './jetpack-field-width';
import JetpackManageResponsesSettings from './jetpack-manage-responses-settings';

const JetpackFieldControls = ( {
setAttributes,
width,
attributes,
id,
required,
placeholder,
placeholderField = 'placeholder',
required,
setAttributes,
width,
type,
} ) => {
const setNumberAttribute = ( key, parse = parseInt ) => value => {
const parsedValue = parse( value, 10 );

setAttributes( {
[ key ]: ! isNaN( parsedValue ) ? parsedValue : '',
} );
};

const hasBorderControls = type !== 'radio' && type !== 'checkbox';

const colorSettings = [
{
value: attributes.labelColor,
onChange: value => setAttributes( { labelColor: value } ),
label: __( 'Label Text', 'jetpack' ),
},
{
value: attributes.inputColor,
onChange: value => setAttributes( { inputColor: value } ),
label: __( 'Field Text', 'jetpack' ),
},
{
value: attributes.fieldBackgroundColor,
onChange: value => setAttributes( { fieldBackgroundColor: value } ),
label: __( 'Field Background', 'jetpack' ),
},
{
value: attributes.borderColor,
onChange: value => setAttributes( { borderColor: value } ),
label: __( 'Border', 'jetpack' ),
},
];

return (
<>
<BlockControls>
Expand Down Expand Up @@ -67,8 +107,72 @@ const JetpackFieldControls = ( {
'jetpack'
) }
/>

</PanelBody>
<PanelColorSettings
title={ __( 'Color', 'jetpack' ) }
initialOpen={ false }
colorSettings={ ! hasBorderControls ? colorSettings.slice( 0, 2 ) : colorSettings }
/>
<PanelBody title={ __( 'Input Field Styles', 'jetpack' ) } initialOpen={ false }>
<JetpackFieldWidth setAttributes={ setAttributes } width={ width } />
<BaseControl>
<FontSizePicker
withReset={ true }
size="__unstable-large"
__nextHasNoMarginBottom
onChange={ fieldFontSize => setAttributes( { fieldFontSize } ) }
value={ attributes.fieldFontSize }
/>
</BaseControl>
<BaseControl>
<LineHeightControl
__nextHasNoMarginBottom={ true }
__unstableInputWidth="100%"
value={ attributes.lineHeight }
onChange={ setNumberAttribute( 'lineHeight', parseFloat ) }
size="__unstable-large"
/>
</BaseControl>
{ hasBorderControls && (
<>
<RangeControl
label={ __( 'Border Width', 'jetpack' ) }
value={ attributes.borderWidth }
initialPosition={ 1 }
onChange={ setNumberAttribute( 'borderWidth' ) }
min={ 0 }
max={ 100 }
/>
<RangeControl
label={ __( 'Border Radius', 'jetpack' ) }
value={ attributes.borderRadius }
initialPosition={ 0 }
onChange={ setNumberAttribute( 'borderRadius' ) }
min={ 0 }
max={ 100 }
/>
</>
) }
</PanelBody>
<PanelBody title={ __( 'Label Styles', 'jetpack' ) } initialOpen={ false }>
<BaseControl>
<FontSizePicker
withReset={ true }
size="__unstable-large"
__nextHasNoMarginBottom
onChange={ labelFontSize => setAttributes( { labelFontSize } ) }
value={ attributes.labelFontSize }
/>
</BaseControl>
<BaseControl>
<LineHeightControl
__unstableInputWidth="100%"
__nextHasNoMarginBottom={ true }
value={ attributes.labelLineHeight }
onChange={ setNumberAttribute( 'labelLineHeight', parseFloat ) }
size="__unstable-large"
/>
</BaseControl>
</PanelBody>
</InspectorControls>

Expand Down
Loading