-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathsave.js
More file actions
81 lines (73 loc) · 2.1 KB
/
save.js
File metadata and controls
81 lines (73 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* External dependencies
*/
import { withVersion } from '~stackable/higher-order'
import classnames from 'classnames'
import { version as VERSION } from 'stackable'
import {
getTypographyClasses,
BlockDiv,
CustomCSS,
Button,
Typography,
getResponsiveClasses,
CustomAttributes,
getAlignmentClasses,
} from '~stackable/block-components'
/**
* WordPress dependencies
*/
import { compose } from '@wordpress/compose'
import { useBlockProps } from '@wordpress/block-editor'
import { applyFilters } from '@wordpress/hooks'
export const Save = props => {
const {
className,
...propsToPass
} = props
const responsiveClass = getResponsiveClasses( props.attributes )
const customAttributes = CustomAttributes.getCustomAttributes( props.attributes )
const typographyInnerClasses = getTypographyClasses( props.attributes )
const blockAlignmentClass = getAlignmentClasses( props.attributes )
const blockClassNames = classnames( [
className,
'stk-block-button',
blockAlignmentClass,
responsiveClass,
] )
const typographyInnerClassNames = classnames( [
typographyInnerClasses,
'stk-button__inner-text',
] )
return (
applyFilters( 'stackable.button.save.blockDiv.content', (
<BlockDiv.Content
{ ...useBlockProps.save( { className: blockClassNames } ) }
attributes={ props.attributes }
applyCustomAttributes={ false }
version={ props.version }
blockTag={ props.attributes.className === 'is-style-link' ? 'p' : null }
>
{ props.attributes.generatedCss && <style>{ props.attributes.generatedCss }</style> }
<CustomCSS.Content attributes={ props.attributes } />
<Button.Content
{ ...propsToPass }
attributes={ props.attributes }
buttonProps={ {
id: props.attributes.anchorId || undefined,
...customAttributes,
} }
>
<Typography.Content
attributes={ props.attributes }
tagName="span"
className={ typographyInnerClassNames }
/>
</Button.Content>
</BlockDiv.Content>
), props, propsToPass, blockClassNames, customAttributes, typographyInnerClassNames )
)
}
export default compose(
withVersion( VERSION )
)( Save )