Skip to content

Commit b6b6401

Browse files
committed
update hugeicons
1 parent 94999c6 commit b6b6401

File tree

137 files changed

+1381
-10567
lines changed

Some content is hidden

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

137 files changed

+1381
-10567
lines changed

convertIcons.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { exec } from 'child_process'
2+
import { readdirSync } from 'fs'
3+
import { join } from 'path'
4+
import { promisify } from 'util'
5+
6+
const execAsync = promisify(exec)
7+
8+
// Converts 'Add01Icon' to 'add-01'
9+
function toHugeiconsFormat(filename: string): string {
10+
// Remove 'Icon' suffix
11+
let name = filename.replace(/Icon$/, '')
12+
// Insert hyphens before uppercase letters (except first), then lowercase
13+
name = name.replace(/([a-z])([A-Z])/g, '$1-$2')
14+
// Insert hyphens before numbers
15+
name = name.replace(/([a-zA-Z])(\d+)/g, '$1-$2')
16+
// Insert hyphen before uppercase after number (e.g., 15Sec -> 15-Sec)
17+
name = name.replace(/(\d+)([A-Z][a-z]+)/g, '$1-$2')
18+
name = name.toLowerCase()
19+
return name
20+
}
21+
22+
async function runIconCommand(iconName: string): Promise<{ success: boolean; iconName: string; error?: string }> {
23+
try {
24+
await execAsync(`ic ${iconName}`)
25+
console.log(`✅ Successfully processed: ${iconName}`)
26+
return { success: true, iconName }
27+
} catch (error) {
28+
const errorMessage = error instanceof Error ? error.message : String(error)
29+
console.error(`❌ Failed to process: ${iconName} - ${errorMessage}`)
30+
return { success: false, iconName, error: errorMessage }
31+
}
32+
}
33+
34+
async function processIconsInBatches(iconNames: string[], batchSize = 20): Promise<string[]> {
35+
const failed: string[] = []
36+
37+
for (let i = 0; i < iconNames.length; i += batchSize) {
38+
const batch = iconNames.slice(i, i + batchSize)
39+
console.log(`\nProcessing batch ${Math.floor(i / batchSize) + 1}/${Math.ceil(iconNames.length / batchSize)}`)
40+
41+
const promises = batch.map((iconName) => runIconCommand(iconName))
42+
const results = await Promise.all(promises)
43+
44+
results.forEach((result) => {
45+
if (!result.success) {
46+
failed.push(result.iconName)
47+
}
48+
})
49+
50+
// Small delay between batches to avoid overwhelming the system
51+
if (i + batchSize < iconNames.length) {
52+
await new Promise((resolve) => setTimeout(resolve, 500))
53+
}
54+
}
55+
56+
return failed
57+
}
58+
59+
async function retryFailedIcons(failedIcons: string[], maxRetries = 2): Promise<void> {
60+
let currentFailed = failedIcons
61+
62+
for (let retry = 1; retry <= maxRetries && currentFailed.length > 0; retry++) {
63+
console.log(`\n🔄 Retry attempt ${retry}/${maxRetries} for ${currentFailed.length} failed icons`)
64+
currentFailed = await processIconsInBatches(currentFailed, 3) // Smaller batch size for retries
65+
}
66+
67+
if (currentFailed.length > 0) {
68+
console.log(`\n❌ Final failed icons after ${maxRetries} retries:`)
69+
currentFailed.forEach((icon) => console.log(` - ${icon}`))
70+
} else {
71+
console.log(`\n🎉 All icons processed successfully after ${maxRetries} retries!`)
72+
}
73+
}
74+
75+
async function main() {
76+
const iconsDir = join(process.cwd(), 'src', 'assets', 'icons', 'hugeicons')
77+
const files = readdirSync(iconsDir)
78+
79+
const iconNames: string[] = []
80+
81+
files.forEach((file) => {
82+
const match = file.match(/^(.+?)Icon\.(svg|tsx|js|ts)$/)
83+
if (match) {
84+
const iconName = toHugeiconsFormat(match[1] + 'Icon')
85+
iconNames.push(iconName)
86+
}
87+
})
88+
89+
console.log(`Found ${iconNames.length} icons to process`)
90+
91+
const failedIcons = await processIconsInBatches(iconNames)
92+
93+
if (failedIcons.length > 0) {
94+
await retryFailedIcons(failedIcons)
95+
} else {
96+
console.log('\n🎉 All icons processed successfully!')
97+
}
98+
}
99+
100+
main().catch(console.error)

hugeicons.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"targetPlatform": "react-native"
2+
"targetPlatform": "react-native",
3+
"variants" : ["solid-rounded", "stroke-rounded"]
34
}
Lines changed: 10 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,30 @@
11

22
import React from 'react'
3-
import Svg, { Path } from 'react-native-svg'
4-
import { HugeIconProps, Variant, defaultColor, defaultSize, defaultStrokeWidth, defaultVariant } from './constants'
3+
import Svg, { Circle, ClipPath, Defs, Ellipse, G, Line, LinearGradient, Mask, Path, Polygon, Polyline, RadialGradient, Rect, Stop } from 'react-native-svg'
4+
import { Variant, HugeIconProps, defaultStrokeWidth, defaultVariant, defaultColor, defaultSize } from './constants'
55

