/
GetLabelMarkup.php
41 lines (34 loc) · 1.39 KB
/
GetLabelMarkup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Actions\FontAwesome\v6;
use Illuminate\Http\Request;
use Lorisleiva\Actions\Concerns\AsAction;
class GetLabelMarkup
{
use AsAction;
public function handle(Request $request, int $markerSize)
{
// GET LABEL
$labelText = $request->get('label');
$labelTextSize = $markerSize / 4;
$labelColor = '#'.$request->get('lc', 'D9534F');
$labelFont = $request->get('lf', 'Arial');
$labelFontColor = '#'.$request->get('lfc', 'FFF');
// LABEL ANIMATION
$labelAnimation = $request->get('labelAnimation', null);
$labelAnimationDuration = $request->get('labelAnimationDuration', '1s');
$labelAnimationMarkup = GetLabelAnimationMarkup::run($labelAnimation, $labelAnimationDuration);
// GENERATE LABEL MARKUP
$labelMarkup = '';
if ($request->has('label')) {
$labelMarkup = <<<EOD
<!-- Icon Label -->
<svg x="60%" y="60%" width="40%" height="40%" viewbox="0 0 100 100" class="labelAnimation">
<circle cx="50%" cy="50%" fill="{$labelColor}" r="50%" />
<text x="50%" y="50%" fill="{$labelFontColor}" text-anchor="middle" dy=".33em" font-size="{$labelTextSize}" font-family="{$labelFont}">{$labelText}</text>
{$labelAnimationMarkup}
</svg>
EOD;
}
return $labelMarkup;
}
}