Skip to content

Commit 3c12a0a

Browse files
committed
add option to use custom icon color
1 parent a69cecd commit 3c12a0a

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
border-width: 1px;
1717
border-color: rgba(0, 0, 0, 0.4);
1818
}
19+
20+
// Apply the color to the SVG path on the defintion
21+
&:not(.stk__use-custom-icon-color) svg:where(.ugb-custom-icon) :is(g,path,rect,polygon,ellipse) {
22+
fill: var(--stk-icon-list-marker-color) !important;
23+
color: var(--stk-icon-list-marker-color) !important;
24+
}
1925
}
2026

2127
.stk-block-icon-list-item__content {
@@ -44,19 +50,20 @@
4450
opacity: var(--stk-icon-list-icon-opacity, 1);
4551
position: relative;
4652

47-
// Do not apply the color to custom icons.
48-
&:not(.ugb-custom-icon) {
49-
fill: var(--stk-icon-list-marker-color);
50-
color: var(--stk-icon-list-marker-color);
51-
52-
:is(use,g,path,rect,polygon,ellipse) {
53-
fill: var(--stk-icon-list-marker-color);
54-
color: var(--stk-icon-list-marker-color);
55-
}
56-
}
5753
}
5854
}
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);
5962

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+
}
6067
}
6168
}
6269

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)