PWA-implementation
This commit is contained in:
86
create_pwa_icons.ps1
Normal file
86
create_pwa_icons.ps1
Normal file
@@ -0,0 +1,86 @@
|
||||
# PowerShell script to generate PWA icons
|
||||
# Creates PNG icons for LittleShop Admin PWA
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
function Create-Icon {
|
||||
param(
|
||||
[int]$Size,
|
||||
[string]$OutputPath
|
||||
)
|
||||
|
||||
# Create bitmap
|
||||
$bitmap = New-Object System.Drawing.Bitmap($Size, $Size)
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||
$graphics.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::AntiAlias
|
||||
|
||||
# Create gradient brush
|
||||
$startColor = [System.Drawing.Color]::FromArgb(37, 99, 235) # #2563eb
|
||||
$endColor = [System.Drawing.Color]::FromArgb(124, 58, 237) # #7c3aed
|
||||
$gradientBrush = New-Object System.Drawing.Drawing2D.LinearGradientBrush(
|
||||
[System.Drawing.Point]::new(0, 0),
|
||||
[System.Drawing.Point]::new($Size, $Size),
|
||||
$startColor,
|
||||
$endColor
|
||||
)
|
||||
|
||||
# Draw rounded rectangle background
|
||||
$cornerRadius = [int]($Size * 0.15)
|
||||
$rect = New-Object System.Drawing.Rectangle(0, 0, $Size, $Size)
|
||||
|
||||
# Create rounded rectangle path
|
||||
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||
$path.AddArc(0, 0, $cornerRadius * 2, $cornerRadius * 2, 180, 90)
|
||||
$path.AddArc($Size - $cornerRadius * 2, 0, $cornerRadius * 2, $cornerRadius * 2, 270, 90)
|
||||
$path.AddArc($Size - $cornerRadius * 2, $Size - $cornerRadius * 2, $cornerRadius * 2, $cornerRadius * 2, 0, 90)
|
||||
$path.AddArc(0, $Size - $cornerRadius * 2, $cornerRadius * 2, $cornerRadius * 2, 90, 90)
|
||||
$path.CloseFigure()
|
||||
|
||||
# Fill background
|
||||
$graphics.FillPath($gradientBrush, $path)
|
||||
|
||||
# Draw text "LS"
|
||||
$font = New-Object System.Drawing.Font("Segoe UI", ($Size * 0.3), [System.Drawing.FontStyle]::Bold)
|
||||
$brush = New-Object System.Drawing.SolidBrush([System.Drawing.Color]::White)
|
||||
$format = New-Object System.Drawing.StringFormat
|
||||
$format.Alignment = [System.Drawing.StringAlignment]::Center
|
||||
$format.LineAlignment = [System.Drawing.StringAlignment]::Center
|
||||
|
||||
$textRect = New-Object System.Drawing.RectangleF(0, 0, $Size, $Size)
|
||||
$graphics.DrawString("LS", $font, $brush, $textRect, $format)
|
||||
|
||||
# Save image
|
||||
$bitmap.Save($OutputPath, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
|
||||
# Cleanup
|
||||
$graphics.Dispose()
|
||||
$bitmap.Dispose()
|
||||
$gradientBrush.Dispose()
|
||||
$font.Dispose()
|
||||
$brush.Dispose()
|
||||
$path.Dispose()
|
||||
|
||||
Write-Host "Created icon: $OutputPath ($Size x $Size)"
|
||||
}
|
||||
|
||||
# Create icons directory
|
||||
$iconsDir = "C:\Production\Source\LittleShop\LittleShop\wwwroot\icons"
|
||||
if (!(Test-Path $iconsDir)) {
|
||||
New-Item -ItemType Directory -Path $iconsDir -Force
|
||||
}
|
||||
|
||||
# Generate all required icon sizes
|
||||
$sizes = @(72, 96, 128, 144, 152, 192, 384, 512)
|
||||
|
||||
foreach ($size in $sizes) {
|
||||
$outputPath = Join-Path $iconsDir "icon-${size}x${size}.png"
|
||||
Create-Icon -Size $size -OutputPath $outputPath
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "🎉 All PWA icons created successfully!"
|
||||
Write-Host "Icons saved to: $iconsDir"
|
||||
Write-Host ""
|
||||
Write-Host "Generated icons:"
|
||||
Get-ChildItem $iconsDir -Name "icon-*.png" | ForEach-Object { Write-Host " ✅ $_" }
|
||||
Reference in New Issue
Block a user