Skip to content

Commit e5c2823

Browse files
authored
fix (icon list): added new option to stop override custom icon colors (#3648)
* don't override custom icon colors * add option to use custom icon color
1 parent 6c4bd62 commit e5c2823

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

src/block/icon-list-item/style.scss

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
// Apply the color to the SVG path on the defintion
21-
svg.ugb-custom-icon :is(g,path,rect,polygon,ellipse) {
21+
&:not(.stk__use-custom-icon-color) svg:where(.ugb-custom-icon) :is(g,path,rect,polygon,ellipse) {
2222
fill: var(--stk-icon-list-marker-color) !important;
2323
color: var(--stk-icon-list-marker-color) !important;
2424
}
@@ -48,17 +48,22 @@
4848
width: var(--stk-icon-height, var(--stk-icon-list-icon-size, 16px));
4949
transform: rotate(var(--stk-icon-list-icon-rotation, 0deg));
5050
opacity: var(--stk-icon-list-icon-opacity, 1);
51-
fill: var(--stk-icon-list-marker-color);
52-
color: var(--stk-icon-list-marker-color);
5351
position: relative;
5452

55-
:is(use,g,path,rect,polygon,ellipse) {
56-
fill: var(--stk-icon-list-marker-color);
57-
color: var(--stk-icon-list-marker-color);
58-
}
5953
}
6054
}
55+
}
56+
}
57+
58+
.stk-block-icon-list:not(.stk__use-custom-icon-color) .stk-block-icon-list__ul .stk-block-icon-list-item .stk-block-icon-list-item__content {
59+
.stk--inner-svg svg {
60+
fill: var(--stk-icon-list-marker-color);
61+
color: var(--stk-icon-list-marker-color);
6162

63+
:is(use,g,path,rect,polygon,ellipse) {
64+
fill: var(--stk-icon-list-marker-color);
65+
color: var(--stk-icon-list-marker-color);
66+
}
6267
}
6368
}
6469

src/block/icon-list/edit.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { dispatch, useSelect } from '@wordpress/data'
5252
import { addFilter } from '@wordpress/hooks'
5353
import { memo } from '@wordpress/element'
5454
import { useBlockLayoutDefaults } from '~stackable/hooks'
55+
import { ToggleControl } from '@wordpress/components'
5556

5657
const ALLOWED_INNER_BLOCKS = [ 'stackable/icon-list-item' ]
5758

@@ -143,6 +144,7 @@ const Edit = props => {
143144
listItemBorderColor,
144145
listDisplayStyle,
145146
listFullWidth,
147+
useCustomIconColor,
146148
} = attributes
147149

148150
const wrapList = ! listFullWidth && listDisplayStyle !== 'grid'
@@ -163,7 +165,9 @@ const Edit = props => {
163165
'stk-block-icon-list',
164166
blockAlignmentClass,
165167
textClasses,
166-
] )
168+
], {
169+
'stk__use-custom-icon-color': useCustomIconColor,
170+
} )
167171

168172
const tagNameClassNames = classnames( [
169173
ordered ? 'stk-block-icon-list__ol' : 'stk-block-icon-list__ul',
@@ -209,6 +213,7 @@ const Edit = props => {
209213
listItemBorderStyle={ listItemBorderStyle }
210214
listItemBorderColor={ listItemBorderColor }
211215
resetCustomIcons={ resetCustomIcons }
216+
useCustomIconColor={ useCustomIconColor }
212217
/>
213218

214219
{ blockCss && <style key="block-css">{ blockCss }</style> }
@@ -339,7 +344,7 @@ const InspectorControls = memo( props => {
339344
default="unordered"
340345
/>
341346

342-
{ ! props.ordered && (
347+
{ ! props.ordered && <>
343348
<IconControl
344349
label={ __( 'Icon', i18n ) }
345350
value={ props.icon }
@@ -350,7 +355,13 @@ const InspectorControls = memo( props => {
350355
} }
351356
defaultValue={ DEFAULT_SVG }
352357
/>
353-
) }
358+
359+
<ToggleControl
360+
label={ __( 'Use Custom Icon Color', i18n ) }
361+
checked={ props.useCustomIconColor }
362+
onChange={ useCustomIconColor => props.setAttributes( { useCustomIconColor } ) }
363+
/>
364+
</> }
354365

355366
{ props.ordered && (
356367
<AdvancedSelectControl

src/block/icon-list/schema.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ export const attributes = ( version = VERSION ) => {
148148
versionAdded: '3.0.0',
149149
versionDeprecated: '',
150150
} )
151+
attrObject.add( {
152+
attributes: {
153+
useCustomIconColor: {
154+
type: 'boolean',
155+
default: false,
156+
},
157+
},
158+
versionAdded: '3.14.4',
159+
versionDeprecated: '',
160+
} )
151161

152162
return attrObject.getMerged( version )
153163
}

0 commit comments

Comments
 (0)