Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix svg icon font with class prefix and suffix #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/IconExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getIcon(string $icon, $attributes = [], string $iconSetName = 'd
'<svg%s><use xlink:href="%s#%s"></use></svg>',
$this->renderAttributes($attributes),
$iconSet['path'],
$icon
$iconSet['classPrefix'] . $icon . $iconSet['classSuffix']
);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/IconExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testSvgIcon(): void
]);

$this->assertSame(
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#icon-test"></use></svg>',
$iconExtension->getIcon('test')
);
}
Expand All @@ -127,7 +127,7 @@ public function testSvgIconAttributes(): void
]);

$this->assertSame(
'<svg role="none" class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg role="none" class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#icon-test"></use></svg>',
$iconExtension->getIcon('test', ['role' => 'none'])
);
}
Expand All @@ -147,7 +147,7 @@ public function testSvgIconDefaultAttributes(): void
);

$this->assertSame(
'<svg role="none" class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg role="none" class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#icon-test"></use></svg>',
$iconExtension->getIcon('test')
);
}
Expand All @@ -167,7 +167,7 @@ public function testSvgIconRemoveDefaultAttributes(): void
);

$this->assertSame(
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#icon-test"></use></svg>',
$iconExtension->getIcon('test', ['role' => null])
);
}
Expand All @@ -185,7 +185,7 @@ public function testSvgIconCustomSettings(): void
]);

$this->assertSame(
'<svg class="add-class my-icon my-icon-test-new"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg class="add-class my-icon my-icon-test-new"><use xlink:href="/path/to/symbol-defs.svg#my-icon-test-new"></use></svg>',
$iconExtension->getIcon('test', 'add-class', 'other')
);
}
Expand All @@ -200,7 +200,7 @@ public function testSvgIconOtherGroup(): void
]);

$this->assertSame(
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#test"></use></svg>',
'<svg class="icon icon-test"><use xlink:href="/path/to/symbol-defs.svg#icon-test"></use></svg>',
$iconExtension->getIcon('test', null, 'other')
);
}
Expand Down