Changes to lcp button and icons

This commit is contained in:
Jeremy Rangel
2024-12-29 01:47:56 -08:00
parent d65992a169
commit 372d5aa2c1
19 changed files with 30094 additions and 33 deletions

61
assets/json/converter.php Normal file
View File

@ -0,0 +1,61 @@
<?php
// Function to generate a UUID (compliant with MySQL UUID)
function generateUUID() {
return bin2hex(random_bytes(16)); // Generate a random UUID
}
// Function to convert the raw SVG to JSON format
function convertSymbolsToJSON($svgContent) {
// Match all <symbol> elements and extract them
preg_match_all('/<symbol[^>]*>[\s\S]*?<\/symbol>/', $svgContent, $matches);
$jsonData = [];
foreach ($matches[0] as $symbol) {
// Extract 'id', 'viewBox', and 'path' attributes
preg_match('/id="([^"]+)"/', $symbol, $idMatches);
preg_match('/viewBox="([^"]+)"/', $symbol, $viewBoxMatches);
preg_match('/<path[^>]*d="([^"]+)"/', $symbol, $pathMatches);
// If we have a valid symbol, process it
if (isset($idMatches[1]) && isset($viewBoxMatches[1]) && isset($pathMatches[1])) {
// Generate a UUID for the symbol
$uniqueId = generateUUID();
// Capitalize the name by replacing hyphens with spaces and capitalizing each word
$name = ucwords(str_replace('-', ' ', $idMatches[1]));
// Build the symbol JSON object
$symbolJSON = [
"id" => $uniqueId,
"name" => $name,
"viewBox" => $viewBoxMatches[1],
"path" => "<path d='" . $pathMatches[1] . "'/>"
];
// Add the symbol JSON to the data array
$jsonData[] = $symbolJSON;
}
}
return $jsonData;
}
// Read the SVG file (assumes it's in the same directory)
$svgFilePath = 'input.svg'; // The input SVG file
if (file_exists($svgFilePath)) {
$svgContent = file_get_contents($svgFilePath);
// Convert symbols to JSON
$symbolsJson = convertSymbolsToJSON($svgContent);
// Output the JSON data to a file
$outputFilePath = 'output.json';
file_put_contents($outputFilePath, json_encode($symbolsJson, JSON_PRETTY_PRINT));
echo "JSON file has been created successfully: $outputFilePath\n";
} else {
echo "Error: SVG file not found.\n";
}
?>