Skip to content

Commit

Permalink
feat(icon-picker): add icon-picker component
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Mar 1, 2021
1 parent b476e1c commit b6cea4a
Show file tree
Hide file tree
Showing 19 changed files with 2,724 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### ✨ Features

- axios 支持 form-data 格式请求
- 新增图标选择器组件
- 新增修改密码界面
- 新增部门管理示例界面

### ⚡ Performance Improvements

Expand Down
56 changes: 56 additions & 0 deletions build/gen/generateIconJson.ts
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();
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"test:gzip": "http-server dist --cors --gzip -c-1",
"test:br": "http-server dist --cors --brotli -c-1",
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap",
"postinstall": "is-ci || husky install"
"install:husky": "is-ci || husky install",
"gen:icon": "esno ./build/gen/generateIconJson.ts",
"postinstall": "npm run install:husky"
},
"dependencies": {
"@iconify/iconify": "^2.0.0-rc.6",
Expand Down Expand Up @@ -55,8 +57,9 @@
"@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.7.0",
"@types/crypto-js": "^4.0.1",
"@types/fs-extra": "^9.0.7",
"@types/fs-extra": "^9.0.8",
"@types/http-proxy": "^1.17.5",
"@types/inquirer": "^7.3.1",
"@types/lodash-es": "^4.17.4",
"@types/mockjs": "^1.0.3",
"@types/nprogress": "^0.2.0",
Expand Down Expand Up @@ -84,6 +87,7 @@
"fs-extra": "^9.1.0",
"http-server": "^0.12.3",
"husky": "^5.1.2",
"inquirer": "^8.0.0",
"is-ci": "^3.0.0",
"less": "^4.1.1",
"lint-staged": "^10.5.4",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Icon/index.ts
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;
Loading

0 comments on commit b6cea4a

Please sign in to comment.