Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions src/__block-container-template/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import { BlockCssCompiler } from '~stackable/components'
*/
import { memo } from '@wordpress/element'
import { applyFilters } from '@wordpress/hooks'
import { getPropsWithDefaults } from '../util/props'

const alignmentOptions = {
editorSelectorCallback: getAttribute => `.stk--block-align-${ getAttribute( 'uniqueId' ) } > .block-editor-inner-blocks > .block-editor-block-list__layout`,
}

const BlockStyles = memo( props => {
const BlockStyles = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_STYLES_DEFAULT_PROPS )
const columnArrangement = useBlockAttributesContext( attributes => attributes.columnArrangementMobile || attributes.columnArrangementTablet )
const numColumns = ( columnArrangement || '' ).split( ',' ).length

Expand All @@ -45,11 +47,12 @@ const BlockStyles = memo( props => {
)
} )

BlockStyles.defaultProps = {
const BLOCK_STYLES_DEFAULT_PROPS = {
version: '',
}

BlockStyles.Content = props => {
BlockStyles.Content = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_STYLES_CONTENT_DEFAULT_PROPS )
if ( props.attributes.generatedCss ) {
return <style>{ props.attributes.generatedCss }</style>
}
Expand All @@ -72,7 +75,7 @@ BlockStyles.Content = props => {
)
}

BlockStyles.Content.defaultProps = {
const BLOCK_STYLES_CONTENT_DEFAULT_PROPS = {
version: '',
attributes: {},
}
Expand Down
11 changes: 7 additions & 4 deletions src/__block-template/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
* WordPress dependencies
*/
import { memo } from '@wordpress/element'
import { getPropsWithDefaults } from '../util/props'

const typographyOptions = {
selector: '.stk-block-text__text',
Expand Down Expand Up @@ -48,7 +49,8 @@ const Styles = () => {
)
}

export const BlockStyles = memo( props => {
export const BlockStyles = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_STYLES_DEFAULT_PROPS )
return (
<>
<Alignment.Style { ...props } />
Expand All @@ -62,11 +64,12 @@ export const BlockStyles = memo( props => {
)
} )

BlockStyles.defaultProps = {
const BLOCK_STYLES_DEFAULT_PROPS = {
version: '',
}

BlockStyles.Content = props => {
BlockStyles.Content = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_STYLES_CONTENT_DEFAULT_PROPS )
if ( props.attributes.generatedCss ) {
return <style>{ props.attributes.generatedCss }</style>
}
Expand All @@ -85,7 +88,7 @@ BlockStyles.Content = props => {
)
}

BlockStyles.Content.defaultProps = {
const BLOCK_STYLES_CONTENT_DEFAULT_PROPS = {
version: '',
attributes: {},
}
Expand Down
6 changes: 4 additions & 2 deletions src/block-components/alignment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { memo } from '@wordpress/element'
import { sprintf, __ } from '@wordpress/i18n'
import { addFilter } from '@wordpress/hooks'
import { useSelect } from '@wordpress/data'
import { getPropsWithDefaults } from '../../util/props'

const ALIGN_OPTIONS = [
{
Expand All @@ -53,7 +54,8 @@ const ALIGN_OPTIONS = [

const ALIGN_OPTIONS_NO_JUSTIFY = ALIGN_OPTIONS.filter( option => option.align !== 'justify' )

export const Edit = memo( props => {
export const Edit = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, EDIT_DEFAULT_PROPS )
const {
contentAlign,
columnJustify,
Expand Down Expand Up @@ -382,7 +384,7 @@ if ( userAgent && userAgent.indexOf( 'Firefox' ) !== -1 ) {
} )
}

Edit.defaultProps = {
const EDIT_DEFAULT_PROPS = {
hasColumnJustify: false,
hasRowAlignment: false,
hasColumnAlignment: false,
Expand Down
6 changes: 4 additions & 2 deletions src/block-components/block-div/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import {
*/
import { __ } from '@wordpress/i18n'
import { memo } from '@wordpress/element'
import { getPropsWithDefaults } from '../../util/props'

export const Edit = memo( props => {
export const Edit = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, EDIT_DEFAULT_PROPS )
const {
hasSizeSpacing,
initialOpen,
Expand Down Expand Up @@ -126,7 +128,7 @@ export const Edit = memo( props => {
)
} )

Edit.defaultProps = {
const EDIT_DEFAULT_PROPS = {
hasSizeSpacing: true,
initialOpen: false,
sizeControlLayoutProps: {},
Expand Down
11 changes: 7 additions & 4 deletions src/block-components/block-div/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import classnames from 'classnames/dedupe'
import { Div } from '~stackable/components'
import { useVariationPicker } from '~stackable/hooks'
import { getUniqueBlockClass, useQueryLoopInstanceId } from '~stackable/util'
import { getPropsWithDefaults } from '../../util/props'
import { memo } from '@wordpress/element'

import { useBlockProps } from '@wordpress/block-editor'
Expand All @@ -22,7 +23,8 @@ export {
deprecateBlockBackgroundColorOpacity, deprecateBlockShadowColor, deprecateBlockHeight,
} from './deprecated'

export const BlockDiv = memo( props => {
export const BlockDiv = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_DIV_DEFAULT_PROPS )
const {
className,
applyCustomAttributes,
Expand Down Expand Up @@ -103,7 +105,7 @@ export const BlockDiv = memo( props => {
</Div>
} )

BlockDiv.defaultProps = {
const BLOCK_DIV_DEFAULT_PROPS = {
className: '',
applyCustomAttributes: true,
renderHtmlTag: true, // If true, this renders the HTML Tag based from the block attributes.
Expand All @@ -113,7 +115,8 @@ BlockDiv.defaultProps = {
blockTag: 'div',
}

BlockDiv.Content = props => {
BlockDiv.Content = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_DIV_CONTENT_DEFAULT_PROPS )
const {
className,
attributes,
Expand Down Expand Up @@ -169,7 +172,7 @@ BlockDiv.Content = props => {
/>
}

BlockDiv.Content.defaultProps = {
const BLOCK_DIV_CONTENT_DEFAULT_PROPS = {
version: VERSION,
className: '',
attributes: {},
Expand Down
6 changes: 4 additions & 2 deletions src/block-components/block-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
*/
import { __ } from '@wordpress/i18n'
import { LinkControls } from '../helpers/link'
import { getPropsWithDefaults } from '../../util/props'

export const Edit = props => {
export const Edit = incomingProps => {
const props = getPropsWithDefaults( incomingProps, EDIT_DEFAULT_PROPS )
const {
hasLink,
hasTitle,
Expand Down Expand Up @@ -41,7 +43,7 @@ export const Edit = props => {
)
}

Edit.defaultProps = {
const EDIT_DEFAULT_PROPS = {
hasLink: true,
hasTitle: true,
hasLightbox: true,
Expand Down
6 changes: 4 additions & 2 deletions src/block-components/block-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { Edit } from './edit'
* External dependencies
*/
import { Link } from '~stackable/components'
import { getPropsWithDefaults } from '../../util/props'

export const BlockLink = () => {
return null
}

BlockLink.Content = props => {
BlockLink.Content = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BLOCK_LINK_CONTENT_DEFAULT_PROPS )
const {
href, attributes, isHidden,
} = props
Expand All @@ -35,7 +37,7 @@ BlockLink.Content = props => {
)
}

BlockLink.Content.defaultProps = {
const BLOCK_LINK_CONTENT_DEFAULT_PROPS = {
className: '',
attributes: {},
href: '',
Expand Down
6 changes: 4 additions & 2 deletions src/block-components/block-style/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import {
*/
import { __ } from '@wordpress/i18n'
import { memo } from '@wordpress/element'
import { getPropsWithDefaults } from '../../util/props'

export const Edit = memo( props => {
export const Edit = memo( incomingProps => {
const props = getPropsWithDefaults( incomingProps, EDIT_DEFAULT_PROPS )
return (
<InspectorStyleControls>
<PanelAdvancedSettings
Expand All @@ -34,7 +36,7 @@ export const Edit = memo( props => {
)
} )

Edit.defaultProps = {
const EDIT_DEFAULT_PROPS = {
initialOpen: true,
styles: [],
}
30 changes: 18 additions & 12 deletions src/block-components/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import { applyFilters } from '@wordpress/hooks'
import { useSelect } from '@wordpress/data'
import { useBlockEditContext } from '@wordpress/block-editor'
import { getAttributeNameFunc } from '~stackable/util'
import { getPropsWithDefaults } from '../../util/props'

export const Icon = props => (
<_Icon.InspectorControls
export const Icon = incomingProps => {
const props = getPropsWithDefaults( incomingProps, ICON_DEFAULT_PROPS )
return <_Icon.InspectorControls
hasColor={ props.hasColor }
hasGradient={ false }
hasShape={ false }
Expand All @@ -44,9 +46,9 @@ export const Icon = props => (
iconSizePlaceholderName="button-icon-size"
iconGapPlaceholderName={ props.iconGapPlaceholderName }
/>
)
}

Icon.defaultProps = {
const ICON_DEFAULT_PROPS = {
hasIconGap: true,
hasIconPosition: true,
hasColor: true,
Expand Down Expand Up @@ -159,7 +161,8 @@ export const ColorsControls = props => {
</> )
}

export const Colors = props => {
export const Colors = incomingProps => {
const props = getPropsWithDefaults( incomingProps, COLORS_DEFAULT_PROPS )
return (
<InspectorStyleControls>
<PanelAdvancedSettings
Expand All @@ -172,7 +175,7 @@ export const Colors = props => {
)
}

Colors.defaultProps = {
const COLORS_DEFAULT_PROPS = {
hasTextColor: true,
hasIconColor: false,
}
Expand Down Expand Up @@ -239,7 +242,8 @@ const SizeControls = props => {
</> )
}

export const Size = props => {
export const Size = incomingProps => {
const props = getPropsWithDefaults( incomingProps, SIZE_DEFAULT_PROPS )
return (
<InspectorStyleControls>
<PanelAdvancedSettings
Expand All @@ -252,7 +256,7 @@ export const Size = props => {
)
}

Size.defaultProps = {
const SIZE_DEFAULT_PROPS = {
hasWidth: false,
}

Expand All @@ -277,7 +281,8 @@ const BorderControls = props => {
)
}

export const Borders = props => {
export const Borders = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BORDERS_DEFAULT_PROPS )
return (
<InspectorStyleControls>
<PanelAdvancedSettings
Expand All @@ -294,11 +299,12 @@ export const Borders = props => {
)
}

Borders.defaultProps = {
const BORDERS_DEFAULT_PROPS = {
borderSelector: '',
}

export const Edit = props => {
export const Edit = incomingProps => {
const props = getPropsWithDefaults( incomingProps, EDIT_DEFAULT_PROPS )
const {
borderSelector,
hasTextColor,
Expand Down Expand Up @@ -347,7 +353,7 @@ export const Edit = props => {
)
}

Edit.defaultProps = {
const EDIT_DEFAULT_PROPS = {
hasIcon: true,
hasLink: true,
borderSelector: '',
Expand Down
11 changes: 7 additions & 4 deletions src/block-components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { Edit } from './edit'
import { Link } from '../link'
import { Icon } from '../icon'
import { getButtonClasses } from './get-button-classes'
import { getPropsWithDefaults } from '../../util/props'

export { getButtonClasses }
export { deprecateButtonGradientColor } from './deprecated'

export const Button = props => {
export const Button = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BUTTON_DEFAULT_PROPS )
const {
className,
buttonProps,
Expand All @@ -44,12 +46,13 @@ export const Button = props => {
)
}

Button.defaultProps = {
const BUTTON_DEFAULT_PROPS = {
className: '',
buttonProps: {},
}

Button.Content = props => {
Button.Content = incomingProps => {
const props = getPropsWithDefaults( incomingProps, BUTTON_CONTENT_DEFAULT_PROPS )
const {
className,
attributes,
Expand All @@ -72,7 +75,7 @@ Button.Content = props => {
)
}

Button.Content.defaultProps = {
const BUTTON_CONTENT_DEFAULT_PROPS = {
className: '',
buttonProps: {},
}
Expand Down
Loading
Loading