-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icon-picker): add icon-picker component
- Loading branch information
Showing
19 changed files
with
2,724 additions
and
38 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,56 @@ | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import inquirer from 'inquirer'; | ||
import chalk from 'chalk'; | ||
import pkg from '../../package.json'; | ||
|
||
async function generateIcon() { | ||
const dir = path.resolve(process.cwd(), 'node_modules/@iconify/json'); | ||
|
||
const raw = await fs.readJSON(path.join(dir, 'collections.json')); | ||
|
||
const collections = Object.entries(raw).map(([id, v]) => ({ | ||
...(v as any), | ||
id, | ||
})); | ||
|
||
const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name })); | ||
|
||
inquirer | ||
.prompt([ | ||
{ | ||
type: 'checkbox', | ||
name: 'iconSet', | ||
choices: choices, | ||
message: 'Select the icon set that needs to be generated?', | ||
default: true, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'output', | ||
message: 'Select the icon set that needs to be generated?', | ||
default: 'src/components/Icon/json', | ||
}, | ||
]) | ||
.then(async (answers) => { | ||
const { iconSet, output } = answers; | ||
const outputDir = path.resolve(process.cwd(), output); | ||
fs.ensureDir(outputDir); | ||
const genCollections = collections.filter((item) => iconSet.includes(item.id)); | ||
const prefixSet: string[] = []; | ||
for (const info of genCollections) { | ||
const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`)); | ||
if (data) { | ||
const { prefix } = data; | ||
const icons = Object.keys(data.icons).map((item) => `${prefix}:${item}`); | ||
await fs.writeJSON(path.join(output, `${prefix}-info.json`), icons); | ||
prefixSet.push(prefix); | ||
} | ||
} | ||
console.log( | ||
`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]` | ||
); | ||
}); | ||
} | ||
|
||
generateIcon(); |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import Icon from './src/index.vue'; | ||
import IconPicker from './src/IconPicker.vue'; | ||
|
||
export { Icon, IconPicker }; | ||
|
||
export { Icon }; | ||
export default Icon; |
Oops, something went wrong.