Skip to content

Commit

Permalink
fix(NcIconSvgWrapper): Fix icon size variable being undefined
Browse files Browse the repository at this point in the history
Use CSS variable with `style` binding instead, as the `v-bind` generated an undefined CSS variable.
(Yet for the next branch, Vue 3, it seems to work).

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed May 16, 2024
1 parent a735ec0 commit ffc5e09
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/NcIconSvgWrapper/NcIconSvgWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export default {
* Icon size used in CSS
*/
iconSize() {
console.warn('foo', typeof this.size === 'number' ? `${this.size}px` : this.size, 'FF')
return typeof this.size === 'number' ? `${this.size}px` : this.size
},

Expand All @@ -206,6 +207,9 @@ export default {
attributes() {
return {
class: ['icon-vue', { 'icon-vue--inline': this.inline }],
style: {
' --icon-size': this.iconSize,
},
role: 'img',
'aria-hidden': !this.name ? true : undefined,
'aria-label': this.name || undefined,
Expand Down Expand Up @@ -233,10 +237,10 @@ export default {

&:deep(svg) {
fill: currentColor;
width: v-bind('iconSize');
height: v-bind('iconSize');
max-width: v-bind('iconSize');
max-height: v-bind('iconSize');
width: var(--icon-size, 20px);
height: var(--icon-size, 20px);
max-width: var(--icon-size, 20px);
max-height: var(--icon-size, 20px);
}
}
</style>

0 comments on commit ffc5e09

Please sign in to comment.