6-
const iconMap: Record<Variant, React.FC<HugeIconProps>> = {
7-
'stroke-rounded': StrokeRounded,
8-
'stroke-standard': StrokeStandard,
9-
'solid-standard': SolidStandard,
10-
'duotone-rounded': DuotoneRounded,
11-
'twotone-rounded': TwotoneRounded,
6+
const iconMap: Partial<Record<Variant, React.FC<HugeIconProps>>> = {
127
'solid-rounded': SolidRounded,
13-
'bulk-rounded': BulkRounded,
14-
'stroke-sharp': StrokeSharp,
15-
'solid-sharp': SolidSharp,
8+
'stroke-rounded': StrokeRounded,
169
}
1710

1811
export default function Add01Icon({ variant, ...rest }: HugeIconProps) {
19-
const Component = iconMap[variant || defaultVariant]
12+
const selectedVariant = variant || defaultVariant
13+
const Component = iconMap[selectedVariant] || iconMap[defaultVariant] || StrokeRounded
2014
return <Component {...rest} />
2115
}
2216

23-
function StrokeRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
24-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
25-
<Path d="M12 4V20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
26-
<Path d="M4 12H20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
27-
</Svg>
28-
)
29-
}
30-
31-
function StrokeStandard({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
32-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
33-
<Path d="M12 4V20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
34-
<Path d="M4 12H20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
35-
</Svg>
36-
)
37-
}
38-
39-
function SolidStandard({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
40-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
41-
<Path fillRule="evenodd" clipRule="evenodd" d="M12 2.75C12.6904 2.75 13.25 3.30964 13.25 4V20C13.25 20.6904 12.6904 21.25 12 21.25C11.3096 21.25 10.75 20.6904 10.75 20V4C10.75 3.30964 11.3096 2.75 12 2.75Z" fill={color}/>
42-
<Path fillRule="evenodd" clipRule="evenodd" d="M2.75 12C2.75 11.3096 3.30964 10.75 4 10.75H20C20.6904 10.75 21.25 11.3096 21.25 12C21.25 12.6904 20.6904 13.25 20 13.25H4C3.30964 13.25 2.75 12.6904 2.75 12Z" fill={color}/>
43-
</Svg>
44-
)
45-
}
46-
47-
function DuotoneRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
48-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
49-
<Path opacity="0.4" d="M12 4V20M4 12H20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
50-
</Svg>
51-
)
52-
}
53-
54-
function TwotoneRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
55-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
56-
<Path d="M12 4V20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
57-
<Path opacity="0.4" d="M4 12H20" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
58-
</Svg>
59-
)
60-
}
61-
6217
function SolidRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
6318
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
64-
<Path fillRule="evenodd" clipRule="evenodd" d="M12 2.75C12.6904 2.75 13.25 3.30964 13.25 4V20C13.25 20.6904 12.6904 21.25 12 21.25C11.3096 21.25 10.75 20.6904 10.75 20V4C10.75 3.30964 11.3096 2.75 12 2.75Z" fill={color}/>
65-
<Path fillRule="evenodd" clipRule="evenodd" d="M2.75 12C2.75 11.3096 3.30964 10.75 4 10.75H20C20.6904 10.75 21.25 11.3096 21.25 12C21.25 12.6904 20.6904 13.25 20 13.25H4C3.30964 13.25 2.75 12.6904 2.75 12Z" fill={color}/>
19+
<Path d="M11.001 19.002V13.002H5C4.44772 13.002 4 12.5543 4 12.002C4 11.4498 4.44772 11.002 5 11.002H11.001V5.00009C11.001 4.44781 11.4487 4.00009 12.001 4.00009C12.5533 4.0001 13.001 4.44781 13.001 5.00009V11.002H19.002L19.1045 11.0069C19.6086 11.0583 20.002 11.4844 20.002 12.002C20.002 12.5197 19.6086 12.9458 19.1045 12.9972L19.002 13.002H13.001V19.002C13.001 19.5543 12.5533 20.002 12.001 20.002C11.4487 20.002 11.001 19.5543 11.001 19.002Z" fill={color}/>
6620
</Svg>
6721
)
6822
}
6923

70-
function BulkRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
71-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
72-
<Path fillRule="evenodd" clipRule="evenodd" d="M12 2.75C12.6904 2.75 13.25 3.30964 13.25 4V20C13.25 20.6904 12.6904 21.25 12 21.25C11.3096 21.25 10.75 20.6904 10.75 20V4C10.75 3.30964 11.3096 2.75 12 2.75Z" fill={color}/>
73-
<Path opacity="0.4" fillRule="evenodd" clipRule="evenodd" d="M2.75 12C2.75 11.3096 3.30964 10.75 4 10.75H20C20.6904 10.75 21.25 11.3096 21.25 12C21.25 12.6904 20.6904 13.25 20 13.25H4C3.30964 13.25 2.75 12.6904 2.75 12Z" fill={color}/>
74-
</Svg>
75-
)
76-
}
77-
78-
function StrokeSharp({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
79-
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
80-
<Path d="M12 4V20" stroke={color} strokeWidth={strokeWidth} strokeLinejoin="round"/>
81-
<Path d="M4 12H20" stroke={color} strokeWidth={strokeWidth} strokeLinejoin="round"/>
82-
</Svg>
83-
)
84-
}
85-
86-
function SolidSharp({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
24+
function StrokeRounded({ size = defaultSize, color = defaultColor, strokeWidth = defaultStrokeWidth, className, style }: HugeIconProps) {
8725
return (<Svg className={className} style={style} width={size} height={size} viewBox="0 0 24 24" fill="none">
88-
<Path d="M10.75 13.25V20H13.25V13.25H20V10.75H13.25V4H10.75V10.75H4V13.25H10.75Z" fill={color}/>
26+
<Path d="M12.001 5.00003V19.002" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
27+
<Path d="M19.002 12.002L4.99998 12.002" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round"/>
8928
</Svg>
9029
)
9130
}

0 commit comments

Comments
 (0)