Add shape prefix to symbol IDs, fix brand naming, add assets
- Symbol IDs now include shape for uniqueness: {shape}_{brand}_{mode}
e.g., text-only_paypal_lm, rectangle_visa_la, icon_mastercard_dm
- Fixed brand name inconsistencies:
- amazon_pay → amazon
- naverpay → naver_pay
- p24 → przelewy24
- direct_debit → bacs (unified BACS Direct Debit name)
- Added font assets (FontAwesome, Material Icons)
- Added MprIconsAssets and MprIconsConfig classes
- Updated preview.html with shape parameter support
- All 752 icons complete (38 payment × 4 shapes × 4 modes + 12 social × 3 shapes × 4 modes)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,7 +109,7 @@ function processIcon(string $content, string $iconId): array
|
||||
/**
|
||||
* Build a sprite from a directory of SVG files
|
||||
*/
|
||||
function buildSprite(string $sourceDir, string $outputFile, string $modeSuffix): void
|
||||
function buildSprite(string $sourceDir, string $outputFile, string $modeSuffix, string $shape): void
|
||||
{
|
||||
if (!is_dir($sourceDir)) {
|
||||
echo " Skipping: $sourceDir (not found)\n";
|
||||
@@ -128,6 +128,9 @@ function buildSprite(string $sourceDir, string $outputFile, string $modeSuffix):
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = strtolower(basename($file, '.svg'));
|
||||
// Symbol ID includes shape for uniqueness: {shape}_{brand}_{mode}
|
||||
// e.g., text-only_paypal_lm, rectangle_visa_la, icon_mastercard_dm
|
||||
$symbolId = $shape . '_' . $filename;
|
||||
$content = file_get_contents($file);
|
||||
|
||||
// Extract viewBox from original SVG
|
||||
@@ -135,7 +138,7 @@ function buildSprite(string $sourceDir, string $outputFile, string $modeSuffix):
|
||||
$viewBox = $viewBoxMatch[1] ?? '0 0 45 45';
|
||||
|
||||
// Process the icon (convert styles, prefix IDs, extract defs)
|
||||
$result = processIcon($content, $filename);
|
||||
$result = processIcon($content, $symbolId);
|
||||
|
||||
if (empty($result['content'])) {
|
||||
echo " Warning: Could not parse $filename\n";
|
||||
@@ -152,7 +155,7 @@ function buildSprite(string $sourceDir, string $outputFile, string $modeSuffix):
|
||||
$internalSymbols .= $result['symbols'];
|
||||
}
|
||||
|
||||
$symbols[] = " <symbol id=\"$filename\" viewBox=\"$viewBox\">{$result['content']}</symbol>";
|
||||
$symbols[] = " <symbol id=\"$symbolId\" viewBox=\"$viewBox\">{$result['content']}</symbol>";
|
||||
}
|
||||
|
||||
if (empty($symbols)) {
|
||||
@@ -180,7 +183,7 @@ foreach ($paymentShapes as $shape) {
|
||||
foreach ($modes as $modeDir => $modeSuffix) {
|
||||
$sourceDir = "$materialsDir/payment-icons/$shape/$modeDir";
|
||||
$outputFile = "$outputDir/payments/$shape-$modeSuffix.svg";
|
||||
buildSprite($sourceDir, $outputFile, $modeSuffix);
|
||||
buildSprite($sourceDir, $outputFile, $modeSuffix, $shape);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +193,7 @@ foreach ($socialShapes as $shape) {
|
||||
foreach ($modes as $modeDir => $modeSuffix) {
|
||||
$sourceDir = "$materialsDir/socials-icons/$shape/$modeDir";
|
||||
$outputFile = "$outputDir/socials/$shape-$modeSuffix.svg";
|
||||
buildSprite($sourceDir, $outputFile, $modeSuffix);
|
||||
buildSprite($sourceDir, $outputFile, $modeSuffix, $shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user