Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ docker/lnd/

#Build
android/app/release/

# Optimized SVGs
src/assets/svgs/optimized/
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"files": {
"ignore": ["src/polyfills/**"]
"ignore": ["src/polyfills/**", "src/assets/icons/index.ts"]
},
"linter": {
"rules": {
Expand Down
80 changes: 80 additions & 0 deletions scripts/optimize-svgs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

// Directory constants
const DIRS = {
RAW_SVGS: path.join(__dirname, '../src/assets/svgs/raw'),
OPTIMIZED_SVGS: path.join(__dirname, '../src/assets/svgs/optimized'),
INDEX: path.join(__dirname, '../src/assets/icons/index.ts'),
};

/**
* Clean and recreate the optimized SVGs directory
*/
function setupDirectories() {
if (fs.existsSync(DIRS.OPTIMIZED_SVGS)) {
fs.rmSync(DIRS.OPTIMIZED_SVGS, { recursive: true, force: true });
}
fs.mkdirSync(DIRS.OPTIMIZED_SVGS, { recursive: true });
}

/**
* Optimize SVGs using SVGO
*/
function optimizeSvgs() {
console.log('\nOptimizing SVGs with SVGO...');
try {
execSync(`npx svgo -rf "${DIRS.RAW_SVGS}" -o "${DIRS.OPTIMIZED_SVGS}"`, {
stdio: 'inherit',
});
console.log('\nSVG optimization completed successfully!');
} catch (error) {
throw new Error(`SVGO optimization failed: ${error.message}`);
}
}

/**
* Generate the icons/index.ts file with optimized SVGs
*/
function generateIndexFile() {
console.log('\nGenerating index.ts...');
const optimizedSvgs = fs
.readdirSync(DIRS.OPTIMIZED_SVGS)
.filter((file) => file.endsWith('.svg'));

const indexContent = `/**
* This file is auto-generated. Do not edit it manually.
* Run \`node scripts/optimize-svgs.js\` to regenerate.
*/

${optimizedSvgs
.map((file) => {
const name = path.basename(file, '.svg');
const svgContent = fs.readFileSync(
path.join(DIRS.OPTIMIZED_SVGS, file),
'utf8',
);
return `export const ${name}Icon = (color = 'white'): string => \`\n${svgContent}\`;`;
})
.join('\n\n')}\n`;

fs.writeFileSync(DIRS.INDEX, indexContent);
console.log(`Generated index.ts with ${optimizedSvgs.length} icons!`);
}

function main() {
try {
// Setup directories
setupDirectories();

// Optimize and generate index
optimizeSvgs();
generateIndexFile();
} catch (error) {
console.error('\nError:', error.message);
process.exit(1);
}
}

main();
313 changes: 313 additions & 0 deletions src/assets/icons/index.ts

Large diffs are not rendered by default.

274 changes: 0 additions & 274 deletions src/assets/icons/settings.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/assets/icons/tabs.ts

This file was deleted.

530 changes: 0 additions & 530 deletions src/assets/icons/wallet.ts

This file was deleted.

60 changes: 0 additions & 60 deletions src/assets/icons/widgets.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/assets/svgs/raw/about.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading