Skip to content

Commit b78448d

Browse files
authored
fix (number box): number box gradient now applied correctly (#3387)
* fix(number-box): add a container to separate the text from the shape * fix(number-box): add deprecation code
1 parent 7c0965d commit b78448d

File tree

5 files changed

+82
-20
lines changed

5 files changed

+82
-20
lines changed

src/block/number-box/deprecated.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,58 @@ import { withVersion } from '~stackable/higher-order'
55
import {
66
deprecateBlockBackgroundColorOpacity, deprecateTypographyGradientColor, deprecationBackgrounColorOpacity,
77
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor,
8+
BlockDiv, CustomCSS, Typography,
9+
getResponsiveClasses, getTypographyClasses, getAlignmentClasses,
810
} from '~stackable/block-components'
11+
import classnames from 'classnames'
12+
13+
const depecatedSave_3_13_11 = props => {
14+
const {
15+
className,
16+
attributes,
17+
} = props
18+
19+
const responsiveClass = getResponsiveClasses( props.attributes )
20+
const textClasses = getTypographyClasses( props.attributes )
21+
const blockAlignmentClass = getAlignmentClasses( props.attributes )
22+
23+
const blockClassNames = classnames( [
24+
className,
25+
'stk-block-number-box',
26+
responsiveClass,
27+
blockAlignmentClass,
28+
], {
29+
'stk--has-shape': attributes.hasShape,
30+
} )
31+
32+
const textClassNames = classnames( [
33+
'stk-block-number-box__text',
34+
textClasses,
35+
] )
36+
37+
return (
38+
<BlockDiv.Content
39+
className={ blockClassNames }
40+
attributes={ attributes }
41+
version={ props.version }
42+
>
43+
{ attributes.generatedCss && <style>{ attributes.generatedCss }</style> }
44+
<CustomCSS.Content attributes={ attributes } />
45+
<Typography.Content
46+
tagName="div"
47+
attributes={ attributes }
48+
className={ textClassNames }
49+
role="presentation"
50+
/>
51+
</BlockDiv.Content>
52+
)
53+
}
954

1055
const deprecated = [
56+
{
57+
attributes: attributes( '3.13.11' ),
58+
save: depecatedSave_3_13_11,
59+
},
1160
{
1261
// Support the new shadow color.
1362
attributes: attributes( '3.12.11' ),

src/block/number-box/edit.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ const Edit = props => {
5555
const blockClassNames = classnames( [
5656
className,
5757
'stk-block-number-box',
58-
blockAlignmentClass,
5958
], {
6059
'stk--has-shape': props.attributes.hasShape,
6160
} )
6261

62+
const containerClassNames = classnames( [
63+
'stk-block-number-box__container',
64+
blockAlignmentClass,
65+
] )
66+
6367
const textClassNames = classnames( [
6468
'stk-block-number-box__text',
6569
textClasses,
@@ -78,7 +82,6 @@ const Edit = props => {
7882

7983
return (
8084
<>
81-
8285
<InspectorControls
8386
setAttributes={ setAttributes }
8487
blockState={ props.blockState }
@@ -94,11 +97,13 @@ const Edit = props => {
9497
attributes={ props.attributes }
9598
className={ blockClassNames }
9699
>
97-
<Typography
98-
tagName="div"
99-
placeholder="1"
100-
className={ textClassNames }
101-
/>
100+
<div className={ containerClassNames }>
101+
<Typography
102+
tagName="span"
103+
placeholder="1"
104+
className={ textClassNames }
105+
/>
106+
</div>
102107
</BlockDiv>
103108
{ props.isHovered && <MarginBottom /> }
104109
</>

src/block/number-box/save.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ export const Save = props => {
2929
className,
3030
'stk-block-number-box',
3131
responsiveClass,
32-
blockAlignmentClass,
3332
], {
3433
'stk--has-shape': attributes.hasShape,
3534
} )
3635

36+
const containerClassNames = classnames( [
37+
'stk-block-number-box__container',
38+
blockAlignmentClass,
39+
] )
40+
3741
const textClassNames = classnames( [
3842
'stk-block-number-box__text',
3943
textClasses,
@@ -47,12 +51,14 @@ export const Save = props => {
4751
>
4852
{ attributes.generatedCss && <style>{ attributes.generatedCss }</style> }
4953
<CustomCSS.Content attributes={ attributes } />
50-
<Typography.Content
51-
tagName="div"
52-
attributes={ attributes }
53-
className={ textClassNames }
54-
role="presentation"
55-
/>
54+
<div className={ containerClassNames }>
55+
<Typography.Content
56+
tagName="span"
57+
attributes={ attributes }
58+
className={ textClassNames }
59+
role="presentation"
60+
/>
61+
</div>
5662
</BlockDiv.Content>
5763
)
5864
}

src/block/number-box/style.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const blockStyles = new BlockStyleGenerator( {
1919
} )
2020

2121
blockStyles.addBlockStyles( 'shapeSize', [ {
22-
selector: '.stk-block-number-box__text',
22+
selector: '.stk-block-number-box__container',
2323
styleRule: 'height',
2424
attrName: 'shapeSize',
2525
key: 'shapeSize',
@@ -28,7 +28,7 @@ blockStyles.addBlockStyles( 'shapeSize', [ {
2828
enabledCallback: getAttribute => getAttribute( 'hasShape' ),
2929
dependencies: [ 'hasShape' ],
3030
}, {
31-
selector: '.stk-block-number-box__text',
31+
selector: '.stk-block-number-box__container',
3232
styleRule: 'width',
3333
attrName: 'shapeSize',
3434
key: 'shapeSize-width',
@@ -40,12 +40,12 @@ blockStyles.addBlockStyles( 'shapeSize', [ {
4040

4141
addBackgroundStyles( blockStyles, {
4242
attrNameTemplate: 'shape%s',
43-
selector: '.stk-block-number-box__text',
43+
selector: '.stk-block-number-box__container',
4444
renderCondition: 'hasShape',
4545
} )
4646
addBorderStyles( blockStyles, {
4747
attrNameTemplate: 'shape%s',
48-
selector: '.stk-block-number-box__text',
48+
selector: '.stk-block-number-box__container',
4949
renderCondition: 'hasShape',
5050
} )
5151
Alignment.addStyles( blockStyles )

src/block/number-box/style.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "common";
22

3-
.stk-block-number-box__text {
3+
.stk-block-number-box__container,
4+
div.stk-block-number-box__text {
45
display: inline-flex;
56
justify-content: center;
67
align-items: center;
@@ -9,7 +10,8 @@
910
flex: 0 1 auto;
1011
}
1112
.stk-block-number-box.stk--has-shape {
12-
.stk-block-number-box__text {
13+
.stk-block-number-box__container,
14+
div.stk-block-number-box__text {
1315
background: cssvar(button-background-color);
1416
color: #fff;
1517
border-radius: 100%;

0 commit comments

Comments
 (0)