-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from mtmacdonald/icons
Modernise icons
- Loading branch information
Showing
16 changed files
with
9,925 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { promises as fsp } from 'fs'; | ||
import path from 'path'; | ||
|
||
const iconSourcePath = 'node_modules/@tabler/icons/icons'; | ||
const iconsOutputPath = 'src/include/require/styles/icons.js'; | ||
|
||
const output = (icons) => `var w_icons = ${JSON.stringify(icons, null, 2)};`; | ||
|
||
export const buildIcons = async () => { | ||
console.log('Build icons'); | ||
try { | ||
const files = await fsp.readdir(iconSourcePath); | ||
const svgFiles = files.filter(file => path.extname(file).toLowerCase() === '.svg'); | ||
const svgContents = {}; | ||
await Promise.all( | ||
svgFiles.map(async file => { | ||
const filePath = path.join(iconSourcePath, file); | ||
const content = await fsp.readFile(filePath, 'utf8'); | ||
const key = path.basename(file, '.svg'); // Remove .svg extension from filename | ||
svgContents[key] = content; | ||
}) | ||
); | ||
await fsp.writeFile( | ||
iconsOutputPath, | ||
output(svgContents), | ||
{ encoding: 'utf8' }, | ||
); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env node | ||
|
||
import { program } from 'commander'; | ||
import { buildIcons } from './build-icons'; | ||
|
||
program | ||
.command('build-icons') | ||
.description('build the SVG icons') | ||
.action(() => { | ||
buildIcons(); | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
//if no arguments were provided, show help and then exit | ||
if (!process.argv.slice(2).length) { | ||
program.help(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.