@@ -20,36 +20,6 @@ import {
2020 getBlockVariations ,
2121} from '@wordpress/blocks'
2222
23- /* eslint-disable jsx-a11y/anchor-is-valid */
24- export const DefaultButton = ( {
25- text, dataDevice = 'desktop' , style = '' ,
26- } ) => {
27- return < >
28- < div className = "wp-block-stackable-button stk-block-button stk-block stk-5609083" data-block-id = "5609083" >
29- { style && < style > { style } </ style > }
30- < a className = "stk-link stk-button stk--hover-effect-darken" href = "" onClick = { e => e . preventDefault ( ) } >
31- < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = { dataDevice } > { text } </ span >
32- </ a >
33- </ div >
34- </ >
35- }
36-
37- export const DefaultOutlineButton = ( {
38- text, dataDevice = 'desktop' , style = '' ,
39- } ) => {
40- return < >
41-
42- < div className = "wp-block-stackable-button stk-block-button is-style-ghost stk-block stk-3f9ae3c" data-block-id = "3f9ae3c" >
43- < style > { '.stk-3f9ae3c .stk-button{background:transparent !important;}.stk-3f9ae3c .stk-button:hover:after{background:transparent !important;opacity:1 !important;}:where(.stk-hover-parent:hover, .stk-hover-parent.stk--is-hovered) .stk-3f9ae3c .stk-button:after{background:transparent !important;opacity:1 !important;}.stk-3f9ae3c .stk-button:before{border-style:solid !important;}' } </ style >
44- { style && < style > { style } </ style > }
45- < a className = "stk-link stk-button stk--hover-effect-darken" href = "" onClick = { e => e . preventDefault ( ) } >
46- < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = { dataDevice } > { text } </ span >
47- </ a >
48- </ div >
49-
50- </ >
51- }
52-
5323export const DUMMY_COLOR_SCHEMES = [
5424 {
5525 name : 'Base Color Scheme' ,
@@ -87,6 +57,23 @@ export const DUMMY_COLOR_SCHEMES = [
8757
8858const SERIALIZE_CALLBACKS = {
8959 'stackable/tabs' : serialized => serialized . replace ( '"stk-block-tabs__tab"' , '"stk-block-tabs__tab stk-block-tabs__tab--active"' ) ,
60+ 'stackable/countdown' : serialized => serialized . replace (
61+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-day"></div>' ,
62+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-day">10</div>'
63+ ) . replace (
64+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-hour"></div>' ,
65+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-hour">12</div>'
66+ ) . replace (
67+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-minute"></div>' ,
68+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-minute">30</div>'
69+ ) . replace (
70+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-second"></div>' ,
71+ '<div class="stk-block-countdown__digit stk-block-countdown__digit-second">45</div>' ,
72+ ) ,
73+ 'stackable/icon-list' : ( serialized , attributes ) => serialized . replace (
74+ / # s t k - i c o n - l i s t _ _ i c o n - s v g - d e f - [ ^ " ] * / g,
75+ `#stk-icon-list__icon-svg-def-${ attributes . uniqueId } `
76+ ) ,
9077}
9178
9279const ADDITIONAL_ATTRIBUTES = {
@@ -99,6 +86,49 @@ const ADDITIONAL_ATTRIBUTES = {
9986 'stackable/number-box' : { text : __ ( '1' , i18n ) } ,
10087}
10188
89+ const INNER_BLOCK_CALLBACKS = {
90+ 'stackable/team-member' : innerBlocks => {
91+ innerBlocks [ 0 ] . attributes . imageExternalUrl = `${ srcUrl } /${ profile } `
92+
93+ return innerBlocks
94+ } ,
95+ 'stackable/testimonial' : innerBlocks => {
96+ innerBlocks [ 1 ] . attributes . imageExternalUrl = `${ srcUrl } /${ profile } `
97+
98+ return innerBlocks
99+ } ,
100+ }
101+
102+ /* eslint-disable jsx-a11y/anchor-is-valid */
103+ export const DefaultButton = ( {
104+ text, dataDevice = 'desktop' , style = '' ,
105+ } ) => {
106+ return < >
107+ < div className = "wp-block-stackable-button stk-block-button stk-block stk-5609083" data-block-id = "5609083" >
108+ { style && < style > { style } </ style > }
109+ < a className = "stk-link stk-button stk--hover-effect-darken" href = "" onClick = { e => e . preventDefault ( ) } >
110+ < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = { dataDevice } > { text } </ span >
111+ </ a >
112+ </ div >
113+ </ >
114+ }
115+
116+ export const DefaultOutlineButton = ( {
117+ text, dataDevice = 'desktop' , style = '' ,
118+ } ) => {
119+ return < >
120+
121+ < div className = "wp-block-stackable-button stk-block-button is-style-ghost stk-block stk-3f9ae3c" data-block-id = "3f9ae3c" >
122+ < style > { '.stk-3f9ae3c .stk-button{background:transparent !important;}.stk-3f9ae3c .stk-button:hover:after{background:transparent !important;opacity:1 !important;}:where(.stk-hover-parent:hover, .stk-hover-parent.stk--is-hovered) .stk-3f9ae3c .stk-button:after{background:transparent !important;opacity:1 !important;}.stk-3f9ae3c .stk-button:before{border-style:solid !important;}' } </ style >
123+ { style && < style > { style } </ style > }
124+ < a className = "stk-link stk-button stk--hover-effect-darken" href = "" onClick = { e => e . preventDefault ( ) } >
125+ < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = { dataDevice } > { text } </ span >
126+ </ a >
127+ </ div >
128+
129+ </ >
130+ }
131+
102132const getGeneratedCss = ( blocks , generateForInnerBlocks = false ) => {
103133 return blocks . map ( block => {
104134 if ( ! block . attributes . uniqueId ) {
@@ -129,14 +159,15 @@ const getGeneratedCss = ( blocks, generateForInnerBlocks = false ) => {
129159 } )
130160}
131161
132- export const RenderBlock = props => {
162+ const getSerializedBlock = props => {
133163 const {
134- blockName, attributes, innerBlocks, name = __ ( 'Default' , i18n ) ,
164+ blockName : _blockName , attributes, innerBlocks,
135165 } = props
136166
137- const block = createBlock ( blockName , attributes , innerBlocks )
138- const newBlock = getGeneratedCss ( [ block ] )
167+ let blockName = _blockName
139168
169+ let block = createBlock ( blockName , attributes , innerBlocks )
170+ let newBlock = getGeneratedCss ( [ block ] )
140171 let serialized = serialize ( newBlock )
141172
142173 if ( blockName === 'stackable/timeline' ) {
@@ -146,27 +177,45 @@ export const RenderBlock = props => {
146177 serialized += '\n' + serialize ( duplicateBlock )
147178 }
148179
180+ if ( blockName === 'stackable/accordion' ) {
181+ const _block = createBlock ( blockName , attributes , innerBlocks )
182+ _block . attributes . startOpen = true
183+ _block . attributes . blockMargin = {
184+ top : 24 , bottom : 0 , left : 0 , right : 0 ,
185+ }
186+ const duplicateBlock = getGeneratedCss ( [ _block ] )
187+ serialized += '\n' + serialize ( duplicateBlock )
188+ }
189+
190+ if ( blockName === 'stackable/icon-list-item' ) {
191+ block = createBlock ( 'stackable/icon-list' , { } , [ block ] )
192+ newBlock = getGeneratedCss ( [ block ] )
193+ serialized = serialize ( newBlock )
194+ blockName = 'stackable/icon-list'
195+ }
196+
197+ return {
198+ serialized, blockName, attributes : block . attributes ,
199+ }
200+ }
201+
202+ export const RenderBlock = props => {
203+ const {
204+ name = __ ( 'Default' , i18n ) , ...propsToPass
205+ } = props
206+
207+ const {
208+ serialized, blockName, attributes,
209+ } = getSerializedBlock ( propsToPass )
210+
149211 return (
150212 < RawHTML >
151- { cleanSerializedBlock ( serialized , SERIALIZE_CALLBACKS [ blockName ] ) }
213+ { cleanSerializedBlock ( serialized , SERIALIZE_CALLBACKS [ blockName ] , attributes ) }
152214 { `<p>${ name } </p>` }
153215 </ RawHTML >
154216 )
155217}
156218
157- const INNER_BLOCK_CALLBACKS = {
158- 'stackable/team-member' : innerBlocks => {
159- innerBlocks [ 0 ] . attributes . imageExternalUrl = `${ srcUrl } /${ profile } `
160-
161- return innerBlocks
162- } ,
163- 'stackable/testimonial' : innerBlocks => {
164- innerBlocks [ 1 ] . attributes . imageExternalUrl = `${ srcUrl } /${ profile } `
165-
166- return innerBlocks
167- } ,
168- }
169-
170219export const getPlaceholders = blockName => {
171220 let innerBlocks = [ ]
172221 let attributes = { }
0 commit comments