-
-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init new react package project * setup react package * Fix config for build * update package * Fix build * update package * fix package.json * refactor and cleanup * bumb beta version * fix regex * bump version * Add hashing * Add tests * bump version * Add peer dependecies * Add docs * Add readme link
- Loading branch information
1 parent
571cab8
commit cedf113
Showing
335 changed files
with
5,164 additions
and
11,847 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
"extends": ["airbnb-base", "prettier"], | ||
"plugins": ["import", "prettier"], | ||
"rules": { | ||
"no-console": "off", | ||
"no-param-reassign": "off", | ||
"no-shadow": "off", | ||
"no-use-before-define": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
extends: ['airbnb-base', 'prettier'], | ||
plugins: ['import', 'prettier'], | ||
rules: { | ||
'no-console': 'off', | ||
'no-param-reassign': 'off', | ||
'no-shadow': 'off', | ||
'no-use-before-define': 'off', | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
singleQuote: true, | ||
trailingComma: 'all' | ||
} | ||
] | ||
} | ||
} | ||
}; |
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,73 @@ | ||
# Lucide React | ||
|
||
Use the lucide icon library in you react app. | ||
|
||
## Installation | ||
|
||
```sh | ||
yarn add lucide-react | ||
|
||
# or | ||
|
||
npm install lucide-react | ||
``` | ||
|
||
## How to use | ||
|
||
It's build with ESmodules so it's completely threeshakable. | ||
Each icon can be imported as an react component. | ||
|
||
### Example | ||
|
||
You can pass additional props to adjust the icon. | ||
|
||
``` js | ||
import { Camera } from 'lucide-react'; | ||
// Returns ReactComponent | ||
|
||
// Usage | ||
const App = () => { | ||
return <Camera color="red" size={48}/> | ||
}; | ||
|
||
export default App; | ||
``` | ||
|
||
### Props | ||
|
||
| name | type | default | ||
| ------------ | -------- | -------- | ||
| `size` | *Number* | 24 | ||
| `color` | *String* | currentColor | ||
| `strokeWidth`| *Number* | 2 | ||
|
||
### Custom props | ||
|
||
You can also pass custom props that will be added in the svg as attributes. | ||
|
||
``` js | ||
// Usage | ||
const App = () => { | ||
return <Camera fill="red"/> | ||
}; | ||
``` | ||
|
||
### One generic icon component | ||
|
||
It is possible to create one generic icon component to load icons. | ||
|
||
> :warning: Example below importing all EsModules, caution using this example, not recommended when you using bundlers. | ||
#### Icon Component Example | ||
|
||
``` js | ||
import * as icons from 'lucide-react'; | ||
|
||
const Icon = ({name, color, size}) => { | ||
const LucideIcon = icons[name]; | ||
|
||
return <LucideIcon color={color} size={size} /> | ||
}; | ||
|
||
export default Icon; | ||
``` |
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,4 @@ | ||
// module.exports = require('../../babel.config'); | ||
module.exports = { | ||
presets: ['react-app'], | ||
}; |
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,12 @@ | ||
module.exports = { | ||
verbose: true, | ||
roots: ['<rootDir>/src/', '<rootDir>/tests/'], | ||
moduleFileExtensions: ['js'], | ||
transformIgnorePatterns: [`/node_modules`], | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
}, | ||
transform: { | ||
'^.+\\.js$': 'babel-jest', | ||
}, | ||
}; |
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,37 @@ | ||
{ | ||
"name": "lucide-react", | ||
"description": "Lucide is a community-run fork of Feather Icons, open for anyone to contribute icons.", | ||
"version": "0.1.2-beta.5", | ||
"license": "ISC", | ||
"amdName": "lucide-react", | ||
"source": "build/lucide-react.js", | ||
"main": "dist/cjs/lucide-react.js", | ||
"main:umd": "dist/umd/lucide-react.js", | ||
"module": "dist/esm/lucide-react.js", | ||
"unpkg": "dist/umd/lucide-react.min.js", | ||
"repository": "github:lucide-icons/lucide", | ||
"author": "Eric Fennis", | ||
"scripts": { | ||
"build": "yarn clean && yarn build:move && yarn build:icons && yarn build:es && yarn build:bundles", | ||
"clean": "rm -rf dist && rm -rf build", | ||
"build:move": "cp -av src build", | ||
"build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-react/build --templateSrc=../packages/lucide-react/scripts/exportTemplate --camelizeAttrs --renderUniqueKey", | ||
"build:es": "yarn --cwd ../../ babel packages/lucide-react/build -d packages/lucide-react/dist/esm", | ||
"build:bundles": "yarn --cwd ../../ rollup -c packages/lucide-react/rollup.config.js", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"prop-types": "^15.7.2", | ||
"react": "^17.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-preset-react-app": "^10.0.0", | ||
"jest": "^26.6.3", | ||
"lucide": "file:../..", | ||
"react-test-renderer": "^17.0.1" | ||
}, | ||
"peerDependencies": { | ||
"prop-types": "^15.7.2", | ||
"react": "^17.0.1" | ||
} | ||
} |
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,47 @@ | ||
const plugins = require('lucide/rollup.plugins'); | ||
const pkg = require('./package.json'); | ||
|
||
const outputFileName = pkg.name; | ||
const rootDir = 'packages/lucide-react'; // It runs from the root | ||
const outputDir = `${rootDir}/dist`; | ||
const inputs = [`${rootDir}/build/lucide-react.js`]; | ||
const bundles = [ | ||
{ | ||
format: 'umd', | ||
inputs, | ||
outputDir, | ||
minify: true, | ||
}, | ||
{ | ||
format: 'umd', | ||
inputs, | ||
outputDir, | ||
}, | ||
{ | ||
format: 'cjs', | ||
inputs, | ||
outputDir, | ||
}, | ||
]; | ||
|
||
const configs = bundles | ||
.map(({ inputs, outputDir, format, minify }) => | ||
inputs.map(input => ({ | ||
input, | ||
plugins: plugins(pkg, minify), | ||
external: ['react', 'prop-types'], | ||
output: { | ||
name: outputFileName, | ||
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`, | ||
format, | ||
sourcemap: true, | ||
globals: { | ||
react: 'react', | ||
'prop-types': 'PropTypes', | ||
}, | ||
}, | ||
})), | ||
) | ||
.flat(); | ||
|
||
export default configs; |
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,7 @@ | ||
export default ({ componentName, node }) => ` | ||
import createReactComponent from '../createReactComponent'; | ||
const ${componentName} = createReactComponent('${componentName}', ${node}); | ||
export default ${componentName}; | ||
`; |
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,31 @@ | ||
import { forwardRef, createElement } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default (iconName, [tag, attrs, children]) => { | ||
const Component = forwardRef( | ||
({ color = 'currentColor', size = 24, strokeWidth = 2, ...rest }, ref) => | ||
createElement( | ||
tag, | ||
{ | ||
ref, | ||
...attrs, | ||
width: size, | ||
height: size, | ||
color, | ||
strokeWidth, | ||
...rest, | ||
}, | ||
children.map(([childTag, childAttrs]) => createElement(childTag, childAttrs)), | ||
), | ||
); | ||
|
||
Component.propTypes = { | ||
color: PropTypes.string, | ||
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
}; | ||
|
||
Component.displayName = `${iconName}`; | ||
|
||
return Component; | ||
}; |
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,5 @@ | ||
/* | ||
Icons exports. | ||
Will be generated | ||
*/ |
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 @@ | ||
export * from './icons'; |
Oops, something went wrong.