Skip to content

Commit d66876a

Browse files
committed
fix save and deprecated
1 parent 333ee5c commit d66876a

File tree

10 files changed

+67
-47
lines changed

10 files changed

+67
-47
lines changed

src/block/carousel/deprecated.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ import { withVersion } from '~stackable/higher-order'
1010
import { addFilter } from '@wordpress/hooks'
1111
import { semverCompare } from '~stackable/util'
1212

13-
addFilter( 'stackable.carousel.save.slider', 'stackable/3.19.0', version => {
13+
addFilter( 'stackable.carousel.save.slider-props', 'stackable/3.19.0', ( sliderProps, version ) => {
1414
if ( semverCompare( version, '<', '3.19.0' ) ) {
15-
return {}
15+
return {
16+
...sliderProps,
17+
tabIndex: undefined,
18+
}
1619
}
1720

18-
return { tabIndex: 0 }
21+
return sliderProps
1922
} )
2023

2124
const deprecated = [

src/block/carousel/save.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ export const Save = props => {
8181
role="list"
8282
data-autoplay={ attributes.autoplay ? ( attributes.autoplaySpeed || '4000' ) : undefined }
8383
data-label-slide-of={ attributes.ariaLabelPrev || 'Slide %%d of %%d' }
84-
{ ...applyFilters( 'stackable.carousel.save.slider', props.version ) }
84+
{ ...applyFilters( 'stackable.carousel.save.slider-props', {
85+
className: 'stk-block-carousel__slider',
86+
role: 'list',
87+
'data-autoplay': attributes.autoplay ? ( attributes.autoplaySpeed || '4000' ) : undefined,
88+
'data-label-slide-of': attributes.ariaLabelPrev || 'Slide %%d of %%d',
89+
tabIndex: 0,
90+
}, props.version ) }
8591
>
8692
<InnerBlocks.Content />
8793
</div>

src/block/horizontal-scroller/deprecated.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ import { addFilter } from '@wordpress/hooks'
1010
import compareVersions from 'compare-versions'
1111
import { semverCompare } from '~stackable/util'
1212

13-
addFilter( 'stackable.horizontal-scroller.save.scroller', 'stackable/3.19.0', version => {
13+
addFilter( 'stackable.horizontal-scroller.save.scroller-props', 'stackable/3.19.0', ( scrollerProps, version ) => {
1414
if ( semverCompare( version, '<', '3.19.0' ) ) {
15-
return {}
15+
return {
16+
...scrollerProps,
17+
tabIndex: undefined,
18+
}
1619
}
1720

18-
return { tabIndex: 0 }
21+
return scrollerProps
1922
} )
2023

2124
// Previously, our horizontal scroller always had the stk--fit-content class (which was wrong).

src/block/horizontal-scroller/save.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ export const Save = props => {
5555
{ attributes.generatedCss && <style>{ attributes.generatedCss }</style> }
5656
<CustomCSS.Content attributes={ attributes } />
5757
<div
58-
className={ contentClassNames }
59-
{ ...applyFilters( 'stackable.horizontal-scroller.save.scroller', props.version ) }
58+
{ ...applyFilters( 'stackable.horizontal-scroller.save.scroller-props', {
59+
className: contentClassNames,
60+
tabIndex: 0,
61+
}, props.version ) }
6062
>
6163
<InnerBlocks.Content />
6264
</div>

src/block/notification/deprecated.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { attributes } from './schema'
77
/**
88
* External dependencies
99
*/
10-
import { i18n } from 'stackable'
1110
import { withVersion } from '~stackable/higher-order'
1211
import compareVersions from 'compare-versions'
1312
import {
@@ -24,14 +23,15 @@ import { semverCompare } from '~stackable/util'
2423
import { __ } from '@wordpress/i18n'
2524
import { addFilter } from '@wordpress/hooks'
2625

27-
addFilter( 'stackable.notification.save.close-button', 'stackable/3.19.0', version => {
26+
addFilter( 'stackable.notification.save.close-button-props', 'stackable/3.19.0', ( buttonProps, version ) => {
2827
if ( semverCompare( version, '<', '3.19.0' ) ) {
29-
return {}
28+
return {
29+
...buttonProps,
30+
'aria-label': undefined,
31+
}
3032
}
3133

32-
return {
33-
'aria-label': __( 'Close', i18n ),
34-
}
34+
return buttonProps
3535
} )
3636

3737
// Version 3.8 added horizontal flex, this changes the stk--block-orientation-* to stk--block-horizontal-flex.

src/block/notification/save.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SVGCloseIcon from './images/close-icon.svg'
66
/**
77
* External dependencies
88
*/
9-
import { version as VERSION } from 'stackable'
9+
import { version as VERSION, i18n } from 'stackable'
1010
import { withVersion } from '~stackable/higher-order'
1111
import classnames from 'classnames/dedupe'
1212
import {
@@ -22,6 +22,7 @@ import {
2222
/**
2323
* WordPress dependencies
2424
*/
25+
import { __ } from '@wordpress/i18n'
2526
import { InnerBlocks } from '@wordpress/block-editor'
2627
import { compose } from '@wordpress/compose'
2728
import { applyFilters } from '@wordpress/hooks'
@@ -78,7 +79,10 @@ export const Save = props => {
7879
{ attributes.isDismissible &&
7980
<button
8081
className="stk-block-notification__close-button"
81-
{ ...applyFilters( 'stackable.notification.save.close-button', props.version ) }
82+
{ ...applyFilters( 'stackable.notification.save.close-button-props', {
83+
className: 'stk-block-notification__close-button',
84+
'aria-label': __( 'Close', i18n ),
85+
}, props.version ) }
8286
>
8387
<SVGCloseIcon
8488
width={ attributes.dismissibleSize || 16 }

src/block/progress-bar/deprecated.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ import {
99
} from '~stackable/block-components'
1010
import { semverCompare } from '~stackable/util'
1111

12-
import striptags from 'striptags'
13-
1412
import { addFilter } from '@wordpress/hooks'
1513

16-
const addAriaLabel = ( derivedAriaValue, version ) => {
14+
const addAriaLabel = ( divProps, version ) => {
1715
if ( semverCompare( version, '<', '3.19.0' ) ) {
18-
return {}
16+
return {
17+
...divProps,
18+
'aria-label': undefined,
19+
}
1920
}
2021

21-
return {
22-
'aria-label': derivedAriaValue ? striptags( derivedAriaValue ) : undefined,
23-
}
22+
return divProps
2423
}
2524

26-
addFilter( 'stackable.progress-bar.accessibility', 'stackable/3.19.0', addAriaLabel )
25+
addFilter( 'stackable.progress-bar.div-props', 'stackable/3.19.0', addAriaLabel )
2726

2827
const deprecated = [
2928
{

src/block/progress-bar/save.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ export const Save = props => {
7070
<CustomCSS.Content attributes={ attributes } />
7171
<div className={ containerClassNames }>
7272
<div
73-
className={ divClassNames }
74-
role="progressbar"
75-
aria-valuemin="0"
76-
aria-valuemax="100"
77-
aria-valuenow={ progressValue }
78-
aria-valuetext={ derivedAriaValue ? striptags( derivedAriaValue ) : undefined }
79-
{ ...applyFilters( 'stackable.progress-bar.accessibility', derivedAriaValue, props.version ) }
73+
{ ...applyFilters( 'stackable.progress-bar.div-props', {
74+
className: divClassNames,
75+
role: 'progressbar',
76+
'aria-valuemin': '0',
77+
'aria-valuemax': '100',
78+
'aria-valuenow': progressValue,
79+
'aria-valuetext': derivedAriaValue ? striptags( derivedAriaValue ) : undefined,
80+
'aria-label': derivedAriaValue ? striptags( derivedAriaValue ) : undefined,
81+
}, props.version ) }
8082
>
8183
<div className={ barClassNames }>
8284
{ attributes.showText && (

src/block/progress-circle/deprecated.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ import {
99
} from '~stackable/block-components'
1010
import { semverCompare } from '~stackable/util'
1111

12-
import striptags from 'striptags'
13-
1412
import { addFilter } from '@wordpress/hooks'
1513

16-
const addAriaLabel = ( derivedAriaValue, version ) => {
14+
const addAriaLabel = ( divProps, version ) => {
1715
if ( semverCompare( version, '<', '3.19.0' ) ) {
18-
return {}
16+
return {
17+
...divProps,
18+
'aria-label': undefined,
19+
}
1920
}
2021

21-
return {
22-
'aria-label': derivedAriaValue ? striptags( derivedAriaValue ) : undefined,
23-
}
22+
return divProps
2423
}
2524

26-
addFilter( 'stackable.progress-circle.accessibility', 'stackable/3.19.0', addAriaLabel )
25+
addFilter( 'stackable.progress-circle.div-props', 'stackable/3.19.0', addAriaLabel )
2726

2827
const deprecated = [
2928
{

src/block/progress-circle/save.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ export const Save = props => {
6666
<CustomCSS.Content attributes={ attributes } />
6767
<div className={ containerClassNames }>
6868
<div
69-
className={ divClassNames }
70-
role="progressbar"
71-
aria-valuemin="0"
72-
aria-valuemax="100"
73-
aria-valuenow={ progressValue }
74-
aria-valuetext={ attributes.progressAriaValueText ? striptags( attributes.progressAriaValueText ) : undefined }
75-
{ ...applyFilters( 'stackable.progress-circle.accessibility', attributes.progressAriaValueText, props.version ) }
69+
{ ...applyFilters( 'stackable.progress-circle.div-props', {
70+
className: divClassNames,
71+
role: 'progressbar',
72+
'aria-valuemin': '0',
73+
'aria-valuemax': '100',
74+
'aria-valuenow': progressValue,
75+
'aria-valuetext': attributes.progressAriaValueText ? striptags( attributes.progressAriaValueText ) : undefined,
76+
'aria-label': attributes.progressAriaValueText ? striptags( attributes.progressAriaValueText ) : undefined,
77+
}, props.version ) }
7678
>
7779
<svg>
7880
{ attributes.progressColorType === 'gradient' && (

0 commit comments

Comments
 (0)