Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add build icon and illustration
- Loading branch information
1 parent
6f0c8fd
commit 738d97e
Showing
14 changed files
with
421 additions
and
28 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
packages/svgs/assets/illustrations/office/IllusOffice.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,71 @@ | ||
const globby = require('globby') | ||
const fse = require('fs-extra') | ||
const config = require('./config.js').icon | ||
const chalk = require('chalk') | ||
|
||
const generateVue = ({ svg, filename }) => ` | ||
<template> | ||
${svg} | ||
</template> | ||
<script> | ||
export default { | ||
name: '${filename}', | ||
props: { | ||
size: { | ||
type: [String, Number], | ||
default: 24, | ||
}, | ||
width: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
height: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
color: { | ||
type: String, | ||
default: '#A4A4A4', | ||
}, | ||
}, | ||
} | ||
</script> | ||
` | ||
|
||
console.log(chalk.black.bgGreen.bold('Generate Icon')) | ||
|
||
globby([config.input]).then(icon => { | ||
try { | ||
icon.forEach(v => { | ||
let filename = v.match(/([^\/]+)(?=\.\w+$)/)[0] | ||
const svgString = fse.readFileSync(v).toString() | ||
const svgReplaceWidth = svgString.replace( | ||
/(width)=\".*?\"/, | ||
':width="width || size"' | ||
) | ||
const svgReplaceHeight = svgReplaceWidth.replace( | ||
/(height)=\".*?\"/, | ||
':height="height || size"' | ||
) | ||
const svgReplaceFill = svgReplaceHeight.replace( | ||
/(fill)=\".*?\"/, | ||
':fill="color"' | ||
) | ||
|
||
const svgVueFile = generateVue({ filename, svg: svgReplaceFill }) | ||
fse | ||
.outputFile(`${config.output}/${filename}.vue`, svgVueFile) | ||
.then(() => { | ||
console.log(` ${chalk.green('√')} ${filename}`) | ||
}) | ||
.catch(error => { | ||
console.log(` ${chalk.red('X')} ${filename}`) | ||
console.log(error) | ||
}) | ||
}) | ||
} catch (error) { | ||
console.log(` ${chalk.red('X')} failed`) | ||
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,59 @@ | ||
const globby = require('globby') | ||
const fse = require('fs-extra') | ||
const config = require('./config.js').illustration | ||
const chalk = require('chalk') | ||
|
||
const generateVue = ({ svg, filename }) => ` | ||
<template> | ||
<img | ||
:alt="$options.name" | ||
:width="width || size || null" | ||
:height="height || size || null" | ||
src="@/${svg}" | ||
/> | ||
</template> | ||
<script> | ||
export default { | ||
name: '${filename}', | ||
props: { | ||
size: { | ||
type: [String, Number], | ||
default: 128, | ||
}, | ||
width: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
height: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
}, | ||
} | ||
</script> | ||
` | ||
console.log(chalk.black.bgGreen.bold('Generate Illustration')) | ||
|
||
globby([config.input]).then(icon => { | ||
try { | ||
icon.forEach(v => { | ||
let filename = v.match(/([^\/]+)(?=\.\w+$)/)[0] | ||
const svgVueFile = generateVue({ filename, svg: v }) | ||
const outputPath = v.match('assets/illustrations(.*).svg')[1] | ||
|
||
fse | ||
.outputFile(`${config.output}${outputPath}.vue`, svgVueFile) | ||
.then(() => { | ||
console.log(` ${chalk.green('√')} ${filename}`) | ||
}) | ||
.catch((error) => { | ||
console.log(` ${chalk.red('X')} ${filename}`) | ||
console.log(error) | ||
}) | ||
}) | ||
} catch (error) { | ||
console.log(` ${chalk.red('X')} Failed`) | ||
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,13 @@ | ||
const path = require('path') | ||
module.exports = { | ||
icon: { | ||
input: 'assets/icons/**/*.svg', | ||
output: path.resolve(__dirname, '../components/icons'), | ||
optimize: true, | ||
}, | ||
illustration: { | ||
input: 'assets/illustrations/**/*.svg', | ||
output: path.resolve(__dirname, '../components/illustrations'), | ||
optimize: true, | ||
}, | ||
} |
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,2 @@ | ||
export { default as IconBell } from './icons/IconBell.vue' | ||
export { default as IconClock } from './icons/IconClock.vue' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as IllusInvoice } from './illustrations/IllusInvoice.vue' | ||
export { default as illusOffice } from './illustrations/office/IllusOffice.vue' |
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
28 changes: 28 additions & 0 deletions
28
packages/svgs/components/illustrations/office/IllusOffice.vue
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,28 @@ | ||
<template> | ||
<img | ||
:alt="$options.name" | ||
:width="width || size || null" | ||
:height="height || size || null" | ||
src="@/assets/illustrations/office/IllusOffice.svg" | ||
/> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'IllusOffice', | ||
props: { | ||
size: { | ||
type: [String, Number], | ||
default: 128, | ||
}, | ||
width: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
height: { | ||
type: [String, Number], | ||
default: '', | ||
}, | ||
}, | ||
} | ||
</script> |
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,6 +1,2 @@ | ||
// Icon | ||
export { default as IconBell } from './components/icon/IconBell.vue' | ||
export { default as IconClock } from './components/icon/IconClock.vue' | ||
|
||
// Illustration | ||
export { default as IllusInvoice } from './components/illustration/IllusInvoice.vue' | ||
export * from './components/icons' | ||
export * from './components/illustrations' |
Oops, something went wrong.