Skip to content

Commit fed9760

Browse files
committed
feat(font awesome 6): added svg endpoint for font-awesome-6
1 parent b9cdb2a commit fed9760

File tree

2,027 files changed

+2095
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,027 files changed

+2095
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\API\v3\FontAwesome\v6;
4+
5+
use App\Http\Controllers\Controller as Controller;
6+
use Illuminate\Http\Request;
7+
use Illuminate\Support\Str;
8+
9+
class IconController extends Controller
10+
{
11+
public function show(Request $request)
12+
{
13+
// GET ICON MARKUP
14+
try {
15+
$icon = $request->get('icon', '');
16+
$iconPieces = explode(' ', $icon, 2);
17+
$iconSet = Str::replace('fa-', '', data_get($iconPieces, 0)) ?: 'solid';
18+
$icon = Str::replace('fa-', '', data_get($iconPieces, 1)) ?: 'location-dot';
19+
$iconFilePath = "icons/font-awesome-6/{$iconSet}/{$icon}.svg";
20+
$iconMarkup = file_get_contents(resource_path($iconFilePath));
21+
} catch (\Throwable $e) {
22+
// use default icon markup
23+
$iconMarkup = file_get_contents(resource_path('icons/font-awesome-6/solid/location-dot.svg'));
24+
}
25+
26+
// GET ICON SIZE
27+
$size = $request->get('size', 100);
28+
29+
// GET ICON COLOR
30+
$color = $request->get('color', '#333');
31+
32+
// GET LABEL
33+
$labelText = $request->get('label');
34+
$labelTextSize = $size / 5;
35+
$labelColor = $request->get('labelColor', '#D9534F');
36+
$labelFont = $request->get('labelFont', 'Arial');
37+
$labelMarkup = '';
38+
if ($labelText) {
39+
$labelMarkup = <<<EOD
40+
<!--! Icon Label -->
41+
<svg x="60%" y="60%" width="40%" height="40%" viewbox="0 0 100 100">
42+
<circle cx="50%" cy="50%" fill="{$labelColor}" r="50%" />
43+
<text x="50%" y="50%" fill="#fff" text-anchor="middle" dy=".3em" font-size="{$labelTextSize}" font-family="{$labelFont}">{$labelText}</text>
44+
</svg>
45+
EOD;
46+
}
47+
48+
// COMPOSE MARKUP
49+
$mapMarkerMarkup = <<<EOD
50+
<svg fill="{$color}" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 100" width="{$size}" height="{$size}">
51+
<!--! Generated with MapMarker.io - https://mapmarker.io License - https://www.mapmarker.io/license -->
52+
{$iconMarkup} {$labelMarkup}
53+
</svg>
54+
EOD;
55+
56+
return response($mapMarkerMarkup)->header('Content-Type', 'image/svg+xml');
57+
}
58+
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)