Add vue 3 package (#293)
* init vue next package * Refactor naming * adjust readme * add typescript support * Fix es module build * Bump alpha version * Fix size property not working * Fix issue with default attributes in this PR * small fixes * Update README.md * Fix peer dep * Add return * update release workflow Co-authored-by: AdamSGit <adamelio@protonmail.com>
This commit is contained in:
37
packages/lucide-vue-next/scripts/buildTypes.js
Normal file
37
packages/lucide-vue-next/scripts/buildTypes.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import path from 'path';
|
||||
|
||||
import { readSvgDirectory, resetFile, appendFile, toPascalCase } from '../../../scripts/helpers';
|
||||
import defaultAttributes from '../src/defaultAttributes';
|
||||
|
||||
const TARGET_DIR = path.join(__dirname, '../dist');
|
||||
const ICONS_DIR = path.resolve(__dirname, '../../../icons');
|
||||
const TYPES_FILE_NAME = 'lucide-vue-next.d.ts';
|
||||
|
||||
// Generates header of d.ts file include some types and functions
|
||||
const typeDefinitions = `\
|
||||
import { Component } from 'vue';
|
||||
declare module 'lucide-vue-next'
|
||||
|
||||
// Create interface extending SVGAttributes
|
||||
export interface SVGProps extends Partial<SVGElement> ${JSON.stringify(defaultAttributes, null, 2)}
|
||||
|
||||
// Generated icons
|
||||
`;
|
||||
|
||||
resetFile(TYPES_FILE_NAME, TARGET_DIR);
|
||||
appendFile(typeDefinitions, TYPES_FILE_NAME, TARGET_DIR);
|
||||
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
|
||||
svgFiles.forEach(svgFile => {
|
||||
const nameSvg = path.basename(svgFile, '.svg');
|
||||
const componentName = toPascalCase(nameSvg);
|
||||
|
||||
appendFile(
|
||||
`export declare const ${componentName}: (props: SVGProps) => Component;\n`,
|
||||
TYPES_FILE_NAME,
|
||||
TARGET_DIR,
|
||||
);
|
||||
});
|
||||
|
||||
console.log(`Generated ${TYPES_FILE_NAME} file with`, svgFiles.length, 'icons');
|
||||
7
packages/lucide-vue-next/scripts/exportTemplate.js
Normal file
7
packages/lucide-vue-next/scripts/exportTemplate.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default ({ componentName, children }) => `
|
||||
import createVueComponent from '../createVueComponent';
|
||||
|
||||
const ${componentName} = createVueComponent('${componentName}Icon', ${JSON.stringify(children)});
|
||||
|
||||
export default ${componentName};
|
||||
`;
|
||||
Reference in New Issue
Block a user