Skip to content

Commit

Permalink
Parse Ninja config into SVG module
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdnbrk committed Oct 5, 2024
1 parent bdf6820 commit 32a13e0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/View/Components/NinjaSvgModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function __construct(

$this->parseCssRulesToArray();

$this->parseConfigCssRulesToArray();

$this->addCssStringsToInnerSvg();

$this->removeClassAttributesFromInnerSvg();
Expand Down Expand Up @@ -147,6 +149,30 @@ protected function parseCssRulesToArray(): void
->collapse();
}

protected function parseConfigCssRulesToArray(): void
{
Collection::make($this->config)
->filter(function ($value, $key) {
return preg_match('/^ST\d+$/', $key);
})
->mapWithKeys(function ($value, $key) {
$key = Str::of($key)
->lower()
->prepend('.')
->toString();

return [
$key => $value,
];
})
->each(function ($hexColor, $class) {
$this->cssRules->put(
$class,
['fill' => $hexColor],
);
});
}

protected function removeDeprecatedCssAttributes(): void
{
$this->styleElement = Str::of($this->styleElement)
Expand Down

0 comments on commit 32a13e0

Please sign in to comment.