Lucide 0.15.0 (#272)
* add configs
* Add vue components
* Add documentation
* add alpha release version
* improve npm ignore files
* add tests
* Make style and class attrs work
* 📦 bump version
* Add Icon suffix for component names
* bump version
* Add icon component example
* remove space
* add new build strategy
* Write a better intro
* add other node design
* fix
* add new default template
* add tempalte
* improve code
* small improvements
* small improvements
* move files
* Connect lucide with lucide-react
* Add support for vue
* Add licenses to packages
* Fix tests
* refactor build scripts
* Minor code fixes
* update homepage readme
* Update footer text
* Add a better introduction to packages
* Split up in tempaltes
* Add new types build file
* Setup workflow file
* update readme
* update
* Fix build
* remove debug code
* Add check if svgs have duplicated children
* Add check if their are no children
* small fixes
* last fixes in the build
* Move script to packages folder
* Fix tests and add types for lucide
* Add rule to package.json
* add types in build
* add npm ignore
* update package.jsons
This commit is contained in:
@@ -2,9 +2,10 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Converts string to PascalCase
|
||||
* Converts string to CamelCase
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A camelized string
|
||||
*/
|
||||
export const toCamelCase = string =>
|
||||
string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) =>
|
||||
@@ -15,6 +16,7 @@ export const toCamelCase = string =>
|
||||
* Converts string to PascalCase
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A pascalized string
|
||||
*/
|
||||
export const toPascalCase = string => {
|
||||
const camelCase = toCamelCase(string);
|
||||
@@ -23,9 +25,10 @@ export const toPascalCase = string => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts string to PascalCase
|
||||
* Converts string to KebabCase
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A kebabized string
|
||||
*/
|
||||
export const toKebabCase = string => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
|
||||
@@ -42,6 +45,7 @@ export const resetFile = (fileName, outputDirectory) =>
|
||||
* Reads the file contents.
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {string} The contents of a file
|
||||
*/
|
||||
export const readFile = entry => fs.readFileSync(path.resolve(__dirname, '../', entry), 'utf-8');
|
||||
|
||||
@@ -69,6 +73,7 @@ export const writeFile = (content, fileName, outputDirectory) =>
|
||||
* reads the icon directory
|
||||
*
|
||||
* @param {string} directory
|
||||
* @returns {array} An array of file paths containig svgs
|
||||
*/
|
||||
export const readSvgDirectory = directory =>
|
||||
fs.readdirSync(directory).filter(file => path.extname(file) === '.svg');
|
||||
@@ -79,7 +84,8 @@ export const readSvgDirectory = directory =>
|
||||
* @param {string} fileName
|
||||
* @param {string} directory
|
||||
*/
|
||||
export const readSvg = (fileName, directory) => fs.readFileSync(path.join(directory, fileName));
|
||||
export const readSvg = (fileName, directory) =>
|
||||
fs.readFileSync(path.join(directory, fileName), 'utf-8');
|
||||
|
||||
/**
|
||||
* writes content to a file
|
||||
@@ -91,7 +97,13 @@ export const readSvg = (fileName, directory) => fs.readFileSync(path.join(direct
|
||||
export const writeSvgFile = (fileName, outputDirectory, content) =>
|
||||
fs.writeFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
|
||||
|
||||
// This is a djb2 hashing function
|
||||
/**
|
||||
* djb2 hashing function
|
||||
*
|
||||
* @param {string} string
|
||||
* @param {number} seed
|
||||
* @returns {string} A hashed string of 6 characters
|
||||
*/
|
||||
export const hash = (string, seed = 5381) => {
|
||||
let i = string.length;
|
||||
|
||||
@@ -103,3 +115,27 @@ export const hash = (string, seed = 5381) => {
|
||||
// eslint-disable-next-line no-bitwise
|
||||
return (seed >>> 0).toString(36).substr(0, 6);
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate Hashed string based on name and attributes
|
||||
*
|
||||
* @param {object} seed
|
||||
* @param {string} seed.name A name, for example an icon name
|
||||
* @param {object} seed.attributes An object of SVGElement Attrbutes
|
||||
* @returns {string} A hashed string of 6 characters
|
||||
*/
|
||||
export const generateHashedKey = ({ name, attributes }) => hash(JSON.stringify([name, attributes]));
|
||||
|
||||
/**
|
||||
* Checks if array of items contains duplicated items
|
||||
*
|
||||
* @param {array} children an array of items
|
||||
* @returns {Boolean} if items contains duplicated items.
|
||||
*/
|
||||
export const hasDuplicatedChildren = children => {
|
||||
const hashedKeys = children.map(generateHashedKey);
|
||||
|
||||
return !hashedKeys.every(
|
||||
(key, index) => index === hashedKeys.findIndex(childKey => childKey === key),
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user