Skip to content

Commit 803dc06

Browse files
GambitGambit
authored andcommitted
border width in block editor override default
1 parent 8357e6c commit 803dc06

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/block-components/helpers/borders/edit.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ export const BORDER_CONTROLS = [
3636
},
3737
]
3838

39+
const BORDER_CONTROLS_WITH_NONE_VALUE = [
40+
{
41+
value: 'none',
42+
title: __( 'None', i18n ),
43+
},
44+
{
45+
value: 'solid',
46+
title: __( 'Solid', i18n ),
47+
},
48+
{
49+
value: 'dashed',
50+
title: __( 'Dashed', i18n ),
51+
},
52+
{
53+
value: 'dotted',
54+
title: __( 'Dotted', i18n ),
55+
},
56+
]
57+
3958
export const BorderControls = props => {
4059
const {
4160
getAttribute,
@@ -47,14 +66,18 @@ export const BorderControls = props => {
4766

4867
const borderTypeValue = getAttribute( 'borderType' ) || props.borderTypeValue
4968

69+
const hasBorderType = borderTypeValue !== '' && borderTypeValue !== 'none'
70+
71+
const borderControls = getPlaceholder( `${ props.placeholderTemplate }-border-style` ) !== '' ? BORDER_CONTROLS_WITH_NONE_VALUE : BORDER_CONTROLS
72+
5073
applyFilters( 'stackable.block-component.helpers.borders', null, getAttribute, updateAttributes )
5174

5275
return (
5376
<Fragment>
5477
{ props.hasBorderType &&
5578
<AdvancedToolbarControl
5679
label={ __( 'Borders', i18n ) }
57-
controls={ BORDER_CONTROLS }
80+
controls={ borderControls }
5881
className="ugb-border-controls__border-type-toolbar"
5982
attribute={ getAttrName( 'borderType' ) }
6083
fullwidth={ true }
@@ -63,7 +86,7 @@ export const BorderControls = props => {
6386
/>
6487
}
6588

66-
{ borderTypeValue && props.hasBorderControls &&
89+
{ hasBorderType && props.hasBorderControls &&
6790
<FourRangeControl
6891
label={ __( 'Border Width', i18n ) }
6992
attribute={ getAttrName( 'borderWidth' ) }
@@ -78,7 +101,7 @@ export const BorderControls = props => {
78101
/>
79102
}
80103

81-
{ borderTypeValue && props.hasBorderControls &&
104+
{ hasBorderType && props.hasBorderControls &&
82105
<ColorPaletteControl
83106
label={ __( 'Border Color', i18n ) }
84107
attribute={ getAttrName( 'borderColor' ) }

src/block-components/helpers/borders/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const addBorderStyles = ( blockStyleGenerator, props = {} ) => {
1111
attrNameTemplate = '%s',
1212
hoverSelector,
1313
borderRadiusSelector,
14-
borderEnabledCallback = getAttribute => getAttribute( 'borderType' ),
14+
borderEnabledCallback = getAttribute => getAttribute( 'borderType' ) !== '' && getAttribute( 'borderType' ) !== 'none',
1515
} = props
1616

1717
// The style below is deprecated. We have to keep it because users who have

0 commit comments

Comments
 (0)